effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2
let modifies_buffer128_3 (b1 b2 b3: M.buffer128) (h1 h2: vale_heap) =
false
null
false
modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Memory.buffer128", "Vale.PPC64LE.Decls.vale_heap", "Vale.PPC64LE.Decls.modifies_mem", "Vale.PPC64LE.Memory.loc_union", "Vale.PPC64LE.Decls.loc_buffer", "Vale.PPC64LE.Memory.vuint128", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val modifies_buffer128_3 : b1: Vale.PPC64LE.Memory.buffer128 -> b2: Vale.PPC64LE.Memory.buffer128 -> b3: Vale.PPC64LE.Memory.buffer128 -> h1: Vale.PPC64LE.Decls.vale_heap -> h2: Vale.PPC64LE.Decls.vale_heap -> Vale.Def.Prop_s.prop0
[]
Vale.PPC64LE.Decls.modifies_buffer128_3
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b1: Vale.PPC64LE.Memory.buffer128 -> b2: Vale.PPC64LE.Memory.buffer128 -> b3: Vale.PPC64LE.Memory.buffer128 -> h1: Vale.PPC64LE.Decls.vale_heap -> h2: Vale.PPC64LE.Decls.vale_heap -> Vale.Def.Prop_s.prop0
{ "end_col": 96, "end_line": 294, "start_col": 2, "start_line": 294 }
Prims.Tot
val valid_mem_addr (tm: tmaddr) (s: state) : prop0
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout
val valid_mem_addr (tm: tmaddr) (s: state) : prop0 let valid_mem_addr (tm: tmaddr) (s: state) : prop0 =
false
null
false
let m, t = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Machine_s.tmaddr", "Vale.PPC64LE.State.state", "Vale.PPC64LE.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Prims.l_and", "Vale.PPC64LE.State.valid_maddr", "Vale.PPC64LE.Decls.valid_mem_operand64", "Vale.PPC64LE.State.eval_maddr", "Vale.PPC64LE.Memory.get_vale_heap", "Vale.PPC64LE.Decls.coerce", "Vale.PPC64LE.Memory.vale_full_heap", "Vale.Arch.Heap.heap_impl", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_heap", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_layout", "Vale.Arch.HeapImpl.vale_full_heap", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_mem_addr (tm: tmaddr) (s: state) : prop0
[]
Vale.PPC64LE.Decls.valid_mem_addr
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
tm: Vale.PPC64LE.Machine_s.tmaddr -> s: Vale.PPC64LE.State.state -> Vale.Def.Prop_s.prop0
{ "end_col": 106, "end_line": 120, "start_col": 50, "start_line": 117 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn
let validSrcAddrs (#t: base_typ) (h: vale_heap) (addr: int) (b: M.buffer t) (len: int) (layout: vale_heap_layout) (tn: taint) =
false
null
false
buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.Arch.HeapTypes_s.base_typ", "Vale.PPC64LE.Decls.vale_heap", "Prims.int", "Vale.PPC64LE.Memory.buffer", "Vale.Arch.HeapImpl.vale_heap_layout", "Vale.Arch.HeapTypes_s.taint", "Prims.l_and", "Vale.PPC64LE.Decls.buffer_readable", "Prims.b2t", "Prims.op_LessThanOrEqual", "Vale.PPC64LE.Decls.buffer_length", "Prims.eq2", "Vale.PPC64LE.Memory.buffer_addr", "Vale.PPC64LE.Memory.valid_layout_buffer_id", "Vale.PPC64LE.Memory.get_heaplet_id", "Vale.PPC64LE.Memory.valid_taint_buf", "Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout__item__vl_taint", "Prims.logical" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2
false
false
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validSrcAddrs : h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer t -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
[]
Vale.PPC64LE.Decls.validSrcAddrs
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer t -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
{ "end_col": 42, "end_line": 301, "start_col": 2, "start_line": 297 }
Prims.Tot
val va_get_mem (s: va_state) : vale_heap
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap)
val va_get_mem (s: va_state) : vale_heap let va_get_mem (s: va_state) : vale_heap =
false
null
false
M.get_vale_heap (coerce s.ms_heap)
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_state", "Vale.PPC64LE.Memory.get_vale_heap", "Vale.PPC64LE.Decls.coerce", "Vale.PPC64LE.Memory.vale_full_heap", "Vale.Arch.Heap.heap_impl", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_heap", "Vale.PPC64LE.Decls.vale_heap" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_get_mem (s: va_state) : vale_heap
[]
Vale.PPC64LE.Decls.va_get_mem
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.PPC64LE.Decls.va_state -> Vale.PPC64LE.Decls.vale_heap
{ "end_col": 95, "end_line": 148, "start_col": 61, "start_line": 148 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b
let validDstAddrs (#t: base_typ) (h: vale_heap) (addr: int) (b: M.buffer t) (len: int) (layout: vale_heap_layout) (tn: taint) =
false
null
false
validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.Arch.HeapTypes_s.base_typ", "Vale.PPC64LE.Decls.vale_heap", "Prims.int", "Vale.PPC64LE.Memory.buffer", "Vale.Arch.HeapImpl.vale_heap_layout", "Vale.Arch.HeapTypes_s.taint", "Prims.l_and", "Vale.PPC64LE.Decls.validSrcAddrs", "Vale.PPC64LE.Memory.valid_layout_buffer_id", "Vale.PPC64LE.Memory.get_heaplet_id", "Vale.PPC64LE.Decls.buffer_writeable", "Prims.logical" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn
false
false
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validDstAddrs : h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer t -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
[]
Vale.PPC64LE.Decls.validDstAddrs
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer t -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
{ "end_col": 20, "end_line": 306, "start_col": 2, "start_line": 304 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn
let validSrcAddrs64 (h: vale_heap) (addr: int) (b: M.buffer64) (len: int) (layout: vale_heap_layout) (tn: taint) =
false
null
false
validSrcAddrs h addr b len layout tn
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.vale_heap", "Prims.int", "Vale.PPC64LE.Memory.buffer64", "Vale.Arch.HeapImpl.vale_heap_layout", "Vale.Arch.HeapTypes_s.taint", "Vale.PPC64LE.Decls.validSrcAddrs", "Vale.PPC64LE.Memory.vuint64", "Prims.logical" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validSrcAddrs64 : h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer64 -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
[]
Vale.PPC64LE.Decls.validSrcAddrs64
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer64 -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
{ "end_col": 38, "end_line": 309, "start_col": 2, "start_line": 309 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn
let validDstAddrs64 (h: vale_heap) (addr: int) (b: M.buffer64) (len: int) (layout: vale_heap_layout) (tn: taint) =
false
null
false
validDstAddrs h addr b len layout tn
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.vale_heap", "Prims.int", "Vale.PPC64LE.Memory.buffer64", "Vale.Arch.HeapImpl.vale_heap_layout", "Vale.Arch.HeapTypes_s.taint", "Vale.PPC64LE.Decls.validDstAddrs", "Vale.PPC64LE.Memory.vuint64", "Prims.logical" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validDstAddrs64 : h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer64 -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
[]
Vale.PPC64LE.Decls.validDstAddrs64
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer64 -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
{ "end_col": 38, "end_line": 312, "start_col": 2, "start_line": 312 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn
let validSrcAddrs128 (h: vale_heap) (addr: int) (b: M.buffer128) (len: int) (layout: vale_heap_layout) (tn: taint) =
false
null
false
validSrcAddrs h addr b len layout tn
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.vale_heap", "Prims.int", "Vale.PPC64LE.Memory.buffer128", "Vale.Arch.HeapImpl.vale_heap_layout", "Vale.Arch.HeapTypes_s.taint", "Vale.PPC64LE.Decls.validSrcAddrs", "Vale.PPC64LE.Memory.vuint128", "Prims.logical" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validSrcAddrs128 : h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer128 -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
[]
Vale.PPC64LE.Decls.validSrcAddrs128
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer128 -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
{ "end_col": 38, "end_line": 315, "start_col": 2, "start_line": 315 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let validDstAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn
let validDstAddrs128 (h: vale_heap) (addr: int) (b: M.buffer128) (len: int) (layout: vale_heap_layout) (tn: taint) =
false
null
false
validDstAddrs h addr b len layout tn
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.vale_heap", "Prims.int", "Vale.PPC64LE.Memory.buffer128", "Vale.Arch.HeapImpl.vale_heap_layout", "Vale.Arch.HeapTypes_s.taint", "Vale.PPC64LE.Decls.validDstAddrs", "Vale.PPC64LE.Memory.vuint128", "Prims.logical" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validDstAddrs128 : h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer128 -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
[]
Vale.PPC64LE.Decls.validDstAddrs128
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer128 -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
{ "end_col": 38, "end_line": 318, "start_col": 2, "start_line": 318 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let validSrcAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h (addr - 16 * offset) b (len + offset) layout tn
let validSrcAddrsOffset128 (h: vale_heap) (addr: int) (b: M.buffer128) (offset len: int) (layout: vale_heap_layout) (tn: taint) =
false
null
false
validSrcAddrs h (addr - 16 * offset) b (len + offset) layout tn
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.vale_heap", "Prims.int", "Vale.PPC64LE.Memory.buffer128", "Vale.Arch.HeapImpl.vale_heap_layout", "Vale.Arch.HeapTypes_s.taint", "Vale.PPC64LE.Decls.validSrcAddrs", "Vale.PPC64LE.Memory.vuint128", "Prims.op_Subtraction", "FStar.Mul.op_Star", "Prims.op_Addition", "Prims.logical" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validSrcAddrsOffset128 : h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer128 -> offset: Prims.int -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
[]
Vale.PPC64LE.Decls.validSrcAddrsOffset128
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer128 -> offset: Prims.int -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
{ "end_col": 65, "end_line": 321, "start_col": 2, "start_line": 321 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let validDstAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h (addr - 16 * offset) b (len + offset) layout tn
let validDstAddrsOffset128 (h: vale_heap) (addr: int) (b: M.buffer128) (offset len: int) (layout: vale_heap_layout) (tn: taint) =
false
null
false
validDstAddrs h (addr - 16 * offset) b (len + offset) layout tn
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.vale_heap", "Prims.int", "Vale.PPC64LE.Memory.buffer128", "Vale.Arch.HeapImpl.vale_heap_layout", "Vale.Arch.HeapTypes_s.taint", "Vale.PPC64LE.Decls.validDstAddrs", "Vale.PPC64LE.Memory.vuint128", "Prims.op_Subtraction", "FStar.Mul.op_Star", "Prims.op_Addition", "Prims.logical" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h (addr - 16 * offset) b (len + offset) layout tn
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validDstAddrsOffset128 : h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer128 -> offset: Prims.int -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
[]
Vale.PPC64LE.Decls.validDstAddrsOffset128
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.PPC64LE.Decls.vale_heap -> addr: Prims.int -> b: Vale.PPC64LE.Memory.buffer128 -> offset: Prims.int -> len: Prims.int -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> tn: Vale.Arch.HeapTypes_s.taint -> Prims.logical
{ "end_col": 65, "end_line": 324, "start_col": 2, "start_line": 324 }
Prims.GTot
val buffer_modifies_specific128 (b: M.buffer128) (h1 h2: vale_heap) (start last: nat) : GTot prop0
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let buffer_modifies_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2)
val buffer_modifies_specific128 (b: M.buffer128) (h1 h2: vale_heap) (start last: nat) : GTot prop0 let buffer_modifies_specific128 (b: M.buffer128) (h1 h2: vale_heap) (start last: nat) : GTot prop0 =
false
null
false
(forall (i: nat). {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2)
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "sometrivial" ]
[ "Vale.PPC64LE.Memory.buffer128", "Vale.PPC64LE.Decls.vale_heap", "Prims.nat", "Prims.l_Forall", "Prims.l_imp", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Vale.PPC64LE.Decls.buffer_length", "Vale.PPC64LE.Memory.vuint128", "Prims.op_BarBar", "Prims.op_GreaterThan", "Prims.eq2", "Vale.PPC64LE.Machine_s.quad32", "Vale.PPC64LE.Decls.buffer128_read", "FStar.Seq.Base.index", "Vale.PPC64LE.Memory.base_typ_as_vale_type", "Vale.PPC64LE.Memory.buffer_as_seq", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h (addr - 16 * offset) b (len + offset) layout tn let validDstAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h (addr - 16 * offset) b (len + offset) layout tn let modifies_buffer_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer128 b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let buffer_modifies_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 =
false
false
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val buffer_modifies_specific128 (b: M.buffer128) (h1 h2: vale_heap) (start last: nat) : GTot prop0
[]
Vale.PPC64LE.Decls.buffer_modifies_specific128
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Vale.PPC64LE.Memory.buffer128 -> h1: Vale.PPC64LE.Decls.vale_heap -> h2: Vale.PPC64LE.Decls.vale_heap -> start: Prims.nat -> last: Prims.nat -> Prims.GTot Vale.Def.Prop_s.prop0
{ "end_col": 46, "end_line": 341, "start_col": 4, "start_line": 337 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let buffers_disjoint128 (b1 b2:M.buffer128) = locs_disjoint [loc_buffer b1; loc_buffer b2]
let buffers_disjoint128 (b1 b2: M.buffer128) =
false
null
false
locs_disjoint [loc_buffer b1; loc_buffer b2]
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Memory.buffer128", "Vale.PPC64LE.Decls.locs_disjoint", "Prims.Cons", "Vale.PPC64LE.Memory.loc", "Vale.PPC64LE.Decls.loc_buffer", "Vale.PPC64LE.Memory.vuint128", "Prims.Nil", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h (addr - 16 * offset) b (len + offset) layout tn let validDstAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h (addr - 16 * offset) b (len + offset) layout tn let modifies_buffer_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer128 b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let buffer_modifies_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let modifies_buffer_specific (b:M.buffer64) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer64_read b i h1 == buffer64_read b i h2) unfold let buffers_disjoint (b1 b2:M.buffer64) = locs_disjoint [loc_buffer b1; loc_buffer b2]
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val buffers_disjoint128 : b1: Vale.PPC64LE.Memory.buffer128 -> b2: Vale.PPC64LE.Memory.buffer128 -> Vale.Def.Prop_s.prop0
[]
Vale.PPC64LE.Decls.buffers_disjoint128
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b1: Vale.PPC64LE.Memory.buffer128 -> b2: Vale.PPC64LE.Memory.buffer128 -> Vale.Def.Prop_s.prop0
{ "end_col": 48, "end_line": 356, "start_col": 4, "start_line": 356 }
Prims.GTot
val modifies_buffer_specific128 (b: M.buffer128) (h1 h2: vale_heap) (start last: nat) : GTot prop0
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let modifies_buffer_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer128 b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2)
val modifies_buffer_specific128 (b: M.buffer128) (h1 h2: vale_heap) (start last: nat) : GTot prop0 let modifies_buffer_specific128 (b: M.buffer128) (h1 h2: vale_heap) (start last: nat) : GTot prop0 =
false
null
false
modifies_buffer128 b h1 h2 /\ (forall (i: nat). {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2)
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "sometrivial" ]
[ "Vale.PPC64LE.Memory.buffer128", "Vale.PPC64LE.Decls.vale_heap", "Prims.nat", "Prims.l_and", "Vale.PPC64LE.Decls.modifies_buffer128", "Prims.l_Forall", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Vale.PPC64LE.Decls.buffer_length", "Vale.PPC64LE.Memory.vuint128", "Prims.op_BarBar", "Prims.op_GreaterThan", "Prims.eq2", "Vale.PPC64LE.Machine_s.quad32", "Vale.PPC64LE.Decls.buffer128_read", "FStar.Seq.Base.index", "Vale.PPC64LE.Memory.base_typ_as_vale_type", "Vale.PPC64LE.Memory.buffer_as_seq", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h (addr - 16 * offset) b (len + offset) layout tn let validDstAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h (addr - 16 * offset) b (len + offset) layout tn
false
false
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val modifies_buffer_specific128 (b: M.buffer128) (h1 h2: vale_heap) (start last: nat) : GTot prop0
[]
Vale.PPC64LE.Decls.modifies_buffer_specific128
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Vale.PPC64LE.Memory.buffer128 -> h1: Vale.PPC64LE.Decls.vale_heap -> h2: Vale.PPC64LE.Decls.vale_heap -> start: Prims.nat -> last: Prims.nat -> Prims.GTot Vale.Def.Prop_s.prop0
{ "end_col": 46, "end_line": 333, "start_col": 4, "start_line": 327 }
Prims.GTot
val va_evalCond (b: ocmp) (s: va_state) : GTot bool
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_evalCond (b:ocmp) (s:va_state) : GTot bool = eval_ocmp s b
val va_evalCond (b: ocmp) (s: va_state) : GTot bool let va_evalCond (b: ocmp) (s: va_state) : GTot bool =
false
null
false
eval_ocmp s b
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "sometrivial" ]
[ "Vale.PPC64LE.Decls.ocmp", "Vale.PPC64LE.Decls.va_state", "Vale.PPC64LE.Decls.eval_ocmp", "Prims.bool" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h (addr - 16 * offset) b (len + offset) layout tn let validDstAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h (addr - 16 * offset) b (len + offset) layout tn let modifies_buffer_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer128 b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let buffer_modifies_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let modifies_buffer_specific (b:M.buffer64) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer64_read b i h1 == buffer64_read b i h2) unfold let buffers_disjoint (b1 b2:M.buffer64) = locs_disjoint [loc_buffer b1; loc_buffer b2] unfold let buffers_disjoint128 (b1 b2:M.buffer128) = locs_disjoint [loc_buffer b1; loc_buffer b2] let rec loc_locs_disjoint_rec128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec128 l t unfold let buffer_disjoints128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec128]] (loc_locs_disjoint_rec128 l ls) let rec loc_locs_disjoint_rec64_128 (l:M.buffer64) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec64_128 l t unfold let buffer_disjoints64_128 (l:M.buffer64) (ls:list (M.buffer128)) : prop0 = norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec64_128]] (loc_locs_disjoint_rec64_128 l ls) unfold let buffers3_disjoint128 (b1 b2 b3:M.buffer128) = locs_disjoint [loc_buffer b1; loc_buffer b2; loc_buffer b3] val eval_code (c:va_code) (s0:va_state) (f0:va_fuel) (sN:va_state) : prop0 val eval_while_inv (c:va_code) (s0:va_state) (fW:va_fuel) (sW:va_state) : prop0 [@va_qattr] let va_state_eq (s0:va_state) (s1:va_state) : prop0 = state_eq s0 s1 let state_inv (s:state) : prop0 = M.mem_inv (coerce s.ms_heap) let va_require_total (c0:va_code) (c1:va_code) (s0:va_state) : prop0 = c0 == c1 /\ state_inv s0 let va_ensure_total (c0:va_code) (s0:va_state) (s1:va_state) (f1:va_fuel) : prop0 = eval_code c0 s0 f1 s1 /\ state_inv s1 val va_ins_lemma (c0:va_code) (s0:va_state) : Lemma (requires True) (ensures True)
false
false
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_evalCond (b: ocmp) (s: va_state) : GTot bool
[]
Vale.PPC64LE.Decls.va_evalCond
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Vale.PPC64LE.Decls.ocmp -> s: Vale.PPC64LE.Decls.va_state -> Prims.GTot Prims.bool
{ "end_col": 72, "end_line": 398, "start_col": 59, "start_line": 398 }
Prims.Tot
val buffer_disjoints128 (l: M.buffer128) (ls: list (M.buffer128)) : prop0
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let buffer_disjoints128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec128]] (loc_locs_disjoint_rec128 l ls)
val buffer_disjoints128 (l: M.buffer128) (ls: list (M.buffer128)) : prop0 let buffer_disjoints128 (l: M.buffer128) (ls: list (M.buffer128)) : prop0 =
false
null
false
norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec128]] (loc_locs_disjoint_rec128 l ls)
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Memory.buffer128", "Prims.list", "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.zeta", "FStar.Pervasives.iota", "FStar.Pervasives.delta_only", "Prims.string", "Prims.Nil", "Vale.Def.Prop_s.prop0", "Vale.PPC64LE.Decls.loc_locs_disjoint_rec128" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h (addr - 16 * offset) b (len + offset) layout tn let validDstAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h (addr - 16 * offset) b (len + offset) layout tn let modifies_buffer_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer128 b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let buffer_modifies_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let modifies_buffer_specific (b:M.buffer64) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer64_read b i h1 == buffer64_read b i h2) unfold let buffers_disjoint (b1 b2:M.buffer64) = locs_disjoint [loc_buffer b1; loc_buffer b2] unfold let buffers_disjoint128 (b1 b2:M.buffer128) = locs_disjoint [loc_buffer b1; loc_buffer b2] let rec loc_locs_disjoint_rec128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec128 l t unfold
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val buffer_disjoints128 (l: M.buffer128) (ls: list (M.buffer128)) : prop0
[]
Vale.PPC64LE.Decls.buffer_disjoints128
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Vale.PPC64LE.Memory.buffer128 -> ls: Prims.list Vale.PPC64LE.Memory.buffer128 -> Vale.Def.Prop_s.prop0
{ "end_col": 92, "end_line": 365, "start_col": 2, "start_line": 365 }
Prims.Tot
val buffer_disjoints64_128 (l: M.buffer64) (ls: list (M.buffer128)) : prop0
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let buffer_disjoints64_128 (l:M.buffer64) (ls:list (M.buffer128)) : prop0 = norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec64_128]] (loc_locs_disjoint_rec64_128 l ls)
val buffer_disjoints64_128 (l: M.buffer64) (ls: list (M.buffer128)) : prop0 let buffer_disjoints64_128 (l: M.buffer64) (ls: list (M.buffer128)) : prop0 =
false
null
false
norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec64_128]] (loc_locs_disjoint_rec64_128 l ls)
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Memory.buffer64", "Prims.list", "Vale.PPC64LE.Memory.buffer128", "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.zeta", "FStar.Pervasives.iota", "FStar.Pervasives.delta_only", "Prims.string", "Prims.Nil", "Vale.Def.Prop_s.prop0", "Vale.PPC64LE.Decls.loc_locs_disjoint_rec64_128" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h (addr - 16 * offset) b (len + offset) layout tn let validDstAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h (addr - 16 * offset) b (len + offset) layout tn let modifies_buffer_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer128 b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let buffer_modifies_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let modifies_buffer_specific (b:M.buffer64) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer64_read b i h1 == buffer64_read b i h2) unfold let buffers_disjoint (b1 b2:M.buffer64) = locs_disjoint [loc_buffer b1; loc_buffer b2] unfold let buffers_disjoint128 (b1 b2:M.buffer128) = locs_disjoint [loc_buffer b1; loc_buffer b2] let rec loc_locs_disjoint_rec128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec128 l t unfold let buffer_disjoints128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec128]] (loc_locs_disjoint_rec128 l ls) let rec loc_locs_disjoint_rec64_128 (l:M.buffer64) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec64_128 l t unfold
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val buffer_disjoints64_128 (l: M.buffer64) (ls: list (M.buffer128)) : prop0
[]
Vale.PPC64LE.Decls.buffer_disjoints64_128
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Vale.PPC64LE.Memory.buffer64 -> ls: Prims.list Vale.PPC64LE.Memory.buffer128 -> Vale.Def.Prop_s.prop0
{ "end_col": 98, "end_line": 374, "start_col": 2, "start_line": 374 }
Prims.Tot
val va_ensure_total (c0: va_code) (s0 s1: va_state) (f1: va_fuel) : prop0
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_ensure_total (c0:va_code) (s0:va_state) (s1:va_state) (f1:va_fuel) : prop0 = eval_code c0 s0 f1 s1 /\ state_inv s1
val va_ensure_total (c0: va_code) (s0 s1: va_state) (f1: va_fuel) : prop0 let va_ensure_total (c0: va_code) (s0 s1: va_state) (f1: va_fuel) : prop0 =
false
null
false
eval_code c0 s0 f1 s1 /\ state_inv s1
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_code", "Vale.PPC64LE.Decls.va_state", "Vale.PPC64LE.Decls.va_fuel", "Prims.l_and", "Vale.PPC64LE.Decls.eval_code", "Vale.PPC64LE.Decls.state_inv", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h (addr - 16 * offset) b (len + offset) layout tn let validDstAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h (addr - 16 * offset) b (len + offset) layout tn let modifies_buffer_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer128 b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let buffer_modifies_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let modifies_buffer_specific (b:M.buffer64) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer64_read b i h1 == buffer64_read b i h2) unfold let buffers_disjoint (b1 b2:M.buffer64) = locs_disjoint [loc_buffer b1; loc_buffer b2] unfold let buffers_disjoint128 (b1 b2:M.buffer128) = locs_disjoint [loc_buffer b1; loc_buffer b2] let rec loc_locs_disjoint_rec128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec128 l t unfold let buffer_disjoints128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec128]] (loc_locs_disjoint_rec128 l ls) let rec loc_locs_disjoint_rec64_128 (l:M.buffer64) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec64_128 l t unfold let buffer_disjoints64_128 (l:M.buffer64) (ls:list (M.buffer128)) : prop0 = norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec64_128]] (loc_locs_disjoint_rec64_128 l ls) unfold let buffers3_disjoint128 (b1 b2 b3:M.buffer128) = locs_disjoint [loc_buffer b1; loc_buffer b2; loc_buffer b3] val eval_code (c:va_code) (s0:va_state) (f0:va_fuel) (sN:va_state) : prop0 val eval_while_inv (c:va_code) (s0:va_state) (fW:va_fuel) (sW:va_state) : prop0 [@va_qattr] let va_state_eq (s0:va_state) (s1:va_state) : prop0 = state_eq s0 s1 let state_inv (s:state) : prop0 = M.mem_inv (coerce s.ms_heap) let va_require_total (c0:va_code) (c1:va_code) (s0:va_state) : prop0 = c0 == c1 /\ state_inv s0
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_ensure_total (c0: va_code) (s0 s1: va_state) (f1: va_fuel) : prop0
[]
Vale.PPC64LE.Decls.va_ensure_total
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c0: Vale.PPC64LE.Decls.va_code -> s0: Vale.PPC64LE.Decls.va_state -> s1: Vale.PPC64LE.Decls.va_state -> f1: Vale.PPC64LE.Decls.va_fuel -> Vale.Def.Prop_s.prop0
{ "end_col": 39, "end_line": 391, "start_col": 2, "start_line": 391 }
Prims.Tot
val va_require_total (c0 c1: va_code) (s0: va_state) : prop0
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_require_total (c0:va_code) (c1:va_code) (s0:va_state) : prop0 = c0 == c1 /\ state_inv s0
val va_require_total (c0 c1: va_code) (s0: va_state) : prop0 let va_require_total (c0 c1: va_code) (s0: va_state) : prop0 =
false
null
false
c0 == c1 /\ state_inv s0
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_code", "Vale.PPC64LE.Decls.va_state", "Prims.l_and", "Prims.eq2", "Vale.PPC64LE.Decls.state_inv", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h (addr - 16 * offset) b (len + offset) layout tn let validDstAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h (addr - 16 * offset) b (len + offset) layout tn let modifies_buffer_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer128 b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let buffer_modifies_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let modifies_buffer_specific (b:M.buffer64) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer64_read b i h1 == buffer64_read b i h2) unfold let buffers_disjoint (b1 b2:M.buffer64) = locs_disjoint [loc_buffer b1; loc_buffer b2] unfold let buffers_disjoint128 (b1 b2:M.buffer128) = locs_disjoint [loc_buffer b1; loc_buffer b2] let rec loc_locs_disjoint_rec128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec128 l t unfold let buffer_disjoints128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec128]] (loc_locs_disjoint_rec128 l ls) let rec loc_locs_disjoint_rec64_128 (l:M.buffer64) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec64_128 l t unfold let buffer_disjoints64_128 (l:M.buffer64) (ls:list (M.buffer128)) : prop0 = norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec64_128]] (loc_locs_disjoint_rec64_128 l ls) unfold let buffers3_disjoint128 (b1 b2 b3:M.buffer128) = locs_disjoint [loc_buffer b1; loc_buffer b2; loc_buffer b3] val eval_code (c:va_code) (s0:va_state) (f0:va_fuel) (sN:va_state) : prop0 val eval_while_inv (c:va_code) (s0:va_state) (fW:va_fuel) (sW:va_state) : prop0 [@va_qattr] let va_state_eq (s0:va_state) (s1:va_state) : prop0 = state_eq s0 s1 let state_inv (s:state) : prop0 = M.mem_inv (coerce s.ms_heap)
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_require_total (c0 c1: va_code) (s0: va_state) : prop0
[]
Vale.PPC64LE.Decls.va_require_total
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c0: Vale.PPC64LE.Decls.va_code -> c1: Vale.PPC64LE.Decls.va_code -> s0: Vale.PPC64LE.Decls.va_state -> Vale.Def.Prop_s.prop0
{ "end_col": 26, "end_line": 388, "start_col": 2, "start_line": 388 }
Prims.Tot
val va_state_eq (s0 s1: va_state) : prop0
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_state_eq (s0:va_state) (s1:va_state) : prop0 = state_eq s0 s1
val va_state_eq (s0 s1: va_state) : prop0 let va_state_eq (s0 s1: va_state) : prop0 =
false
null
false
state_eq s0 s1
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_state", "Vale.PPC64LE.State.state_eq", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h (addr - 16 * offset) b (len + offset) layout tn let validDstAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h (addr - 16 * offset) b (len + offset) layout tn let modifies_buffer_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer128 b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let buffer_modifies_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let modifies_buffer_specific (b:M.buffer64) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer64_read b i h1 == buffer64_read b i h2) unfold let buffers_disjoint (b1 b2:M.buffer64) = locs_disjoint [loc_buffer b1; loc_buffer b2] unfold let buffers_disjoint128 (b1 b2:M.buffer128) = locs_disjoint [loc_buffer b1; loc_buffer b2] let rec loc_locs_disjoint_rec128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec128 l t unfold let buffer_disjoints128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec128]] (loc_locs_disjoint_rec128 l ls) let rec loc_locs_disjoint_rec64_128 (l:M.buffer64) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec64_128 l t unfold let buffer_disjoints64_128 (l:M.buffer64) (ls:list (M.buffer128)) : prop0 = norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec64_128]] (loc_locs_disjoint_rec64_128 l ls) unfold let buffers3_disjoint128 (b1 b2 b3:M.buffer128) = locs_disjoint [loc_buffer b1; loc_buffer b2; loc_buffer b3] val eval_code (c:va_code) (s0:va_state) (f0:va_fuel) (sN:va_state) : prop0 val eval_while_inv (c:va_code) (s0:va_state) (fW:va_fuel) (sW:va_state) : prop0
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_state_eq (s0 s1: va_state) : prop0
[]
Vale.PPC64LE.Decls.va_state_eq
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s0: Vale.PPC64LE.Decls.va_state -> s1: Vale.PPC64LE.Decls.va_state -> Vale.Def.Prop_s.prop0
{ "end_col": 68, "end_line": 383, "start_col": 54, "start_line": 383 }
Prims.Tot
val va_upd_mem_layout (layout: vale_heap_layout) (s: state) : state
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) }
val va_upd_mem_layout (layout: vale_heap_layout) (s: state) : state let va_upd_mem_layout (layout: vale_heap_layout) (s: state) : state =
false
null
false
{ s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) }
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.Arch.HeapImpl.vale_heap_layout", "Vale.PPC64LE.State.state", "Vale.PPC64LE.Machine_s.Mkstate", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ok", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__regs", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__vecs", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__cr0", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__xer", "Vale.PPC64LE.Decls.coerce", "Vale.Arch.Heap.heap_impl", "Vale.Arch.HeapImpl.vale_full_heap", "Vale.Arch.HeapImpl.Mkvale_full_heap", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_heap", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_stack", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_stackTaint" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_upd_mem_layout (layout: vale_heap_layout) (s: state) : state
[]
Vale.PPC64LE.Decls.va_upd_mem_layout
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
layout: Vale.Arch.HeapImpl.vale_heap_layout -> s: Vale.PPC64LE.State.state -> Vale.PPC64LE.State.state
{ "end_col": 154, "end_line": 178, "start_col": 82, "start_line": 178 }
Prims.Tot
val va_update_mem (sM sK: va_state) : va_state
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK
val va_update_mem (sM sK: va_state) : va_state let va_update_mem (sM sK: va_state) : va_state =
false
null
false
va_upd_mem (coerce sM.ms_heap).vf_heap sK
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_state", "Vale.PPC64LE.Decls.va_upd_mem", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap", "Vale.PPC64LE.Decls.coerce", "Vale.Arch.HeapImpl.vale_full_heap", "Vale.Arch.Heap.heap_impl", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_heap" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state =
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_update_mem (sM sK: va_state) : va_state
[]
Vale.PPC64LE.Decls.va_update_mem
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
sM: Vale.PPC64LE.Decls.va_state -> sK: Vale.PPC64LE.Decls.va_state -> Vale.PPC64LE.Decls.va_state
{ "end_col": 119, "end_line": 190, "start_col": 78, "start_line": 190 }
Prims.Tot
val va_upd_mem (mem: vale_heap) (s: state) : state
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) }
val va_upd_mem (mem: vale_heap) (s: state) : state let va_upd_mem (mem: vale_heap) (s: state) : state =
false
null
false
{ s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) }
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.vale_heap", "Vale.PPC64LE.State.state", "Vale.PPC64LE.Machine_s.Mkstate", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ok", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__regs", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__vecs", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__cr0", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__xer", "Vale.PPC64LE.Decls.coerce", "Vale.Arch.Heap.heap_impl", "Vale.PPC64LE.Memory.vale_full_heap", "Vale.PPC64LE.Memory.set_vale_heap", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_heap", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_stack", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_stackTaint" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_upd_mem (mem: vale_heap) (s: state) : state
[]
Vale.PPC64LE.Decls.va_upd_mem
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
mem: Vale.PPC64LE.Decls.vale_heap -> s: Vale.PPC64LE.State.state -> Vale.PPC64LE.State.state
{ "end_col": 129, "end_line": 177, "start_col": 65, "start_line": 177 }
Prims.Tot
val va_upd_mem_heaplet (n: heaplet_id) (h: vale_heap) (s: state) : state
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) }
val va_upd_mem_heaplet (n: heaplet_id) (h: vale_heap) (s: state) : state let va_upd_mem_heaplet (n: heaplet_id) (h: vale_heap) (s: state) : state =
false
null
false
{ s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) }
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.heaplet_id", "Vale.PPC64LE.Decls.vale_heap", "Vale.PPC64LE.State.state", "Vale.PPC64LE.Machine_s.Mkstate", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ok", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__regs", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__vecs", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__cr0", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__xer", "Vale.PPC64LE.Decls.coerce", "Vale.Arch.Heap.heap_impl", "Vale.Arch.HeapImpl.vale_full_heap", "Vale.Arch.HeapImpl.Mkvale_full_heap", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_layout", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap", "Vale.Lib.Map16.upd", "Vale.Arch.HeapImpl.vale_heap", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_heap", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_stack", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_stackTaint" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) }
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_upd_mem_heaplet (n: heaplet_id) (h: vale_heap) (s: state) : state
[]
Vale.PPC64LE.Decls.va_upd_mem_heaplet
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Vale.PPC64LE.Decls.heaplet_id -> h: Vale.PPC64LE.Decls.vale_heap -> s: Vale.PPC64LE.State.state -> Vale.PPC64LE.State.state
{ "end_col": 116, "end_line": 180, "start_col": 4, "start_line": 180 }
Prims.Tot
val va_update_mem_heaplet (n: heaplet_id) (sM sK: va_state) : va_state
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK
val va_update_mem_heaplet (n: heaplet_id) (sM sK: va_state) : va_state let va_update_mem_heaplet (n: heaplet_id) (sM sK: va_state) : va_state =
false
null
false
va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.heaplet_id", "Vale.PPC64LE.Decls.va_state", "Vale.PPC64LE.Decls.va_upd_mem_heaplet", "Vale.Lib.Map16.sel", "Vale.Arch.HeapImpl.vale_heap", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets", "Vale.PPC64LE.Decls.coerce", "Vale.Arch.HeapImpl.vale_full_heap", "Vale.Arch.Heap.heap_impl", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_heap" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_update_mem_heaplet (n: heaplet_id) (sM sK: va_state) : va_state
[]
Vale.PPC64LE.Decls.va_update_mem_heaplet
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Vale.PPC64LE.Decls.heaplet_id -> sM: Vale.PPC64LE.Decls.va_state -> sK: Vale.PPC64LE.Decls.va_state -> Vale.PPC64LE.Decls.va_state
{ "end_col": 71, "end_line": 193, "start_col": 2, "start_line": 193 }
Prims.Tot
val state_inv (s: state) : prop0
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let state_inv (s:state) : prop0 = M.mem_inv (coerce s.ms_heap)
val state_inv (s: state) : prop0 let state_inv (s: state) : prop0 =
false
null
false
M.mem_inv (coerce s.ms_heap)
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.State.state", "Vale.PPC64LE.Memory.mem_inv", "Vale.PPC64LE.Decls.coerce", "Vale.PPC64LE.Memory.vale_full_heap", "Vale.Arch.Heap.heap_impl", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_heap", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h (addr - 16 * offset) b (len + offset) layout tn let validDstAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h (addr - 16 * offset) b (len + offset) layout tn let modifies_buffer_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer128 b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let buffer_modifies_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let modifies_buffer_specific (b:M.buffer64) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer64_read b i h1 == buffer64_read b i h2) unfold let buffers_disjoint (b1 b2:M.buffer64) = locs_disjoint [loc_buffer b1; loc_buffer b2] unfold let buffers_disjoint128 (b1 b2:M.buffer128) = locs_disjoint [loc_buffer b1; loc_buffer b2] let rec loc_locs_disjoint_rec128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec128 l t unfold let buffer_disjoints128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec128]] (loc_locs_disjoint_rec128 l ls) let rec loc_locs_disjoint_rec64_128 (l:M.buffer64) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec64_128 l t unfold let buffer_disjoints64_128 (l:M.buffer64) (ls:list (M.buffer128)) : prop0 = norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec64_128]] (loc_locs_disjoint_rec64_128 l ls) unfold let buffers3_disjoint128 (b1 b2 b3:M.buffer128) = locs_disjoint [loc_buffer b1; loc_buffer b2; loc_buffer b3] val eval_code (c:va_code) (s0:va_state) (f0:va_fuel) (sN:va_state) : prop0 val eval_while_inv (c:va_code) (s0:va_state) (fW:va_fuel) (sW:va_state) : prop0 [@va_qattr] let va_state_eq (s0:va_state) (s1:va_state) : prop0 = state_eq s0 s1
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val state_inv (s: state) : prop0
[]
Vale.PPC64LE.Decls.state_inv
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.PPC64LE.State.state -> Vale.Def.Prop_s.prop0
{ "end_col": 62, "end_line": 385, "start_col": 34, "start_line": 385 }
Prims.Tot
val loc_locs_disjoint_rec128 (l: M.buffer128) (ls: list (M.buffer128)) : prop0
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec loc_locs_disjoint_rec128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec128 l t
val loc_locs_disjoint_rec128 (l: M.buffer128) (ls: list (M.buffer128)) : prop0 let rec loc_locs_disjoint_rec128 (l: M.buffer128) (ls: list (M.buffer128)) : prop0 =
false
null
false
match ls with | [] -> True | h :: t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec128 l t
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Memory.buffer128", "Prims.list", "Prims.l_True", "Prims.l_and", "Vale.PPC64LE.Decls.locs_disjoint", "Prims.Cons", "Vale.PPC64LE.Memory.loc", "Vale.PPC64LE.Decls.loc_buffer", "Vale.PPC64LE.Memory.vuint128", "Prims.Nil", "Vale.PPC64LE.Decls.loc_locs_disjoint_rec128", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h (addr - 16 * offset) b (len + offset) layout tn let validDstAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h (addr - 16 * offset) b (len + offset) layout tn let modifies_buffer_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer128 b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let buffer_modifies_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let modifies_buffer_specific (b:M.buffer64) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer64_read b i h1 == buffer64_read b i h2) unfold let buffers_disjoint (b1 b2:M.buffer64) = locs_disjoint [loc_buffer b1; loc_buffer b2] unfold let buffers_disjoint128 (b1 b2:M.buffer128) = locs_disjoint [loc_buffer b1; loc_buffer b2]
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val loc_locs_disjoint_rec128 (l: M.buffer128) (ls: list (M.buffer128)) : prop0
[ "recursion" ]
Vale.PPC64LE.Decls.loc_locs_disjoint_rec128
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Vale.PPC64LE.Memory.buffer128 -> ls: Prims.list Vale.PPC64LE.Memory.buffer128 -> Vale.Def.Prop_s.prop0
{ "end_col": 86, "end_line": 361, "start_col": 2, "start_line": 359 }
Prims.Tot
val loc_locs_disjoint_rec64_128 (l: M.buffer64) (ls: list (M.buffer128)) : prop0
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec loc_locs_disjoint_rec64_128 (l:M.buffer64) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec64_128 l t
val loc_locs_disjoint_rec64_128 (l: M.buffer64) (ls: list (M.buffer128)) : prop0 let rec loc_locs_disjoint_rec64_128 (l: M.buffer64) (ls: list (M.buffer128)) : prop0 =
false
null
false
match ls with | [] -> True | h :: t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec64_128 l t
{ "checked_file": "Vale.PPC64LE.Decls.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Memory.buffer64", "Prims.list", "Vale.PPC64LE.Memory.buffer128", "Prims.l_True", "Prims.l_and", "Vale.PPC64LE.Decls.locs_disjoint", "Prims.Cons", "Vale.PPC64LE.Memory.loc", "Vale.PPC64LE.Decls.loc_buffer", "Vale.PPC64LE.Memory.vuint64", "Vale.PPC64LE.Memory.vuint128", "Prims.Nil", "Vale.PPC64LE.Decls.loc_locs_disjoint_rec64_128", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg unfold let va_operand_reg_opr = reg unfold let va_operand_Mem64 = maddr unfold let vec_opr = vec unfold let va_operand_vec_opr = vec unfold let va_operand_heaplet = heaplet_id val va_pbool : Type0 val va_ttrue (_:unit) : va_pbool val va_ffalse (reason:string) : va_pbool val va_pbool_and (x y:va_pbool) : va_pbool val mul_nat_helper (x y:nat) : Lemma (x * y >= 0) [@va_qattr] unfold let va_mul_nat (x y:nat) : nat = mul_nat_helper x y; x * y [@va_qattr] unfold let va_expand_state (s:state) : state = s unfold let buffer_readable (#t:M.base_typ) (h:vale_heap) (b:M.buffer t) : GTot prop0 = M.buffer_readable #t h b unfold let buffer_writeable (#t:M.base_typ) (b:M.buffer t) : GTot prop0 = M.buffer_writeable #t b unfold let buffer_length (#t:M.base_typ) (b:M.buffer t) = M.buffer_length #t b unfold let buffer8_as_seq (m:vale_heap) (b:M.buffer8) : GTot (Seq.seq nat8) = M.buffer_as_seq m b unfold let buffer64_as_seq (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = M.buffer_as_seq m b unfold let s64 (m:vale_heap) (b:M.buffer64) : GTot (Seq.seq nat64) = buffer64_as_seq m b unfold let buffer128_as_seq (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = M.buffer_as_seq m b unfold let s128 (m:vale_heap) (b:M.buffer128) : GTot (Seq.seq quad32) = buffer128_as_seq m b unfold let valid_src_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_read m b i unfold let valid_dst_addr (#t:M.base_typ) (m:vale_heap) (b:M.buffer t) (i:int) : prop0 = M.valid_buffer_write m b i unfold let buffer64_read (b:M.buffer64) (i:int) (h:vale_heap) : GTot nat64 = M.buffer_read b i h unfold let buffer128_read (b:M.buffer128) (i:int) (h:vale_heap) : GTot quad32 = M.buffer_read b i h unfold let modifies_mem (s:M.loc) (h1 h2:vale_heap) : GTot prop0 = M.modifies s h1 h2 unfold let loc_buffer(#t:M.base_typ) (b:M.buffer t) = M.loc_buffer #t b unfold let locs_disjoint = M.locs_disjoint unfold let loc_union = M.loc_union unfold let valid_addr_mem (r:reg) (n:int) (s:state) : prop0 = valid_mem ({ address=r; offset=n }) s let valid_buf_maddr64 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer64) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf64 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 8 * index let valid_buf_maddr128 (addr:int) (s_mem:vale_heap) (layout:vale_heap_layout) (b:M.buffer128) (index:int) (t:taint) : prop0 = valid_src_addr s_mem b index /\ M.valid_taint_buf128 b s_mem layout.vl_taint t /\ addr == M.buffer_addr b s_mem + 16 * index let valid_mem_operand64 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer64) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr64 addr s_mem layout b index t let valid_mem_operand128 (addr:int) (t:taint) (s_mem:vale_heap) (layout:vale_heap_layout) : prop0 = exists (b:M.buffer128) (index:int).{:pattern (M.valid_buffer_read s_mem b index)} valid_buf_maddr128 addr s_mem layout b index t [@va_qattr] let valid_mem_addr (tm:tmaddr) (s:state) : prop0 = let (m, t) = tm in valid_maddr m s /\ valid_mem_operand64 (eval_maddr m s) t (M.get_vale_heap (coerce s.ms_heap)) (coerce s.ms_heap).vf_layout [@va_qattr] let valid_stack (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack64 (eval_maddr m s) t s.ms_stackTaint [@va_qattr] let valid_stack128 (m:maddr) (t:taint) (s:state) : prop0 = SI.valid_taint_stack128 (eval_maddr m s) t s.ms_stackTaint // Constructors val va_fuel_default : unit -> va_fuel [@va_qattr] unfold let va_op_reg_opr_reg (r:reg) : reg_opr = r [@va_qattr] unfold let va_op_vec_opr_vec (v:vec) : vec_opr = v [@va_qattr] unfold let va_op_cmp_reg (r:reg) : cmp_opr = CReg r [@va_qattr] unfold let va_const_cmp (n:imm16) : cmp_opr = CImm n [@va_qattr] unfold let va_op_heaplet_mem_heaplet (h:heaplet_id) : heaplet_id = h [@va_qattr] unfold let va_opr_code_Mem64 (h:heaplet_id) (r:reg) (n:int) (t:taint) : tmaddr = ({ address=r; offset=n }, t) // Getters [@va_qattr] unfold let va_get_ok (s:va_state) : bool = s.ok [@va_qattr] unfold let va_get_cr0 (s:va_state) : cr0_t = s.cr0 [@va_qattr] unfold let va_get_xer (s:va_state) : xer_t = s.xer [@va_qattr] unfold let va_get_reg (r:reg) (s:va_state) : nat64 = eval_reg r s [@va_qattr] unfold let va_get_vec (x:vec) (s:va_state) : quad32 = eval_vec x s [@va_qattr] unfold let va_get_mem (s:va_state) : vale_heap = M.get_vale_heap (coerce s.ms_heap) [@va_qattr] unfold let va_get_mem_layout (s:va_state) : vale_heap_layout = (coerce s.ms_heap).vf_layout [@va_qattr] unfold let va_get_mem_heaplet (n:heaplet_id) (s:va_state) : vale_heap = Map16.sel (coerce s.ms_heap).vf_heaplets n [@va_qattr] unfold let va_get_stack (s:va_state) : SI.vale_stack = VSS.stack_from_s s.ms_stack [@va_qattr] unfold let va_get_stackTaint (s:va_state) : M.memtaint = s.ms_stackTaint // Evaluation [@va_qattr] unfold let va_eval_reg (s:va_state) (r:reg) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_Mem64 (s:va_state) (m:maddr) : GTot nat64 = eval_mem (eval_maddr m s) s [@va_qattr] unfold let va_eval_reg_opr (s:va_state) (r:reg_opr) : GTot nat64 = eval_reg r s [@va_qattr] unfold let va_eval_cmp_opr (s:va_state) (o:cmp_opr) : GTot nat64 = eval_cmp_opr o s [@va_qattr] unfold let va_eval_vec_opr (s:va_state) (v:vec_opr) : GTot quad32 = eval_vec v s [@va_qattr] unfold let va_eval_heaplet (s:va_state) (h:heaplet_id) : vale_heap = va_get_mem_heaplet h s // Predicates [@va_qattr] unfold let va_is_src_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_reg_opr (r:reg_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_dst_Mem64 (m:maddr) (s:va_state) = valid_mem m s [@va_qattr] unfold let va_is_src_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_dst_vec_opr (v:vec_opr) (s:va_state) = True [@va_qattr] unfold let va_is_src_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] unfold let va_is_dst_heaplet (h:heaplet_id) (s:va_state) = True [@va_qattr] let va_upd_ok (ok:bool) (s:state) : state = { s with ok = ok } [@va_qattr] let va_upd_cr0 (cr0:cr0_t) (s:state) : state = { s with cr0 = cr0 } [@va_qattr] let va_upd_xer (xer:xer_t) (s:state) : state = { s with xer = xer } [@va_qattr] let va_upd_reg (r:reg) (v:nat64) (s:state) : state = update_reg r v s [@va_qattr] let va_upd_vec (x:vec) (v:quad32) (s:state) : state = update_vec x v s [@va_qattr] let va_upd_mem (mem:vale_heap) (s:state) : state = { s with ms_heap = coerce (M.set_vale_heap (coerce s.ms_heap) mem) } [@va_qattr] let va_upd_mem_layout (layout:vale_heap_layout) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_layout = layout }) } [@va_qattr] let va_upd_mem_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = { s with ms_heap = coerce ({ (coerce s.ms_heap) with vf_heaplets = Map16.upd (coerce s.ms_heap).vf_heaplets n h }) } [@va_qattr] let va_upd_stack (stack:SI.vale_stack) (s:state) : state = { s with ms_stack = (VSS.stack_to_s stack) } [@va_qattr] let va_upd_stackTaint (stackTaint:M.memtaint) (s:state) : state = { s with ms_stackTaint = stackTaint } // Framing: va_update_foo means the two states are the same except for foo [@va_qattr] unfold let va_update_ok (sM:va_state) (sK:va_state) : va_state = va_upd_ok sM.ok sK [@va_qattr] unfold let va_update_cr0 (sM:va_state) (sK:va_state) : va_state = va_upd_cr0 sM.cr0 sK [@va_qattr] unfold let va_update_xer (sM:va_state) (sK:va_state) : va_state = va_upd_xer sM.xer sK [@va_qattr] unfold let va_update_reg (r:reg) (sM:va_state) (sK:va_state) : va_state = va_upd_reg r (eval_reg r sM) sK [@va_qattr] unfold let va_update_mem (sM:va_state) (sK:va_state) : va_state = va_upd_mem (coerce sM.ms_heap).vf_heap sK [@va_qattr] unfold let va_update_mem_layout (sM:va_state) (sK:va_state) : va_state = va_upd_mem_layout (coerce sM.ms_heap).vf_layout sK [@va_qattr] unfold let va_update_mem_heaplet (n:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_upd_mem_heaplet n (Map16.sel (coerce sM.ms_heap).vf_heaplets n) sK [@va_qattr] unfold let va_update_vec (x:vec) (sM:va_state) (sK:va_state) : va_state = va_upd_vec x (eval_vec x sM) sK [@va_qattr] unfold let va_update_stack (sM:va_state) (sK:va_state) : va_state = va_upd_stack (VSS.stack_from_s sM.ms_stack) sK [@va_qattr] unfold let va_update_stackTaint (sM:va_state) (sK:va_state) : va_state = va_upd_stackTaint sM.ms_stackTaint sK [@va_qattr] unfold let va_update_operand_reg_opr (r:reg) (sM:va_state) (sK:va_state) : va_state = va_update_reg r sM sK [@va_qattr] unfold let va_update_operand_Mem64 (m:maddr) (sM:va_state) (sK:va_state) : va_state = va_update_mem sM sK [@va_qattr] unfold let va_update_operand_vec_opr (x:vec) (sM:va_state) (sK:va_state) : va_state = va_update_vec x sM sK [@va_qattr] unfold let va_update_operand_heaplet (h:heaplet_id) (sM:va_state) (sK:va_state) : va_state = va_update_mem_heaplet h sM sK unfold let va_value_reg_opr = nat64 unfold let va_value_vec_opr = quad32 unfold let va_value_heaplet = vale_heap [@va_qattr] let va_upd_operand_reg_opr (r:reg_opr) (v:nat64) (s:state) : state = va_upd_reg r v s [@va_qattr] let va_upd_operand_vec_opr (x:vec) (v:quad32) (s:state) : state = va_upd_vec x v s [@va_qattr] let va_upd_operand_heaplet (n:heaplet_id) (h:vale_heap) (s:state) : state = va_upd_mem_heaplet n h s let va_lemma_upd_update (sM:state) : Lemma ( (forall (sK:state).{:pattern (va_update_xer sM sK)} va_update_xer sM sK == va_upd_xer sM.xer sK) /\ (forall (sK:state) (h:heaplet_id).{:pattern (va_update_operand_heaplet h sM sK)} va_update_operand_heaplet h sM sK == va_upd_operand_heaplet h (Map16.sel (coerce sM.ms_heap).vf_heaplets h) sK) /\ (forall (sK:state) (r:reg).{:pattern (va_update_operand_reg_opr r sM sK)} va_update_operand_reg_opr r sM sK == va_upd_operand_reg_opr r (eval_reg r sM) sK) /\ (forall (sK:state) (x:vec).{:pattern (va_update_operand_vec_opr x sM sK)} va_update_operand_vec_opr x sM sK == va_upd_operand_vec_opr x (eval_vec x sM) sK) ) = () // Constructors for va_codes [@va_qattr] unfold let va_CNil () : va_codes = [] [@va_qattr] unfold let va_CCons (hd:va_code) (tl:va_codes) : va_codes = hd::tl // Constructors for va_code unfold let va_Block (block:va_codes) : va_code = Block block unfold let va_IfElse (ifCond:ocmp) (ifTrue:va_code) (ifFalse:va_code) : va_code = IfElse ifCond ifTrue ifFalse unfold let va_While (whileCond:ocmp) (whileBody:va_code) : va_code = While whileCond whileBody val va_cmp_eq (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ne (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_le (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_ge (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_lt (o1:cmp_opr) (o2:cmp_opr) : ocmp val va_cmp_gt (o1:cmp_opr) (o2:cmp_opr) : ocmp unfold let va_get_block (c:va_code{Block? c}) : va_codes = Block?.block c unfold let va_get_ifCond (c:va_code{IfElse? c}) : ocmp = IfElse?.ifCond c unfold let va_get_ifTrue (c:va_code{IfElse? c}) : va_code = IfElse?.ifTrue c unfold let va_get_ifFalse (c:va_code{IfElse? c}) : va_code = IfElse?.ifFalse c unfold let va_get_whileCond (c:va_code{While? c}) : ocmp = While?.whileCond c unfold let va_get_whileBody (c:va_code{While? c}) : va_code = While?.whileBody c // Map syntax // syntax for map accesses, m.[key] and m.[key] <- value type map (key:eqtype) (value:Type) = Map.t key value let (.[]) = Map.sel let (.[]<-) = Map.upd (** Memory framing **) (* unfold let in_mem (addr:int) (m:mem) : bool = m `Map.contains` addr let disjoint (ptr1:int) (num_bytes1:int) (ptr2:int) (num_bytes2:int) = ptr1 + num_bytes1 <= ptr2 \/ ptr2 + num_bytes2 <= ptr1 let validSrcAddrs (mem:mem) (addr:int) (size:int) (num_bytes:int) = size == 64 /\ (forall (a:int) . {:pattern (mem `Map.contains` a)} addr <= a && a < addr+num_bytes && (a - addr) % 8 = 0 ==> mem `Map.contains` a) let memModified (old_mem:mem) (new_mem:mem) (ptr:int) (num_bytes) = (forall (a:int) . {:pattern (new_mem `Map.contains` a)} old_mem `Map.contains` a <==> new_mem `Map.contains` a) /\ (forall (a:int) . {:pattern (new_mem.[a]) \/ Map.sel new_mem a} a < ptr || a >= ptr + num_bytes ==> old_mem.[a] == new_mem.[ a]) *) (** Convenient memory-related functions **) let rec buffers_readable (h: vale_heap) (l: list M.buffer64) : GTot prop0 (decreases l) = match l with | [] -> True | b :: l' -> buffer_readable h b /\ buffers_readable h l' unfold let modifies_buffer (b:M.buffer64) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer_2 (b1 b2:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer_3 (b1 b2 b3:M.buffer64) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 unfold let modifies_buffer128 (b:M.buffer128) (h1 h2:vale_heap) = modifies_mem (loc_buffer b) h1 h2 unfold let modifies_buffer128_2 (b1 b2:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 unfold let modifies_buffer128_3 (b1 b2 b3:M.buffer128) (h1 h2:vale_heap) = modifies_mem (M.loc_union (loc_buffer b1) (M.loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 let validSrcAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = buffer_readable h b /\ len <= buffer_length b /\ M.buffer_addr b h == addr /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) false /\ M.valid_taint_buf b h layout.vl_taint tn let validDstAddrs (#t:base_typ) (h:vale_heap) (addr:int) (b:M.buffer t) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn /\ M.valid_layout_buffer_id t b layout (M.get_heaplet_id h) true /\ buffer_writeable b let validSrcAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs64 (h:vale_heap) (addr:int) (b:M.buffer64) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h addr b len layout tn let validDstAddrs128 (h:vale_heap) (addr:int) (b:M.buffer128) (len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h addr b len layout tn let validSrcAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validSrcAddrs h (addr - 16 * offset) b (len + offset) layout tn let validDstAddrsOffset128 (h:vale_heap) (addr:int) (b:M.buffer128) (offset len:int) (layout:vale_heap_layout) (tn:taint) = validDstAddrs h (addr - 16 * offset) b (len + offset) layout tn let modifies_buffer_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer128 b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let buffer_modifies_specific128 (b:M.buffer128) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer128_read b i h1 == buffer128_read b i h2) let modifies_buffer_specific (b:M.buffer64) (h1 h2:vale_heap) (start last:nat) : GTot prop0 = modifies_buffer b h1 h2 /\ // TODO: Consider replacing this with: modifies (loc_buffer (gsub_buffer b i len)) h1 h2 (forall (i:nat) . {:pattern (Seq.index (M.buffer_as_seq h2 b) i)} 0 <= i /\ i < buffer_length b /\ (i < start || i > last) ==> buffer64_read b i h1 == buffer64_read b i h2) unfold let buffers_disjoint (b1 b2:M.buffer64) = locs_disjoint [loc_buffer b1; loc_buffer b2] unfold let buffers_disjoint128 (b1 b2:M.buffer128) = locs_disjoint [loc_buffer b1; loc_buffer b2] let rec loc_locs_disjoint_rec128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = match ls with | [] -> True | h::t -> locs_disjoint [loc_buffer l; loc_buffer h] /\ loc_locs_disjoint_rec128 l t unfold let buffer_disjoints128 (l:M.buffer128) (ls:list (M.buffer128)) : prop0 = norm [zeta; iota; delta_only [`%loc_locs_disjoint_rec128]] (loc_locs_disjoint_rec128 l ls)
false
true
Vale.PPC64LE.Decls.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val loc_locs_disjoint_rec64_128 (l: M.buffer64) (ls: list (M.buffer128)) : prop0
[ "recursion" ]
Vale.PPC64LE.Decls.loc_locs_disjoint_rec64_128
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Vale.PPC64LE.Memory.buffer64 -> ls: Prims.list Vale.PPC64LE.Memory.buffer128 -> Vale.Def.Prop_s.prop0
{ "end_col": 89, "end_line": 370, "start_col": 2, "start_line": 368 }
Prims.Tot
val va_wp_Gctr_blocks128 (alg: algorithm) (in_b out_b: buffer128) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wp_Gctr_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ ((Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) in_b (va_get_reg 6 va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0) out_b (va_get_reg 6 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 6 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16 `op_Multiply` va_get_reg 6 va_s0 < pow2_64 /\ l_and (Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 out_b) (Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b < pow2_32) /\ va_get_reg 6 va_s0 == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b /\ va_get_reg 6 va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0)) /\ (forall (va_x_mem:vale_heap) (va_x_r3:nat64) (va_x_r7:nat64) (va_x_r6:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r26:nat64) (va_x_r27:nat64) (va_x_r28:nat64) (va_x_r29:nat64) (va_x_r30:nat64) (va_x_r31:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) (va_x_v6:quad32) (va_x_v7:quad32) (va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32) (va_x_v12:quad32) (va_x_v13:quad32) (va_x_v14:quad32) (va_x_v15:quad32) (va_x_v16:quad32) (va_x_v17:quad32) (va_x_v18:quad32) (va_x_v19:quad32) (va_x_cr0:cr0_t) (va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_cr0 va_x_cr0 (va_upd_vec 19 va_x_v19 (va_upd_vec 18 va_x_v18 (va_upd_vec 17 va_x_v17 (va_upd_vec 16 va_x_v16 (va_upd_vec 15 va_x_v15 (va_upd_vec 14 va_x_v14 (va_upd_vec 13 va_x_v13 (va_upd_vec 12 va_x_v12 (va_upd_vec 11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 7 va_x_v7 (va_upd_vec 6 va_x_v6 (va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 31 va_x_r31 (va_upd_reg 30 va_x_r30 (va_upd_reg 29 va_x_r29 (va_upd_reg 28 va_x_r28 (va_upd_reg 27 va_x_r27 (va_upd_reg 26 va_x_r26 (va_upd_reg 10 va_x_r10 (va_upd_reg 9 va_x_r9 (va_upd_reg 8 va_x_r8 (va_upd_reg 6 va_x_r6 (va_upd_reg 7 va_x_r7 (va_upd_reg 3 va_x_r3 (va_upd_mem va_x_mem va_s0)))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial alg (va_get_reg 6 va_s0) (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key (va_get_vec 7 va_s0) /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite (va_get_vec 7 va_s0) (va_get_reg 6 va_s0) /\ (va_get_reg 6 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b) /\ l_and (l_and (va_get_reg 3 va_sM == va_get_reg 3 va_s0) (va_get_reg 7 va_sM == va_get_reg 7 va_s0)) (va_get_reg 6 va_sM == va_get_reg 6 va_s0)) ==> va_k va_sM (())))
val va_wp_Gctr_blocks128 (alg: algorithm) (in_b out_b: buffer128) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_Gctr_blocks128 (alg: algorithm) (in_b out_b: buffer128) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_get_ok va_s0 /\ ((Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) in_b (va_get_reg 6 va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0) out_b (va_get_reg 6 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg 3 va_s0 + 16 `op_Multiply` (va_get_reg 6 va_s0) < pow2_64 /\ va_get_reg 7 va_s0 + 16 `op_Multiply` (va_get_reg 6 va_s0) < pow2_64 /\ l_and (Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 out_b) (Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b < pow2_32) /\ va_get_reg 6 va_s0 == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b /\ va_get_reg 6 va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0)) /\ (forall (va_x_mem: vale_heap) (va_x_r3: nat64) (va_x_r7: nat64) (va_x_r6: nat64) (va_x_r8: nat64) (va_x_r9: nat64) (va_x_r10: nat64) (va_x_r26: nat64) (va_x_r27: nat64) (va_x_r28: nat64) (va_x_r29: nat64) (va_x_r30: nat64) (va_x_r31: nat64) (va_x_v0: quad32) (va_x_v1: quad32) (va_x_v2: quad32) (va_x_v3: quad32) (va_x_v4: quad32) (va_x_v5: quad32) (va_x_v6: quad32) (va_x_v7: quad32) (va_x_v8: quad32) (va_x_v9: quad32) (va_x_v10: quad32) (va_x_v11: quad32) (va_x_v12: quad32) (va_x_v13: quad32) (va_x_v14: quad32) (va_x_v15: quad32) (va_x_v16: quad32) (va_x_v17: quad32) (va_x_v18: quad32) (va_x_v19: quad32) (va_x_cr0: cr0_t) (va_x_heap1: vale_heap). let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_cr0 va_x_cr0 (va_upd_vec 19 va_x_v19 (va_upd_vec 18 va_x_v18 (va_upd_vec 17 va_x_v17 (va_upd_vec 16 va_x_v16 (va_upd_vec 15 va_x_v15 (va_upd_vec 14 va_x_v14 (va_upd_vec 13 va_x_v13 (va_upd_vec 12 va_x_v12 (va_upd_vec 11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 7 va_x_v7 (va_upd_vec 6 va_x_v6 (va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 31 va_x_r31 (va_upd_reg 30 va_x_r30 ( va_upd_reg 29 va_x_r29 ( va_upd_reg 28 va_x_r28 ( va_upd_reg 27 va_x_r27 ( va_upd_reg 26 va_x_r26 ( va_upd_reg 10 va_x_r10 ( va_upd_reg 9 va_x_r9 ( va_upd_reg 8 va_x_r8 ( va_upd_reg 6 va_x_r6 ( va_upd_reg 7 va_x_r7 ( va_upd_reg 3 va_x_r3 ( va_upd_mem va_x_mem va_s0 ) ) ) ) ) ) ) ) ) ) ) )) )))))))))) ))))))))))) in va_get_ok va_sM /\ (Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial alg (va_get_reg 6 va_s0) (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key (va_get_vec 7 va_s0) /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite (va_get_vec 7 va_s0) (va_get_reg 6 va_s0) /\ (va_get_reg 6 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b) /\ l_and (l_and (va_get_reg 3 va_sM == va_get_reg 3 va_s0) (va_get_reg 7 va_sM == va_get_reg 7 va_s0)) (va_get_reg 6 va_sM == va_get_reg 6 va_s0)) ==> va_k va_sM (())))
{ "checked_file": "Vale.AES.PPC64LE.GCTR.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsStack.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.PPC64LE.AES.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCTR_BE.fsti.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.GCTR.fsti" }
[ "total" ]
[ "Vale.AES.AES_common_s.algorithm", "Vale.PPC64LE.Memory.buffer128", "FStar.Seq.Base.seq", "Vale.PPC64LE.Memory.nat32", "Vale.PPC64LE.Memory.quad32", "Vale.PPC64LE.Decls.va_state", "Prims.unit", "Prims.l_and", "Prims.b2t", "Vale.PPC64LE.Decls.va_get_ok", "Prims.l_or", "Vale.PPC64LE.Decls.buffers_disjoint128", "Prims.eq2", "Vale.PPC64LE.Decls.validSrcAddrs128", "Vale.PPC64LE.Decls.va_get_mem_heaplet", "Vale.PPC64LE.Decls.va_get_reg", "Vale.PPC64LE.Decls.va_get_mem_layout", "Vale.Arch.HeapTypes_s.Secret", "Vale.PPC64LE.Decls.validDstAddrs128", "Prims.op_LessThan", "Prims.op_Addition", "Prims.op_Multiply", "Vale.PPC64LE.Machine_s.pow2_64", "Prims.nat", "Vale.PPC64LE.Decls.buffer_length", "Vale.PPC64LE.Memory.vuint128", "Vale.PPC64LE.Machine_s.pow2_32", "Vale.AES.PPC64LE.GCTR.aes_reqs", "Prims.l_Forall", "Vale.PPC64LE.InsBasic.vale_heap", "Vale.PPC64LE.Memory.nat64", "Vale.PPC64LE.Machine_s.cr0_t", "Prims.l_imp", "Vale.PPC64LE.Decls.modifies_buffer128", "Vale.AES.GCTR_BE.gctr_partial", "Vale.Arch.Types.reverse_bytes_quad32_seq", "Vale.PPC64LE.Decls.s128", "Vale.PPC64LE.Decls.va_get_vec", "Vale.Def.Types_s.quad32", "Vale.AES.GCTR_BE.inc32lite", "Prims.int", "Vale.PPC64LE.Machine_s.quad32", "Vale.PPC64LE.Machine_s.nat64", "Vale.PPC64LE.Machine_s.state", "Vale.PPC64LE.Decls.va_upd_mem_heaplet", "Vale.PPC64LE.Decls.va_upd_cr0", "Vale.PPC64LE.Decls.va_upd_vec", "Vale.PPC64LE.Decls.va_upd_reg", "Vale.PPC64LE.Decls.va_upd_mem" ]
[]
module Vale.AES.PPC64LE.GCTR open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.PPC64LE.AES open Vale.AES.GCTR_BE_s open Vale.AES.GCTR_BE open Vale.AES.GCM_helpers_BE open Vale.Poly1305.Math open Vale.Def.Words.Two_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.Memory open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.InsStack open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.Types_helpers #reset-options "--z3rlimit 30" let aes_reqs (alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128) (key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0 = (alg = AES_128 \/ alg = AES_256) /\ is_aes_key_word alg key /\ length(round_keys) == nr(alg) + 1 /\ round_keys == key_to_round_keys_word alg key /\ validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\ reverse_bytes_quad32_seq (s128 heap0 keys_b) == round_keys //-- Gctr_register val va_code_Gctr_register : alg:algorithm -> Tot va_code val va_codegen_success_Gctr_register : alg:algorithm -> Tot va_pbool val va_lemma_Gctr_register : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Gctr_register alg) va_s0 /\ va_get_ok va_s0 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE #Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) == Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes (va_get_vec 1 va_s0)) alg key /\ va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1 va_s0) alg key 0) /\ va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))) [@ va_qattr] let va_wp_Gctr_register (alg:algorithm) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ (forall (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) . let va_sM = va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 va_s0))) in va_get_ok va_sM /\ (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE #Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) == Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes (va_get_vec 1 va_s0)) alg key /\ va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1 va_s0) alg key 0) ==> va_k va_sM (()))) val va_wpProof_Gctr_register : alg:algorithm -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Gctr_register alg key round_keys keys_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_register alg) ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Gctr_register (alg:algorithm) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_register alg)) = (va_QProc (va_code_Gctr_register alg) ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) (va_wp_Gctr_register alg key round_keys keys_b) (va_wpProof_Gctr_register alg key round_keys keys_b)) //-- //-- Gctr_blocks128 val va_code_Gctr_blocks128 : alg:algorithm -> Tot va_code val va_codegen_success_Gctr_blocks128 : alg:algorithm -> Tot va_pbool val va_lemma_Gctr_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Gctr_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\ ((Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) in_b (va_get_reg 6 va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0) out_b (va_get_reg 6 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 6 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16 `op_Multiply` va_get_reg 6 va_s0 < pow2_64 /\ l_and (Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 out_b) (Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b < pow2_32) /\ va_get_reg 6 va_s0 == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b /\ va_get_reg 6 va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial alg (va_get_reg 6 va_s0) (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key (va_get_vec 7 va_s0) /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite (va_get_vec 7 va_s0) (va_get_reg 6 va_s0) /\ (va_get_reg 6 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b) /\ l_and (l_and (va_get_reg 3 va_sM == va_get_reg 3 va_s0) (va_get_reg 7 va_sM == va_get_reg 7 va_s0)) (va_get_reg 6 va_sM == va_get_reg 6 va_s0)) /\ va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM (va_update_vec 19 va_sM (va_update_vec 18 va_sM (va_update_vec 17 va_sM (va_update_vec 16 va_sM (va_update_vec 15 va_sM (va_update_vec 14 va_sM (va_update_vec 13 va_sM (va_update_vec 12 va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM (va_update_vec 7 va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 31 va_sM (va_update_reg 30 va_sM (va_update_reg 29 va_sM (va_update_reg 28 va_sM (va_update_reg 27 va_sM (va_update_reg 26 va_sM (va_update_reg 10 va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_reg 6 va_sM (va_update_reg 7 va_sM (va_update_reg 3 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))))))) [@ va_qattr] let va_wp_Gctr_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
false
true
Vale.AES.PPC64LE.GCTR.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wp_Gctr_blocks128 (alg: algorithm) (in_b out_b: buffer128) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.AES.PPC64LE.GCTR.va_wp_Gctr_blocks128
{ "file_name": "obj/Vale.AES.PPC64LE.GCTR.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> in_b: Vale.PPC64LE.Memory.buffer128 -> out_b: Vale.PPC64LE.Memory.buffer128 -> key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 -> round_keys: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 -> keys_b: Vale.PPC64LE.Memory.buffer128 -> va_s0: Vale.PPC64LE.Decls.va_state -> va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 21, "end_line": 167, "start_col": 2, "start_line": 130 }
Prims.Tot
val aes_reqs (alg: algorithm) (key: seq nat32) (round_keys: seq quad32) (keys_b: buffer128) (key_ptr: int) (heap0: vale_heap) (layout: vale_heap_layout) : prop0
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_reqs (alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128) (key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0 = (alg = AES_128 \/ alg = AES_256) /\ is_aes_key_word alg key /\ length(round_keys) == nr(alg) + 1 /\ round_keys == key_to_round_keys_word alg key /\ validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\ reverse_bytes_quad32_seq (s128 heap0 keys_b) == round_keys
val aes_reqs (alg: algorithm) (key: seq nat32) (round_keys: seq quad32) (keys_b: buffer128) (key_ptr: int) (heap0: vale_heap) (layout: vale_heap_layout) : prop0 let aes_reqs (alg: algorithm) (key: seq nat32) (round_keys: seq quad32) (keys_b: buffer128) (key_ptr: int) (heap0: vale_heap) (layout: vale_heap_layout) : prop0 =
false
null
false
(alg = AES_128 \/ alg = AES_256) /\ is_aes_key_word alg key /\ length (round_keys) == nr (alg) + 1 /\ round_keys == key_to_round_keys_word alg key /\ validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\ reverse_bytes_quad32_seq (s128 heap0 keys_b) == round_keys
{ "checked_file": "Vale.AES.PPC64LE.GCTR.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsStack.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.PPC64LE.AES.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCTR_BE.fsti.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.GCTR.fsti" }
[ "total" ]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.PPC64LE.Memory.nat32", "Vale.PPC64LE.Memory.quad32", "Vale.PPC64LE.Memory.buffer128", "Prims.int", "Vale.PPC64LE.InsBasic.vale_heap", "Vale.Arch.HeapImpl.vale_heap_layout", "Prims.l_and", "Prims.l_or", "Prims.b2t", "Prims.op_Equality", "Vale.AES.AES_common_s.AES_128", "Vale.AES.AES_common_s.AES_256", "Vale.AES.AES_BE_s.is_aes_key_word", "Prims.eq2", "FStar.Seq.Base.length", "Prims.op_Addition", "Vale.AES.AES_common_s.nr", "Vale.Def.Types_s.quad32", "Vale.AES.AES_BE_s.key_to_round_keys_word", "Vale.PPC64LE.Decls.validSrcAddrs128", "Vale.Arch.HeapTypes_s.Secret", "Vale.Arch.Types.reverse_bytes_quad32_seq", "Vale.PPC64LE.Decls.s128", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.AES.PPC64LE.GCTR open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.PPC64LE.AES open Vale.AES.GCTR_BE_s open Vale.AES.GCTR_BE open Vale.AES.GCM_helpers_BE open Vale.Poly1305.Math open Vale.Def.Words.Two_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.Memory open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.InsStack open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.Types_helpers #reset-options "--z3rlimit 30" let aes_reqs (alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128) (key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0
false
true
Vale.AES.PPC64LE.GCTR.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_reqs (alg: algorithm) (key: seq nat32) (round_keys: seq quad32) (keys_b: buffer128) (key_ptr: int) (heap0: vale_heap) (layout: vale_heap_layout) : prop0
[]
Vale.AES.PPC64LE.GCTR.aes_reqs
{ "file_name": "obj/Vale.AES.PPC64LE.GCTR.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 -> round_keys: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 -> keys_b: Vale.PPC64LE.Memory.buffer128 -> key_ptr: Prims.int -> heap0: Vale.PPC64LE.InsBasic.vale_heap -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> Vale.Def.Prop_s.prop0
{ "end_col": 60, "end_line": 37, "start_col": 2, "start_line": 32 }
Prims.Tot
val va_quick_Gctr_register (alg: algorithm) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) : (va_quickCode unit (va_code_Gctr_register alg))
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_quick_Gctr_register (alg:algorithm) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_register alg)) = (va_QProc (va_code_Gctr_register alg) ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) (va_wp_Gctr_register alg key round_keys keys_b) (va_wpProof_Gctr_register alg key round_keys keys_b))
val va_quick_Gctr_register (alg: algorithm) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) : (va_quickCode unit (va_code_Gctr_register alg)) let va_quick_Gctr_register (alg: algorithm) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) : (va_quickCode unit (va_code_Gctr_register alg)) =
false
null
false
(va_QProc (va_code_Gctr_register alg) ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) (va_wp_Gctr_register alg key round_keys keys_b) (va_wpProof_Gctr_register alg key round_keys keys_b))
{ "checked_file": "Vale.AES.PPC64LE.GCTR.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsStack.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.PPC64LE.AES.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCTR_BE.fsti.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.GCTR.fsti" }
[ "total" ]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.PPC64LE.Memory.nat32", "Vale.PPC64LE.Memory.quad32", "Vale.PPC64LE.Memory.buffer128", "Vale.PPC64LE.QuickCode.va_QProc", "Prims.unit", "Vale.AES.PPC64LE.GCTR.va_code_Gctr_register", "Prims.Cons", "Vale.PPC64LE.QuickCode.mod_t", "Vale.PPC64LE.QuickCode.va_Mod_vec", "Vale.PPC64LE.QuickCode.va_Mod_reg", "Prims.Nil", "Vale.AES.PPC64LE.GCTR.va_wp_Gctr_register", "Vale.AES.PPC64LE.GCTR.va_wpProof_Gctr_register", "Vale.PPC64LE.QuickCode.va_quickCode" ]
[]
module Vale.AES.PPC64LE.GCTR open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.PPC64LE.AES open Vale.AES.GCTR_BE_s open Vale.AES.GCTR_BE open Vale.AES.GCM_helpers_BE open Vale.Poly1305.Math open Vale.Def.Words.Two_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.Memory open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.InsStack open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.Types_helpers #reset-options "--z3rlimit 30" let aes_reqs (alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128) (key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0 = (alg = AES_128 \/ alg = AES_256) /\ is_aes_key_word alg key /\ length(round_keys) == nr(alg) + 1 /\ round_keys == key_to_round_keys_word alg key /\ validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\ reverse_bytes_quad32_seq (s128 heap0 keys_b) == round_keys //-- Gctr_register val va_code_Gctr_register : alg:algorithm -> Tot va_code val va_codegen_success_Gctr_register : alg:algorithm -> Tot va_pbool val va_lemma_Gctr_register : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Gctr_register alg) va_s0 /\ va_get_ok va_s0 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE #Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) == Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes (va_get_vec 1 va_s0)) alg key /\ va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1 va_s0) alg key 0) /\ va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))) [@ va_qattr] let va_wp_Gctr_register (alg:algorithm) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ (forall (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) . let va_sM = va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 va_s0))) in va_get_ok va_sM /\ (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE #Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) == Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes (va_get_vec 1 va_s0)) alg key /\ va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1 va_s0) alg key 0) ==> va_k va_sM (()))) val va_wpProof_Gctr_register : alg:algorithm -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Gctr_register alg key round_keys keys_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_register alg) ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Gctr_register (alg:algorithm) (key:(seq nat32)) (round_keys:(seq quad32))
false
false
Vale.AES.PPC64LE.GCTR.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_quick_Gctr_register (alg: algorithm) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) : (va_quickCode unit (va_code_Gctr_register alg))
[]
Vale.AES.PPC64LE.GCTR.va_quick_Gctr_register
{ "file_name": "obj/Vale.AES.PPC64LE.GCTR.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 -> round_keys: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 -> keys_b: Vale.PPC64LE.Memory.buffer128 -> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit (Vale.AES.PPC64LE.GCTR.va_code_Gctr_register alg)
{ "end_col": 12, "end_line": 82, "start_col": 2, "start_line": 80 }
Prims.Tot
val va_wp_Gctr_register (alg: algorithm) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wp_Gctr_register (alg:algorithm) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ (forall (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) . let va_sM = va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 va_s0))) in va_get_ok va_sM /\ (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE #Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) == Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes (va_get_vec 1 va_s0)) alg key /\ va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1 va_s0) alg key 0) ==> va_k va_sM (())))
val va_wp_Gctr_register (alg: algorithm) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_Gctr_register (alg: algorithm) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_get_ok va_s0 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ (forall (va_x_r10: nat64) (va_x_v0: quad32) (va_x_v1: quad32) (va_x_v2: quad32). let va_sM = va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 va_s0))) in va_get_ok va_sM /\ (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE #Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) == Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes (va_get_vec 1 va_s0)) alg key /\ va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1 va_s0) alg key 0) ==> va_k va_sM (())))
{ "checked_file": "Vale.AES.PPC64LE.GCTR.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsStack.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.PPC64LE.AES.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCTR_BE.fsti.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.GCTR.fsti" }
[ "total" ]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.PPC64LE.Memory.nat32", "Vale.PPC64LE.Memory.quad32", "Vale.PPC64LE.Memory.buffer128", "Vale.PPC64LE.Decls.va_state", "Prims.unit", "Prims.l_and", "Prims.b2t", "Vale.PPC64LE.Decls.va_get_ok", "Vale.AES.PPC64LE.GCTR.aes_reqs", "Vale.PPC64LE.Decls.va_get_reg", "Vale.PPC64LE.Decls.va_get_mem_heaplet", "Vale.PPC64LE.Decls.va_get_mem_layout", "Prims.l_Forall", "Vale.PPC64LE.Memory.nat64", "Prims.l_imp", "Prims.eq2", "Vale.Def.Words_s.nat8", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "Vale.Def.Words_s.nat32", "FStar.Seq.Base.create", "Vale.PPC64LE.Decls.va_get_vec", "Vale.AES.GCTR_BE_s.gctr_encrypt", "Vale.Arch.Types.be_quad32_to_bytes", "Vale.Def.Types_s.quad32", "Vale.AES.GCTR_BE_s.gctr_encrypt_block", "Vale.PPC64LE.Machine_s.state", "Vale.PPC64LE.Decls.va_upd_vec", "Vale.PPC64LE.Decls.va_upd_reg" ]
[]
module Vale.AES.PPC64LE.GCTR open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.PPC64LE.AES open Vale.AES.GCTR_BE_s open Vale.AES.GCTR_BE open Vale.AES.GCM_helpers_BE open Vale.Poly1305.Math open Vale.Def.Words.Two_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.Memory open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.InsStack open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.Types_helpers #reset-options "--z3rlimit 30" let aes_reqs (alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128) (key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0 = (alg = AES_128 \/ alg = AES_256) /\ is_aes_key_word alg key /\ length(round_keys) == nr(alg) + 1 /\ round_keys == key_to_round_keys_word alg key /\ validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\ reverse_bytes_quad32_seq (s128 heap0 keys_b) == round_keys //-- Gctr_register val va_code_Gctr_register : alg:algorithm -> Tot va_code val va_codegen_success_Gctr_register : alg:algorithm -> Tot va_pbool val va_lemma_Gctr_register : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Gctr_register alg) va_s0 /\ va_get_ok va_s0 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE #Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) == Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes (va_get_vec 1 va_s0)) alg key /\ va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1 va_s0) alg key 0) /\ va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))) [@ va_qattr] let va_wp_Gctr_register (alg:algorithm) (key:(seq nat32)) (round_keys:(seq quad32))
false
true
Vale.AES.PPC64LE.GCTR.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wp_Gctr_register (alg: algorithm) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.AES.PPC64LE.GCTR.va_wp_Gctr_register
{ "file_name": "obj/Vale.AES.PPC64LE.GCTR.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 -> round_keys: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 -> keys_b: Vale.PPC64LE.Memory.buffer128 -> va_s0: Vale.PPC64LE.Decls.va_state -> va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 78, "end_line": 69, "start_col": 2, "start_line": 61 }
Prims.Tot
val va_quick_Gctr_blocks128 (alg: algorithm) (in_b out_b: buffer128) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) : (va_quickCode unit (va_code_Gctr_blocks128 alg))
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_quick_Gctr_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_blocks128 alg)) = (va_QProc (va_code_Gctr_blocks128 alg) ([va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 19; va_Mod_vec 18; va_Mod_vec 17; va_Mod_vec 16; va_Mod_vec 15; va_Mod_vec 14; va_Mod_vec 13; va_Mod_vec 12; va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 31; va_Mod_reg 30; va_Mod_reg 29; va_Mod_reg 28; va_Mod_reg 27; va_Mod_reg 26; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 6; va_Mod_reg 7; va_Mod_reg 3; va_Mod_mem]) (va_wp_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_wpProof_Gctr_blocks128 alg in_b out_b key round_keys keys_b))
val va_quick_Gctr_blocks128 (alg: algorithm) (in_b out_b: buffer128) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) : (va_quickCode unit (va_code_Gctr_blocks128 alg)) let va_quick_Gctr_blocks128 (alg: algorithm) (in_b out_b: buffer128) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) : (va_quickCode unit (va_code_Gctr_blocks128 alg)) =
false
null
false
(va_QProc (va_code_Gctr_blocks128 alg) ([ va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 19; va_Mod_vec 18; va_Mod_vec 17; va_Mod_vec 16; va_Mod_vec 15; va_Mod_vec 14; va_Mod_vec 13; va_Mod_vec 12; va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 31; va_Mod_reg 30; va_Mod_reg 29; va_Mod_reg 28; va_Mod_reg 27; va_Mod_reg 26; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 6; va_Mod_reg 7; va_Mod_reg 3; va_Mod_mem ]) (va_wp_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_wpProof_Gctr_blocks128 alg in_b out_b key round_keys keys_b))
{ "checked_file": "Vale.AES.PPC64LE.GCTR.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsStack.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.PPC64LE.AES.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCTR_BE.fsti.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.GCTR.fsti" }
[ "total" ]
[ "Vale.AES.AES_common_s.algorithm", "Vale.PPC64LE.Memory.buffer128", "FStar.Seq.Base.seq", "Vale.PPC64LE.Memory.nat32", "Vale.PPC64LE.Memory.quad32", "Vale.PPC64LE.QuickCode.va_QProc", "Prims.unit", "Vale.AES.PPC64LE.GCTR.va_code_Gctr_blocks128", "Prims.Cons", "Vale.PPC64LE.QuickCode.mod_t", "Vale.PPC64LE.QuickCode.va_Mod_mem_heaplet", "Vale.PPC64LE.QuickCode.va_Mod_cr0", "Vale.PPC64LE.QuickCode.va_Mod_vec", "Vale.PPC64LE.QuickCode.va_Mod_reg", "Vale.PPC64LE.QuickCode.va_Mod_mem", "Prims.Nil", "Vale.AES.PPC64LE.GCTR.va_wp_Gctr_blocks128", "Vale.AES.PPC64LE.GCTR.va_wpProof_Gctr_blocks128", "Vale.PPC64LE.QuickCode.va_quickCode" ]
[]
module Vale.AES.PPC64LE.GCTR open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.PPC64LE.AES open Vale.AES.GCTR_BE_s open Vale.AES.GCTR_BE open Vale.AES.GCM_helpers_BE open Vale.Poly1305.Math open Vale.Def.Words.Two_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.Memory open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.InsStack open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.Types_helpers #reset-options "--z3rlimit 30" let aes_reqs (alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128) (key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0 = (alg = AES_128 \/ alg = AES_256) /\ is_aes_key_word alg key /\ length(round_keys) == nr(alg) + 1 /\ round_keys == key_to_round_keys_word alg key /\ validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\ reverse_bytes_quad32_seq (s128 heap0 keys_b) == round_keys //-- Gctr_register val va_code_Gctr_register : alg:algorithm -> Tot va_code val va_codegen_success_Gctr_register : alg:algorithm -> Tot va_pbool val va_lemma_Gctr_register : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Gctr_register alg) va_s0 /\ va_get_ok va_s0 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE #Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) == Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes (va_get_vec 1 va_s0)) alg key /\ va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1 va_s0) alg key 0) /\ va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))) [@ va_qattr] let va_wp_Gctr_register (alg:algorithm) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ (forall (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) . let va_sM = va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 va_s0))) in va_get_ok va_sM /\ (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE #Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) == Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes (va_get_vec 1 va_s0)) alg key /\ va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1 va_s0) alg key 0) ==> va_k va_sM (()))) val va_wpProof_Gctr_register : alg:algorithm -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Gctr_register alg key round_keys keys_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_register alg) ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Gctr_register (alg:algorithm) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_register alg)) = (va_QProc (va_code_Gctr_register alg) ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) (va_wp_Gctr_register alg key round_keys keys_b) (va_wpProof_Gctr_register alg key round_keys keys_b)) //-- //-- Gctr_blocks128 val va_code_Gctr_blocks128 : alg:algorithm -> Tot va_code val va_codegen_success_Gctr_blocks128 : alg:algorithm -> Tot va_pbool val va_lemma_Gctr_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Gctr_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\ ((Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) in_b (va_get_reg 6 va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0) out_b (va_get_reg 6 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 6 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16 `op_Multiply` va_get_reg 6 va_s0 < pow2_64 /\ l_and (Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 out_b) (Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b < pow2_32) /\ va_get_reg 6 va_s0 == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b /\ va_get_reg 6 va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial alg (va_get_reg 6 va_s0) (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key (va_get_vec 7 va_s0) /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite (va_get_vec 7 va_s0) (va_get_reg 6 va_s0) /\ (va_get_reg 6 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b) /\ l_and (l_and (va_get_reg 3 va_sM == va_get_reg 3 va_s0) (va_get_reg 7 va_sM == va_get_reg 7 va_s0)) (va_get_reg 6 va_sM == va_get_reg 6 va_s0)) /\ va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM (va_update_vec 19 va_sM (va_update_vec 18 va_sM (va_update_vec 17 va_sM (va_update_vec 16 va_sM (va_update_vec 15 va_sM (va_update_vec 14 va_sM (va_update_vec 13 va_sM (va_update_vec 12 va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM (va_update_vec 7 va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 31 va_sM (va_update_reg 30 va_sM (va_update_reg 29 va_sM (va_update_reg 28 va_sM (va_update_reg 27 va_sM (va_update_reg 26 va_sM (va_update_reg 10 va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_reg 6 va_sM (va_update_reg 7 va_sM (va_update_reg 3 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))))))) [@ va_qattr] let va_wp_Gctr_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ ((Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) in_b (va_get_reg 6 va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0) out_b (va_get_reg 6 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 6 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16 `op_Multiply` va_get_reg 6 va_s0 < pow2_64 /\ l_and (Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 out_b) (Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b < pow2_32) /\ va_get_reg 6 va_s0 == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b /\ va_get_reg 6 va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0)) /\ (forall (va_x_mem:vale_heap) (va_x_r3:nat64) (va_x_r7:nat64) (va_x_r6:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r26:nat64) (va_x_r27:nat64) (va_x_r28:nat64) (va_x_r29:nat64) (va_x_r30:nat64) (va_x_r31:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) (va_x_v6:quad32) (va_x_v7:quad32) (va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32) (va_x_v12:quad32) (va_x_v13:quad32) (va_x_v14:quad32) (va_x_v15:quad32) (va_x_v16:quad32) (va_x_v17:quad32) (va_x_v18:quad32) (va_x_v19:quad32) (va_x_cr0:cr0_t) (va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_cr0 va_x_cr0 (va_upd_vec 19 va_x_v19 (va_upd_vec 18 va_x_v18 (va_upd_vec 17 va_x_v17 (va_upd_vec 16 va_x_v16 (va_upd_vec 15 va_x_v15 (va_upd_vec 14 va_x_v14 (va_upd_vec 13 va_x_v13 (va_upd_vec 12 va_x_v12 (va_upd_vec 11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 7 va_x_v7 (va_upd_vec 6 va_x_v6 (va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 31 va_x_r31 (va_upd_reg 30 va_x_r30 (va_upd_reg 29 va_x_r29 (va_upd_reg 28 va_x_r28 (va_upd_reg 27 va_x_r27 (va_upd_reg 26 va_x_r26 (va_upd_reg 10 va_x_r10 (va_upd_reg 9 va_x_r9 (va_upd_reg 8 va_x_r8 (va_upd_reg 6 va_x_r6 (va_upd_reg 7 va_x_r7 (va_upd_reg 3 va_x_r3 (va_upd_mem va_x_mem va_s0)))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial alg (va_get_reg 6 va_s0) (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key (va_get_vec 7 va_s0) /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite (va_get_vec 7 va_s0) (va_get_reg 6 va_s0) /\ (va_get_reg 6 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b) /\ l_and (l_and (va_get_reg 3 va_sM == va_get_reg 3 va_s0) (va_get_reg 7 va_sM == va_get_reg 7 va_s0)) (va_get_reg 6 va_sM == va_get_reg 6 va_s0)) ==> va_k va_sM (()))) val va_wpProof_Gctr_blocks128 : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Gctr_blocks128 alg in_b out_b key round_keys keys_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128 alg) ([va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 19; va_Mod_vec 18; va_Mod_vec 17; va_Mod_vec 16; va_Mod_vec 15; va_Mod_vec 14; va_Mod_vec 13; va_Mod_vec 12; va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 31; va_Mod_reg 30; va_Mod_reg 29; va_Mod_reg 28; va_Mod_reg 27; va_Mod_reg 26; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 6; va_Mod_reg 7; va_Mod_reg 3; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Gctr_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
false
false
Vale.AES.PPC64LE.GCTR.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_quick_Gctr_blocks128 (alg: algorithm) (in_b out_b: buffer128) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) : (va_quickCode unit (va_code_Gctr_blocks128 alg))
[]
Vale.AES.PPC64LE.GCTR.va_quick_Gctr_blocks128
{ "file_name": "obj/Vale.AES.PPC64LE.GCTR.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> in_b: Vale.PPC64LE.Memory.buffer128 -> out_b: Vale.PPC64LE.Memory.buffer128 -> key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 -> round_keys: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 -> keys_b: Vale.PPC64LE.Memory.buffer128 -> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit (Vale.AES.PPC64LE.GCTR.va_code_Gctr_blocks128 alg)
{ "end_col": 69, "end_line": 192, "start_col": 2, "start_line": 185 }
Prims.Tot
val valid (#t:Type) (p:repr_ptr t) (h:HS.mem) : prop
[ { "abbrev": true, "full_module": "LowStar.ImmutableBuffer", "short_module": "I" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.ConstBuffer", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowParse.SLow.Base", "short_module": "LS" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowStar.ImmutableBuffer", "short_module": "I" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.ConstBuffer", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowParse.SLow.Base", "short_module": "LS" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LP" }, { "abbrev": false, "full_module": "LowParse", "short_module": null }, { "abbrev": false, "full_module": "LowParse", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid (#t:Type) (p:repr_ptr t) (h:HS.mem) = valid' p h
val valid (#t:Type) (p:repr_ptr t) (h:HS.mem) : prop let valid (#t: Type) (p: repr_ptr t) (h: HS.mem) =
false
null
false
valid' p h
{ "checked_file": "LowParse.Repr.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.ImmutableBuffer.fst.checked", "LowStar.ConstBuffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.SLow.Base.fst.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "LowParse.Repr.fst" }
[ "total" ]
[ "LowParse.Repr.repr_ptr", "FStar.Monotonic.HyperStack.mem", "LowParse.Repr.valid'", "Prims.prop" ]
[]
(* Copyright 2015--2019 INRIA and Microsoft Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 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: T. Ramananandro, A. Rastogi, N. Swamy, A. Fromherz *) module LowParse.Repr module LP = LowParse.Low.Base module LS = LowParse.SLow.Base module B = LowStar.Buffer module HS = FStar.HyperStack module C = LowStar.ConstBuffer module U32 = FStar.UInt32 module U64 = FStar.UInt64 open FStar.Integers open FStar.HyperStack.ST module ST = FStar.HyperStack.ST module I = LowStar.ImmutableBuffer
false
false
LowParse.Repr.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid (#t:Type) (p:repr_ptr t) (h:HS.mem) : prop
[]
LowParse.Repr.valid
{ "file_name": "src/lowparse/LowParse.Repr.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: LowParse.Repr.repr_ptr t -> h: FStar.Monotonic.HyperStack.mem -> Prims.prop
{ "end_col": 14, "end_line": 35, "start_col": 4, "start_line": 35 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x))
let to_post (#a: Type) (post: post_t a) =
false
null
false
fun x -> (hp_of (post x))
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "total" ]
[ "Steel.Effect.Common.post_t", "Steel.Effect.Common.hp_of", "Steel.Memory.slprop" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val to_post : post: Steel.Effect.Common.post_t a -> x: a -> Steel.Memory.slprop
[]
Steel.Effect.to_post
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
post: Steel.Effect.Common.post_t a -> x: a -> Steel.Memory.slprop
{ "end_col": 65, "end_line": 61, "start_col": 40, "start_line": 61 }
Prims.Tot
val repr (a:Type) (framed:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) : Type u#2
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens))
val repr (a:Type) (framed:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) : Type u#2 let repr (a: Type) (_: bool) (pre: pre_t) (post: post_t a) (req: req_t pre) (ens: ens_t pre a post) =
false
null
false
Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens))
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "total" ]
[ "Prims.bool", "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.req_t", "Steel.Effect.Common.ens_t", "Steel.Semantics.Hoare.MST.action_t", "Steel.Semantics.Instantiate.state", "Steel.Effect.Common.hp_of", "Steel.Effect.to_post", "Steel.Effect.req_to_act_req", "Steel.Effect.ens_to_act_ens" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val repr (a:Type) (framed:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) : Type u#2
[]
Steel.Effect.repr
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Type -> framed: Prims.bool -> pre: Steel.Effect.Common.pre_t -> post: Steel.Effect.Common.post_t a -> req: Steel.Effect.Common.req_t pre -> ens: Steel.Effect.Common.ens_t pre a post -> Type
{ "end_col": 26, "end_line": 157, "start_col": 2, "start_line": 155 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let frame_opaque frame h0 h1 = frame_equalities frame h0 h1
let frame_opaque frame h0 h1 =
false
null
false
frame_equalities frame h0 h1
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "total" ]
[ "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem", "Steel.Effect.Common.frame_equalities", "Prims.prop" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0"
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val frame_opaque : frame: Steel.Effect.Common.vprop -> h0: Steel.Effect.Common.rmem frame -> h1: Steel.Effect.Common.rmem frame -> Prims.prop
[]
Steel.Effect.frame_opaque
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
frame: Steel.Effect.Common.vprop -> h0: Steel.Effect.Common.rmem frame -> h1: Steel.Effect.Common.rmem frame -> Prims.prop
{ "end_col": 59, "end_line": 197, "start_col": 31, "start_line": 197 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let norm_opaque = norm [delta_only [`%frame_opaque]]
let norm_opaque =
false
null
false
norm [delta_only [`%frame_opaque]]
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_only", "Prims.string", "Prims.Nil" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val norm_opaque : x: _ -> _
[]
Steel.Effect.norm_opaque
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
x: _ -> _
{ "end_col": 52, "end_line": 200, "start_col": 18, "start_line": 200 }
Prims.Tot
val bind_div_steel_ens (#a #b: Type) (wp: pure_wp a) (#pre_g: pre_t) (#post_g: post_t b) (ens_g: (a -> ens_t pre_g b post_g)) : ens_t pre_g b post_g
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bind_div_steel_ens (#a:Type) (#b:Type) (wp:pure_wp a) (#pre_g:pre_t) (#post_g:post_t b) (ens_g:a -> ens_t pre_g b post_g) : ens_t pre_g b post_g = fun h0 r h1 -> wp (fun _ -> True) /\ (exists x. ens_g x h0 r h1)
val bind_div_steel_ens (#a #b: Type) (wp: pure_wp a) (#pre_g: pre_t) (#post_g: post_t b) (ens_g: (a -> ens_t pre_g b post_g)) : ens_t pre_g b post_g let bind_div_steel_ens (#a #b: Type) (wp: pure_wp a) (#pre_g: pre_t) (#post_g: post_t b) (ens_g: (a -> ens_t pre_g b post_g)) : ens_t pre_g b post_g =
false
null
false
fun h0 r h1 -> wp (fun _ -> True) /\ (exists x. ens_g x h0 r h1)
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "total" ]
[ "Prims.pure_wp", "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.ens_t", "Steel.Effect.Common.rmem", "Prims.l_and", "Prims.l_True", "Prims.l_Exists" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f unfold let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) unfold let bind_ens_opaque (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_opaque (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) val bind_opaque (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#pre_f:pre_t) (#post_f:post_t a) (#req_f:req_t pre_f) (#ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#req_g:(x:a -> req_t (pre_g x))) (#ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#frame_f:vprop) (#frame_g:a -> vprop) (#post:post_t b) (# _ : squash (maybe_emp framed_f frame_f)) (# _ : squash (maybe_emp_dep framed_g frame_g)) (#pr:a -> prop) (#p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req_opaque req_f ens_f req_g frame_f frame_g p1) (bind_ens_opaque req_f ens_f ens_g frame_f frame_g post p1 p2) #push-options "--z3rlimit 20" let bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem (pre_f `star` frame_f) (core_mem m0) in let x = frame00 f frame_f frame in let m1 = nmst_get () in let h1 = mk_rmem (post_f x `star` frame_f) (core_mem m1) in let h1' = mk_rmem (pre_g x `star` frame_g x) (core_mem m1) in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); focus_is_restrict_mk_rmem (post_f x `star` frame_f) (pre_g x `star` frame_g x) (core_mem m1); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x) (core_mem m1); assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); can_be_split_3_interp (hp_of (post_f x `star` frame_f)) (hp_of (pre_g x `star` frame_g x)) frame (locks_invariant Set.empty m1) m1; let y = frame00 (g x) (frame_g x) frame in let m2 = nmst_get () in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); let h2' = mk_rmem (post_g x y `star` frame_g x) (core_mem m2) in let h2 = mk_rmem (post y) (core_mem m2) in // assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x) (core_mem m1); focus_is_restrict_mk_rmem (post_g x y `star` frame_g x) (post y) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (frame_g x) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (post_g x y) (core_mem m2); can_be_split_3_interp (hp_of (post_g x y `star` frame_g x)) (hp_of (post y)) frame (locks_invariant Set.empty m2) m2; y #pop-options let bind a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = norm_repr (bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g) unfold let subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : pure_pre = (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) val subcomp_opaque (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True) #push-options "--fuel 1 --ifuel 1 --z3rlimit 20" let subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #_ #p1 #p2 f = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem pre_g (core_mem m0) in can_be_split_trans pre_g (pre_f `star` fr) pre_f; can_be_split_trans pre_g (pre_f `star` fr) fr; can_be_split_3_interp (hp_of pre_g) (hp_of (pre_f `star` fr)) frame (locks_invariant Set.empty m0) m0; focus_replace pre_g (pre_f `star` fr) pre_f (core_mem m0); let x = frame00 f fr frame in let m1 = nmst_get () in let h1 = mk_rmem (post_g x) (core_mem m1) in let h0' = mk_rmem (pre_f `star` fr) (core_mem m0) in let h1' = mk_rmem (post_f x `star` fr) (core_mem m1) in // From frame00 assert (frame_opaque fr (focus_rmem h0' fr) (focus_rmem h1' fr)); // Replace h0'/h1' by h0/h1 focus_replace pre_g (pre_f `star` fr) fr (core_mem m0); focus_replace (post_g x) (post_f x `star` fr) fr (core_mem m1); assert (frame_opaque fr (focus_rmem h0 fr) (focus_rmem h1 fr)); can_be_split_trans (post_g x) (post_f x `star` fr) (post_f x); can_be_split_trans (post_g x) (post_f x `star` fr) fr; can_be_split_3_interp (hp_of (post_f x `star` fr)) (hp_of (post_g x)) frame (locks_invariant Set.empty m1) m1; focus_replace (post_g x) (post_f x `star` fr) (post_f x) (core_mem m1); x #pop-options let lemma_rewrite (p:Type) : Lemma (requires T.rewrite_with_tactic vc_norm p) (ensures p) = T.unfold_rewrite_with_tactic vc_norm p let lemma_norm_opaque (p:Type) : Lemma (requires norm_opaque p) (ensures p) = () (** Need to manually remove the rewrite_with_tactic marker here *) let lemma_subcomp_pre_opaque_aux1 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) = lemma_rewrite (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) #push-options "--no_tactics" let lemma_subcomp_pre_opaque_aux2 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_norm_opaque (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) let lemma_subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr : prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_subcomp_pre_opaque_aux1 req_f ens_f req_g ens_g p1 p2; lemma_subcomp_pre_opaque_aux2 req_f ens_f req_g ens_g p1 p2 #pop-options let subcomp a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #pr #p1 #p2 f = lemma_subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2; subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #pr #_ #p1 #p2 f let bind_pure_steel_ a b #wp #pre #post #req #ens f g = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun frame -> let x = f () in g x frame (* We need a bind with DIV to implement par, using reification *) unfold let bind_div_steel_req (#a:Type) (wp:pure_wp a) (#pre_g:pre_t) (req_g:a -> req_t pre_g) : req_t pre_g = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun h -> wp (fun _ -> True) /\ (forall x. (req_g x) h) unfold let bind_div_steel_ens (#a:Type) (#b:Type) (wp:pure_wp a) (#pre_g:pre_t) (#post_g:post_t b) (ens_g:a -> ens_t pre_g b post_g)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bind_div_steel_ens (#a #b: Type) (wp: pure_wp a) (#pre_g: pre_t) (#post_g: post_t b) (ens_g: (a -> ens_t pre_g b post_g)) : ens_t pre_g b post_g
[]
Steel.Effect.bind_div_steel_ens
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
wp: Prims.pure_wp a -> ens_g: (_: a -> Steel.Effect.Common.ens_t pre_g b post_g) -> Steel.Effect.Common.ens_t pre_g b post_g
{ "end_col": 66, "end_line": 651, "start_col": 2, "start_line": 651 }
Prims.Tot
val bind_div_steel_req (#a: Type) (wp: pure_wp a) (#pre_g: pre_t) (req_g: (a -> req_t pre_g)) : req_t pre_g
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bind_div_steel_req (#a:Type) (wp:pure_wp a) (#pre_g:pre_t) (req_g:a -> req_t pre_g) : req_t pre_g = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun h -> wp (fun _ -> True) /\ (forall x. (req_g x) h)
val bind_div_steel_req (#a: Type) (wp: pure_wp a) (#pre_g: pre_t) (req_g: (a -> req_t pre_g)) : req_t pre_g let bind_div_steel_req (#a: Type) (wp: pure_wp a) (#pre_g: pre_t) (req_g: (a -> req_t pre_g)) : req_t pre_g =
false
null
false
FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun h -> wp (fun _ -> True) /\ (forall x. (req_g x) h)
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "total" ]
[ "Prims.pure_wp", "Steel.Effect.Common.pre_t", "Steel.Effect.Common.req_t", "Steel.Effect.Common.rmem", "Prims.l_and", "Prims.l_True", "Prims.l_Forall", "Prims.unit", "FStar.Monotonic.Pure.elim_pure_wp_monotonicity" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f unfold let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) unfold let bind_ens_opaque (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_opaque (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) val bind_opaque (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#pre_f:pre_t) (#post_f:post_t a) (#req_f:req_t pre_f) (#ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#req_g:(x:a -> req_t (pre_g x))) (#ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#frame_f:vprop) (#frame_g:a -> vprop) (#post:post_t b) (# _ : squash (maybe_emp framed_f frame_f)) (# _ : squash (maybe_emp_dep framed_g frame_g)) (#pr:a -> prop) (#p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req_opaque req_f ens_f req_g frame_f frame_g p1) (bind_ens_opaque req_f ens_f ens_g frame_f frame_g post p1 p2) #push-options "--z3rlimit 20" let bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem (pre_f `star` frame_f) (core_mem m0) in let x = frame00 f frame_f frame in let m1 = nmst_get () in let h1 = mk_rmem (post_f x `star` frame_f) (core_mem m1) in let h1' = mk_rmem (pre_g x `star` frame_g x) (core_mem m1) in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); focus_is_restrict_mk_rmem (post_f x `star` frame_f) (pre_g x `star` frame_g x) (core_mem m1); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x) (core_mem m1); assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); can_be_split_3_interp (hp_of (post_f x `star` frame_f)) (hp_of (pre_g x `star` frame_g x)) frame (locks_invariant Set.empty m1) m1; let y = frame00 (g x) (frame_g x) frame in let m2 = nmst_get () in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); let h2' = mk_rmem (post_g x y `star` frame_g x) (core_mem m2) in let h2 = mk_rmem (post y) (core_mem m2) in // assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x) (core_mem m1); focus_is_restrict_mk_rmem (post_g x y `star` frame_g x) (post y) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (frame_g x) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (post_g x y) (core_mem m2); can_be_split_3_interp (hp_of (post_g x y `star` frame_g x)) (hp_of (post y)) frame (locks_invariant Set.empty m2) m2; y #pop-options let bind a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = norm_repr (bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g) unfold let subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : pure_pre = (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) val subcomp_opaque (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True) #push-options "--fuel 1 --ifuel 1 --z3rlimit 20" let subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #_ #p1 #p2 f = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem pre_g (core_mem m0) in can_be_split_trans pre_g (pre_f `star` fr) pre_f; can_be_split_trans pre_g (pre_f `star` fr) fr; can_be_split_3_interp (hp_of pre_g) (hp_of (pre_f `star` fr)) frame (locks_invariant Set.empty m0) m0; focus_replace pre_g (pre_f `star` fr) pre_f (core_mem m0); let x = frame00 f fr frame in let m1 = nmst_get () in let h1 = mk_rmem (post_g x) (core_mem m1) in let h0' = mk_rmem (pre_f `star` fr) (core_mem m0) in let h1' = mk_rmem (post_f x `star` fr) (core_mem m1) in // From frame00 assert (frame_opaque fr (focus_rmem h0' fr) (focus_rmem h1' fr)); // Replace h0'/h1' by h0/h1 focus_replace pre_g (pre_f `star` fr) fr (core_mem m0); focus_replace (post_g x) (post_f x `star` fr) fr (core_mem m1); assert (frame_opaque fr (focus_rmem h0 fr) (focus_rmem h1 fr)); can_be_split_trans (post_g x) (post_f x `star` fr) (post_f x); can_be_split_trans (post_g x) (post_f x `star` fr) fr; can_be_split_3_interp (hp_of (post_f x `star` fr)) (hp_of (post_g x)) frame (locks_invariant Set.empty m1) m1; focus_replace (post_g x) (post_f x `star` fr) (post_f x) (core_mem m1); x #pop-options let lemma_rewrite (p:Type) : Lemma (requires T.rewrite_with_tactic vc_norm p) (ensures p) = T.unfold_rewrite_with_tactic vc_norm p let lemma_norm_opaque (p:Type) : Lemma (requires norm_opaque p) (ensures p) = () (** Need to manually remove the rewrite_with_tactic marker here *) let lemma_subcomp_pre_opaque_aux1 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) = lemma_rewrite (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) #push-options "--no_tactics" let lemma_subcomp_pre_opaque_aux2 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_norm_opaque (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) let lemma_subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr : prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_subcomp_pre_opaque_aux1 req_f ens_f req_g ens_g p1 p2; lemma_subcomp_pre_opaque_aux2 req_f ens_f req_g ens_g p1 p2 #pop-options let subcomp a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #pr #p1 #p2 f = lemma_subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2; subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #pr #_ #p1 #p2 f let bind_pure_steel_ a b #wp #pre #post #req #ens f g = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun frame -> let x = f () in g x frame (* We need a bind with DIV to implement par, using reification *) unfold let bind_div_steel_req (#a:Type) (wp:pure_wp a) (#pre_g:pre_t) (req_g:a -> req_t pre_g)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bind_div_steel_req (#a: Type) (wp: pure_wp a) (#pre_g: pre_t) (req_g: (a -> req_t pre_g)) : req_t pre_g
[]
Steel.Effect.bind_div_steel_req
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
wp: Prims.pure_wp a -> req_g: (_: a -> Steel.Effect.Common.req_t pre_g) -> Steel.Effect.Common.req_t pre_g
{ "end_col": 56, "end_line": 644, "start_col": 2, "start_line": 643 }
Steel.Effect.SteelT
val as_action (#a:Type) (#p:slprop) (#q:a -> slprop) (f:action_except a Set.empty p q) : SteelT a (to_vprop p) (fun x -> to_vprop (q x))
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let as_action #a #p #q f = Steel?.reflect (action_as_repr f)
val as_action (#a:Type) (#p:slprop) (#q:a -> slprop) (f:action_except a Set.empty p q) : SteelT a (to_vprop p) (fun x -> to_vprop (q x)) let as_action #a #p #q f =
true
null
false
Steel?.reflect (action_as_repr f)
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[]
[ "Steel.Memory.slprop", "Steel.Memory.action_except", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Effect.action_as_repr", "Steel.Effect.Common.to_vprop", "Steel.Effect.Common.vprop" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f unfold let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) unfold let bind_ens_opaque (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_opaque (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) val bind_opaque (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#pre_f:pre_t) (#post_f:post_t a) (#req_f:req_t pre_f) (#ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#req_g:(x:a -> req_t (pre_g x))) (#ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#frame_f:vprop) (#frame_g:a -> vprop) (#post:post_t b) (# _ : squash (maybe_emp framed_f frame_f)) (# _ : squash (maybe_emp_dep framed_g frame_g)) (#pr:a -> prop) (#p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req_opaque req_f ens_f req_g frame_f frame_g p1) (bind_ens_opaque req_f ens_f ens_g frame_f frame_g post p1 p2) #push-options "--z3rlimit 20" let bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem (pre_f `star` frame_f) (core_mem m0) in let x = frame00 f frame_f frame in let m1 = nmst_get () in let h1 = mk_rmem (post_f x `star` frame_f) (core_mem m1) in let h1' = mk_rmem (pre_g x `star` frame_g x) (core_mem m1) in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); focus_is_restrict_mk_rmem (post_f x `star` frame_f) (pre_g x `star` frame_g x) (core_mem m1); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x) (core_mem m1); assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); can_be_split_3_interp (hp_of (post_f x `star` frame_f)) (hp_of (pre_g x `star` frame_g x)) frame (locks_invariant Set.empty m1) m1; let y = frame00 (g x) (frame_g x) frame in let m2 = nmst_get () in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); let h2' = mk_rmem (post_g x y `star` frame_g x) (core_mem m2) in let h2 = mk_rmem (post y) (core_mem m2) in // assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x) (core_mem m1); focus_is_restrict_mk_rmem (post_g x y `star` frame_g x) (post y) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (frame_g x) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (post_g x y) (core_mem m2); can_be_split_3_interp (hp_of (post_g x y `star` frame_g x)) (hp_of (post y)) frame (locks_invariant Set.empty m2) m2; y #pop-options let bind a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = norm_repr (bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g) unfold let subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : pure_pre = (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) val subcomp_opaque (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True) #push-options "--fuel 1 --ifuel 1 --z3rlimit 20" let subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #_ #p1 #p2 f = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem pre_g (core_mem m0) in can_be_split_trans pre_g (pre_f `star` fr) pre_f; can_be_split_trans pre_g (pre_f `star` fr) fr; can_be_split_3_interp (hp_of pre_g) (hp_of (pre_f `star` fr)) frame (locks_invariant Set.empty m0) m0; focus_replace pre_g (pre_f `star` fr) pre_f (core_mem m0); let x = frame00 f fr frame in let m1 = nmst_get () in let h1 = mk_rmem (post_g x) (core_mem m1) in let h0' = mk_rmem (pre_f `star` fr) (core_mem m0) in let h1' = mk_rmem (post_f x `star` fr) (core_mem m1) in // From frame00 assert (frame_opaque fr (focus_rmem h0' fr) (focus_rmem h1' fr)); // Replace h0'/h1' by h0/h1 focus_replace pre_g (pre_f `star` fr) fr (core_mem m0); focus_replace (post_g x) (post_f x `star` fr) fr (core_mem m1); assert (frame_opaque fr (focus_rmem h0 fr) (focus_rmem h1 fr)); can_be_split_trans (post_g x) (post_f x `star` fr) (post_f x); can_be_split_trans (post_g x) (post_f x `star` fr) fr; can_be_split_3_interp (hp_of (post_f x `star` fr)) (hp_of (post_g x)) frame (locks_invariant Set.empty m1) m1; focus_replace (post_g x) (post_f x `star` fr) (post_f x) (core_mem m1); x #pop-options let lemma_rewrite (p:Type) : Lemma (requires T.rewrite_with_tactic vc_norm p) (ensures p) = T.unfold_rewrite_with_tactic vc_norm p let lemma_norm_opaque (p:Type) : Lemma (requires norm_opaque p) (ensures p) = () (** Need to manually remove the rewrite_with_tactic marker here *) let lemma_subcomp_pre_opaque_aux1 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) = lemma_rewrite (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) #push-options "--no_tactics" let lemma_subcomp_pre_opaque_aux2 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_norm_opaque (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) let lemma_subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr : prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_subcomp_pre_opaque_aux1 req_f ens_f req_g ens_g p1 p2; lemma_subcomp_pre_opaque_aux2 req_f ens_f req_g ens_g p1 p2 #pop-options let subcomp a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #pr #p1 #p2 f = lemma_subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2; subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #pr #_ #p1 #p2 f let bind_pure_steel_ a b #wp #pre #post #req #ens f g = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun frame -> let x = f () in g x frame (* We need a bind with DIV to implement par, using reification *) unfold let bind_div_steel_req (#a:Type) (wp:pure_wp a) (#pre_g:pre_t) (req_g:a -> req_t pre_g) : req_t pre_g = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun h -> wp (fun _ -> True) /\ (forall x. (req_g x) h) unfold let bind_div_steel_ens (#a:Type) (#b:Type) (wp:pure_wp a) (#pre_g:pre_t) (#post_g:post_t b) (ens_g:a -> ens_t pre_g b post_g) : ens_t pre_g b post_g = fun h0 r h1 -> wp (fun _ -> True) /\ (exists x. ens_g x h0 r h1) #push-options "--z3rlimit 20 --fuel 2 --ifuel 1" let bind_div_steel (a:Type) (b:Type) (wp:pure_wp a) (framed:eqtype_as_type bool) (pre_g:pre_t) (post_g:post_t b) (req_g:a -> req_t pre_g) (ens_g:a -> ens_t pre_g b post_g) (f:eqtype_as_type unit -> DIV a wp) (g:(x:a -> repr b framed pre_g post_g (req_g x) (ens_g x))) : repr b framed pre_g post_g (bind_div_steel_req wp req_g) (bind_div_steel_ens wp ens_g) = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun frame -> let x = f () in g x frame #pop-options polymonadic_bind (DIV, SteelBase) |> SteelBase = bind_div_steel #pop-options let par0 (#aL:Type u#a) (#preL:vprop) (#postL:aL -> vprop) (f:repr aL false preL postL (fun _ -> True) (fun _ _ _ -> True)) (#aR:Type u#a) (#preR:vprop) (#postR:aR -> vprop) (g:repr aR false preR postR (fun _ -> True) (fun _ _ _ -> True)) : SteelT (aL & aR) (preL `star` preR) (fun y -> postL (fst y) `star` postR (snd y)) = Steel?.reflect (fun frame -> Sem.run #state #_ #_ #_ #_ #_ frame (Sem.Par (Sem.Act f) (Sem.Act g))) (* * AR: Steel is not marked reifiable since we intend to run Steel programs natively * However to implement the par combinator we need to reify a Steel thunk to its repr * We could implement it better by having support for reification only in the .fst file * But for now assuming a (Dv) function *) assume val reify_steel_comp (#a:Type) (#framed:bool) (#pre:vprop) (#post:a -> vprop) (#req:req_t pre) (#ens:ens_t pre a post) ($f:unit -> SteelBase a framed pre post req ens) : Dv (repr a framed pre post req ens) let par f g = par0 (reify_steel_comp f) (reify_steel_comp g) let action_as_repr (#a:Type) (#p:slprop) (#q:a -> slprop) (f:action_except a Set.empty p q) : repr a false (to_vprop p) (fun x -> to_vprop (q x)) (fun _ -> True) (fun _ _ _ -> True) = Steel.Semantics.Instantiate.state_correspondence Set.empty; f
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val as_action (#a:Type) (#p:slprop) (#q:a -> slprop) (f:action_except a Set.empty p q) : SteelT a (to_vprop p) (fun x -> to_vprop (q x))
[]
Steel.Effect.as_action
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
f: Steel.Memory.action_except a (FStar.Ghost.hide FStar.Set.empty) p q -> Steel.Effect.SteelT a
{ "end_col": 60, "end_line": 698, "start_col": 27, "start_line": 698 }
Steel.Effect.SteelT
val par (#aL:Type u#a) (#aR:Type u#a) (#preL:vprop) (#postL:aL -> vprop) // (#lpreL:req_t preL) // (#lpostL:ens_t preL aL postL) ($f:unit -> SteelT aL preL postL) // lpreL lpostL) (#preR:vprop) (#postR:aR -> vprop) // (#lpreR:req_t preR) // (#lpostR:ens_t preR aR postR) ($g:unit -> SteelT aR preR postR) // lpreR lpostR) : SteelT (aL & aR) (preL `star` preR) (fun y -> postL (fst y) `star` postR (snd y))
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let par f g = par0 (reify_steel_comp f) (reify_steel_comp g)
val par (#aL:Type u#a) (#aR:Type u#a) (#preL:vprop) (#postL:aL -> vprop) // (#lpreL:req_t preL) // (#lpostL:ens_t preL aL postL) ($f:unit -> SteelT aL preL postL) // lpreL lpostL) (#preR:vprop) (#postR:aR -> vprop) // (#lpreR:req_t preR) // (#lpostR:ens_t preR aR postR) ($g:unit -> SteelT aR preR postR) // lpreR lpostR) : SteelT (aL & aR) (preL `star` preR) (fun y -> postL (fst y) `star` postR (snd y)) let par f g =
true
null
false
par0 (reify_steel_comp f) (reify_steel_comp g)
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[]
[ "Steel.Effect.Common.vprop", "Prims.unit", "Steel.Effect.par0", "FStar.Pervasives.Native.tuple2", "Steel.Effect.repr", "Steel.Effect.Common.rmem'", "Steel.Effect.Common.valid_rmem", "Prims.l_True", "Steel.Effect.reify_steel_comp", "Steel.Effect.Common.rmem" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f unfold let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) unfold let bind_ens_opaque (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_opaque (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) val bind_opaque (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#pre_f:pre_t) (#post_f:post_t a) (#req_f:req_t pre_f) (#ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#req_g:(x:a -> req_t (pre_g x))) (#ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#frame_f:vprop) (#frame_g:a -> vprop) (#post:post_t b) (# _ : squash (maybe_emp framed_f frame_f)) (# _ : squash (maybe_emp_dep framed_g frame_g)) (#pr:a -> prop) (#p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req_opaque req_f ens_f req_g frame_f frame_g p1) (bind_ens_opaque req_f ens_f ens_g frame_f frame_g post p1 p2) #push-options "--z3rlimit 20" let bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem (pre_f `star` frame_f) (core_mem m0) in let x = frame00 f frame_f frame in let m1 = nmst_get () in let h1 = mk_rmem (post_f x `star` frame_f) (core_mem m1) in let h1' = mk_rmem (pre_g x `star` frame_g x) (core_mem m1) in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); focus_is_restrict_mk_rmem (post_f x `star` frame_f) (pre_g x `star` frame_g x) (core_mem m1); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x) (core_mem m1); assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); can_be_split_3_interp (hp_of (post_f x `star` frame_f)) (hp_of (pre_g x `star` frame_g x)) frame (locks_invariant Set.empty m1) m1; let y = frame00 (g x) (frame_g x) frame in let m2 = nmst_get () in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); let h2' = mk_rmem (post_g x y `star` frame_g x) (core_mem m2) in let h2 = mk_rmem (post y) (core_mem m2) in // assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x) (core_mem m1); focus_is_restrict_mk_rmem (post_g x y `star` frame_g x) (post y) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (frame_g x) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (post_g x y) (core_mem m2); can_be_split_3_interp (hp_of (post_g x y `star` frame_g x)) (hp_of (post y)) frame (locks_invariant Set.empty m2) m2; y #pop-options let bind a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = norm_repr (bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g) unfold let subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : pure_pre = (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) val subcomp_opaque (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True) #push-options "--fuel 1 --ifuel 1 --z3rlimit 20" let subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #_ #p1 #p2 f = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem pre_g (core_mem m0) in can_be_split_trans pre_g (pre_f `star` fr) pre_f; can_be_split_trans pre_g (pre_f `star` fr) fr; can_be_split_3_interp (hp_of pre_g) (hp_of (pre_f `star` fr)) frame (locks_invariant Set.empty m0) m0; focus_replace pre_g (pre_f `star` fr) pre_f (core_mem m0); let x = frame00 f fr frame in let m1 = nmst_get () in let h1 = mk_rmem (post_g x) (core_mem m1) in let h0' = mk_rmem (pre_f `star` fr) (core_mem m0) in let h1' = mk_rmem (post_f x `star` fr) (core_mem m1) in // From frame00 assert (frame_opaque fr (focus_rmem h0' fr) (focus_rmem h1' fr)); // Replace h0'/h1' by h0/h1 focus_replace pre_g (pre_f `star` fr) fr (core_mem m0); focus_replace (post_g x) (post_f x `star` fr) fr (core_mem m1); assert (frame_opaque fr (focus_rmem h0 fr) (focus_rmem h1 fr)); can_be_split_trans (post_g x) (post_f x `star` fr) (post_f x); can_be_split_trans (post_g x) (post_f x `star` fr) fr; can_be_split_3_interp (hp_of (post_f x `star` fr)) (hp_of (post_g x)) frame (locks_invariant Set.empty m1) m1; focus_replace (post_g x) (post_f x `star` fr) (post_f x) (core_mem m1); x #pop-options let lemma_rewrite (p:Type) : Lemma (requires T.rewrite_with_tactic vc_norm p) (ensures p) = T.unfold_rewrite_with_tactic vc_norm p let lemma_norm_opaque (p:Type) : Lemma (requires norm_opaque p) (ensures p) = () (** Need to manually remove the rewrite_with_tactic marker here *) let lemma_subcomp_pre_opaque_aux1 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) = lemma_rewrite (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) #push-options "--no_tactics" let lemma_subcomp_pre_opaque_aux2 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_norm_opaque (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) let lemma_subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr : prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_subcomp_pre_opaque_aux1 req_f ens_f req_g ens_g p1 p2; lemma_subcomp_pre_opaque_aux2 req_f ens_f req_g ens_g p1 p2 #pop-options let subcomp a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #pr #p1 #p2 f = lemma_subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2; subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #pr #_ #p1 #p2 f let bind_pure_steel_ a b #wp #pre #post #req #ens f g = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun frame -> let x = f () in g x frame (* We need a bind with DIV to implement par, using reification *) unfold let bind_div_steel_req (#a:Type) (wp:pure_wp a) (#pre_g:pre_t) (req_g:a -> req_t pre_g) : req_t pre_g = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun h -> wp (fun _ -> True) /\ (forall x. (req_g x) h) unfold let bind_div_steel_ens (#a:Type) (#b:Type) (wp:pure_wp a) (#pre_g:pre_t) (#post_g:post_t b) (ens_g:a -> ens_t pre_g b post_g) : ens_t pre_g b post_g = fun h0 r h1 -> wp (fun _ -> True) /\ (exists x. ens_g x h0 r h1) #push-options "--z3rlimit 20 --fuel 2 --ifuel 1" let bind_div_steel (a:Type) (b:Type) (wp:pure_wp a) (framed:eqtype_as_type bool) (pre_g:pre_t) (post_g:post_t b) (req_g:a -> req_t pre_g) (ens_g:a -> ens_t pre_g b post_g) (f:eqtype_as_type unit -> DIV a wp) (g:(x:a -> repr b framed pre_g post_g (req_g x) (ens_g x))) : repr b framed pre_g post_g (bind_div_steel_req wp req_g) (bind_div_steel_ens wp ens_g) = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun frame -> let x = f () in g x frame #pop-options polymonadic_bind (DIV, SteelBase) |> SteelBase = bind_div_steel #pop-options let par0 (#aL:Type u#a) (#preL:vprop) (#postL:aL -> vprop) (f:repr aL false preL postL (fun _ -> True) (fun _ _ _ -> True)) (#aR:Type u#a) (#preR:vprop) (#postR:aR -> vprop) (g:repr aR false preR postR (fun _ -> True) (fun _ _ _ -> True)) : SteelT (aL & aR) (preL `star` preR) (fun y -> postL (fst y) `star` postR (snd y)) = Steel?.reflect (fun frame -> Sem.run #state #_ #_ #_ #_ #_ frame (Sem.Par (Sem.Act f) (Sem.Act g))) (* * AR: Steel is not marked reifiable since we intend to run Steel programs natively * However to implement the par combinator we need to reify a Steel thunk to its repr * We could implement it better by having support for reification only in the .fst file * But for now assuming a (Dv) function *) assume val reify_steel_comp (#a:Type) (#framed:bool) (#pre:vprop) (#post:a -> vprop) (#req:req_t pre) (#ens:ens_t pre a post) ($f:unit -> SteelBase a framed pre post req ens) : Dv (repr a framed pre post req ens)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val par (#aL:Type u#a) (#aR:Type u#a) (#preL:vprop) (#postL:aL -> vprop) // (#lpreL:req_t preL) // (#lpostL:ens_t preL aL postL) ($f:unit -> SteelT aL preL postL) // lpreL lpostL) (#preR:vprop) (#postR:aR -> vprop) // (#lpreR:req_t preR) // (#lpostR:ens_t preR aR postR) ($g:unit -> SteelT aR preR postR) // lpreR lpostR) : SteelT (aL & aR) (preL `star` preR) (fun y -> postL (fst y) `star` postR (snd y))
[]
Steel.Effect.par
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
$f: (_: Prims.unit -> Steel.Effect.SteelT aL) -> $g: (_: Prims.unit -> Steel.Effect.SteelT aR) -> Steel.Effect.SteelT (aL * aR)
{ "end_col": 48, "end_line": 692, "start_col": 2, "start_line": 692 }
Steel.Semantics.Hoare.MST.Mst
val nmst_get: #st: Sem.st -> Prims.unit -> Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get ()
val nmst_get: #st: Sem.st -> Prims.unit -> Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) let nmst_get (#st: Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) =
true
null
false
NMST.get ()
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[]
[ "Steel.Semantics.Hoare.MST.st", "Prims.unit", "FStar.NMST.get", "Steel.Semantics.Hoare.MST.full_mem", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__locks_preorder", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__mem", "Prims.l_True", "Prims.l_and", "Prims.eq2" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nmst_get: #st: Sem.st -> Prims.unit -> Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1)
[]
Steel.Effect.nmst_get
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
_: Prims.unit -> Steel.Semantics.Hoare.MST.Mst (Steel.Semantics.Hoare.MST.full_mem st)
{ "end_col": 15, "end_line": 163, "start_col": 4, "start_line": 163 }
FStar.Pervasives.Lemma
val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r)
val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m =
false
null
true
Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r)
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "lemma" ]
[ "Steel.Memory.slprop", "Steel.Memory.mem", "Steel.Memory.slimp_star", "Steel.Memory.star", "Prims.unit", "Steel.Memory.star_associative" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m)
[]
Steel.Effect.can_be_split_3_interp
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p1: Steel.Memory.slprop -> p2: Steel.Memory.slprop -> q: Steel.Memory.slprop -> r: Steel.Memory.slprop -> m: Steel.Memory.mem -> FStar.Pervasives.Lemma (requires Steel.Memory.slimp p1 p2 /\ Steel.Memory.interp (Steel.Memory.star (Steel.Memory.star p1 q) r) m) (ensures Steel.Memory.interp (Steel.Memory.star (Steel.Memory.star p2 q) r) m)
{ "end_col": 52, "end_line": 152, "start_col": 2, "start_line": 150 }
FStar.Pervasives.Lemma
val reveal_focus_rmem (#r: vprop) (h: rmem r) (r0: vprop{r `can_be_split` r0}) (r': vprop{r0 `can_be_split` r'}) : Lemma (r `can_be_split` r' /\ focus_rmem h r0 r' == h r')
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0)
val reveal_focus_rmem (#r: vprop) (h: rmem r) (r0: vprop{r `can_be_split` r0}) (r': vprop{r0 `can_be_split` r'}) : Lemma (r `can_be_split` r' /\ focus_rmem h r0 r' == h r') let reveal_focus_rmem (#r: vprop) (h: rmem r) (r0: vprop{r `can_be_split` r0}) (r': vprop{r0 `can_be_split` r'}) : Lemma (r `can_be_split` r' /\ focus_rmem h r0 r' == h r') =
false
null
true
can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0)
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "lemma" ]
[ "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem", "Steel.Effect.Common.can_be_split", "FStar.FunctionalExtensionality.feq_on_domain_g", "Steel.Effect.Common.normal", "Steel.Effect.Common.t_of", "Steel.Effect.Common.unrestricted_focus_rmem", "Prims.unit", "Steel.Effect.Common.can_be_split_trans", "Prims.l_True", "Prims.squash", "Prims.l_and", "Prims.eq2", "Steel.Effect.Common.focus_rmem", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val reveal_focus_rmem (#r: vprop) (h: rmem r) (r0: vprop{r `can_be_split` r0}) (r': vprop{r0 `can_be_split` r'}) : Lemma (r `can_be_split` r' /\ focus_rmem h r0 r' == h r')
[]
Steel.Effect.reveal_focus_rmem
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
h: Steel.Effect.Common.rmem r -> r0: Steel.Effect.Common.vprop{Steel.Effect.Common.can_be_split r r0} -> r': Steel.Effect.Common.vprop{Steel.Effect.Common.can_be_split r0 r'} -> FStar.Pervasives.Lemma (ensures Steel.Effect.Common.can_be_split r r' /\ Steel.Effect.Common.focus_rmem h r0 r' == h r' )
{ "end_col": 55, "end_line": 76, "start_col": 4, "start_line": 75 }
FStar.Pervasives.Lemma
val lemma_frame_opaque_refl (frame: vprop) (h: rmem frame) : Lemma (frame_opaque frame h h)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl))
val lemma_frame_opaque_refl (frame: vprop) (h: rmem frame) : Lemma (frame_opaque frame h h) let lemma_frame_opaque_refl (frame: vprop) (h: rmem frame) : Lemma (frame_opaque frame h h) =
false
null
true
FStar.Tactics.Effect.assert_by_tactic (frame_opaque frame h h) (fun _ -> (); (T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)))
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "lemma" ]
[ "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem", "FStar.Tactics.Effect.assert_by_tactic", "Steel.Effect.frame_opaque", "Prims.unit", "FStar.Tactics.V1.Derived.apply_lemma", "FStar.Tactics.V1.Builtins.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_only", "Prims.string", "Prims.Nil", "Prims.l_True", "Prims.squash", "FStar.Pervasives.pattern" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]]
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_frame_opaque_refl (frame: vprop) (h: rmem frame) : Lemma (frame_opaque frame h h)
[]
Steel.Effect.lemma_frame_opaque_refl
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
frame: Steel.Effect.Common.vprop -> h: Steel.Effect.Common.rmem frame -> FStar.Pervasives.Lemma (ensures Steel.Effect.frame_opaque frame h h)
{ "end_col": 49, "end_line": 205, "start_col": 2, "start_line": 203 }
FStar.Pervasives.Lemma
val rmem_depends_only_on_post (#a: Type) (post: post_t a) : Lemma (forall (x: a) (m0: hmem (post x)) (m1: mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1))
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post)
val rmem_depends_only_on_post (#a: Type) (post: post_t a) : Lemma (forall (x: a) (m0: hmem (post x)) (m1: mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) let rmem_depends_only_on_post (#a: Type) (post: post_t a) : Lemma (forall (x: a) (m0: hmem (post x)) (m1: mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) =
false
null
true
Classical.forall_intro_3 (rmem_depends_only_on_post' post)
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "lemma" ]
[ "Steel.Effect.Common.post_t", "FStar.Classical.forall_intro_3", "Steel.Effect.Common.hmem", "Steel.Memory.mem", "Steel.Memory.disjoint", "Prims.eq2", "Steel.Effect.Common.rmem", "Steel.Effect.Common.mk_rmem", "Steel.Memory.join", "Steel.Effect.rmem_depends_only_on_post'", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_Forall", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}).
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rmem_depends_only_on_post (#a: Type) (post: post_t a) : Lemma (forall (x: a) (m0: hmem (post x)) (m1: mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1))
[]
Steel.Effect.rmem_depends_only_on_post
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
post: Steel.Effect.Common.post_t a -> FStar.Pervasives.Lemma (ensures forall (x: a) (m0: Steel.Effect.Common.hmem (post x)) (m1: Steel.Memory.mem{Steel.Memory.disjoint m0 m1}). Steel.Effect.Common.mk_rmem (post x) m0 == Steel.Effect.Common.mk_rmem (post x) (Steel.Memory.join m0 m1))
{ "end_col": 62, "end_line": 53, "start_col": 4, "start_line": 53 }
Prims.Tot
val req_to_act_req (#pre: pre_t) (req: req_t pre) : Sem.l_pre #state (hp_of pre)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0)
val req_to_act_req (#pre: pre_t) (req: req_t pre) : Sem.l_pre #state (hp_of pre) let req_to_act_req (#pre: pre_t) (req: req_t pre) : Sem.l_pre #state (hp_of pre) =
false
null
false
rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0)
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "total" ]
[ "Steel.Effect.Common.pre_t", "Steel.Effect.Common.req_t", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__mem", "Steel.Semantics.Instantiate.state", "Prims.l_and", "Steel.Memory.interp", "Steel.Effect.Common.hp_of", "Steel.Effect.Common.mk_rmem", "Prims.prop", "Prims.unit", "Steel.Effect.rmem_depends_only_on", "Steel.Semantics.Hoare.MST.l_pre" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__]
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val req_to_act_req (#pre: pre_t) (req: req_t pre) : Sem.l_pre #state (hp_of pre)
[]
Steel.Effect.req_to_act_req
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
req: Steel.Effect.Common.req_t pre -> Steel.Semantics.Hoare.MST.l_pre (Steel.Effect.Common.hp_of pre)
{ "end_col": 57, "end_line": 58, "start_col": 2, "start_line": 57 }
FStar.Pervasives.Lemma
val lemma_frame_equalities_refl (frame: vprop) (h: rmem frame) : Lemma (frame_equalities frame h h)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2
val lemma_frame_equalities_refl (frame: vprop) (h: rmem frame) : Lemma (frame_equalities frame h h) let rec lemma_frame_equalities_refl (frame: vprop) (h: rmem frame) : Lemma (frame_equalities frame h h) =
false
null
true
match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "lemma" ]
[ "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem", "Steel.Effect.Common.vprop'", "Steel.Effect.lemma_frame_equalities_refl", "Prims.unit", "Steel.Effect.Common.rmem'", "Steel.Effect.Common.valid_rmem", "Steel.Effect.Common.focus_rmem", "Steel.Effect.Common.can_be_split_star_r", "Steel.Effect.Common.can_be_split_star_l", "Prims.l_True", "Prims.squash", "Steel.Effect.Common.frame_equalities", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get ()
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_frame_equalities_refl (frame: vprop) (h: rmem frame) : Lemma (frame_equalities frame h h)
[ "recursion" ]
Steel.Effect.lemma_frame_equalities_refl
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
frame: Steel.Effect.Common.vprop -> h: Steel.Effect.Common.rmem frame -> FStar.Pervasives.Lemma (ensures Steel.Effect.Common.frame_equalities frame h h)
{ "end_col": 41, "end_line": 176, "start_col": 2, "start_line": 166 }
Prims.Tot
val norm_repr (#a: Type) (#framed: bool) (#pre: pre_t) (#post: post_t a) (#req: req_t pre) (#ens: ens_t pre a post) (f: repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1))
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f
val norm_repr (#a: Type) (#framed: bool) (#pre: pre_t) (#post: post_t a) (#req: req_t pre) (#ens: ens_t pre a post) (f: repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) let norm_repr (#a: Type) (#framed: bool) (#pre: pre_t) (#post: post_t a) (#req: req_t pre) (#ens: ens_t pre a post) (f: repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) =
false
null
false
f
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "total" ]
[ "Prims.bool", "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.req_t", "Steel.Effect.Common.ens_t", "Steel.Effect.repr", "Steel.Effect.Common.rmem", "Steel.Effect.norm_opaque" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val norm_repr (#a: Type) (#framed: bool) (#pre: pre_t) (#post: post_t a) (#req: req_t pre) (#ens: ens_t pre a post) (f: repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1))
[]
Steel.Effect.norm_repr
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
f: Steel.Effect.repr a framed pre post req ens -> Steel.Effect.repr a framed pre post (fun h -> Steel.Effect.norm_opaque (req h)) (fun h0 x h1 -> Steel.Effect.norm_opaque (ens h0 x h1))
{ "end_col": 4, "end_line": 261, "start_col": 3, "start_line": 261 }
Prims.Tot
val bind_req_opaque: #a: Type -> #pre_f: pre_t -> #post_f: post_t a -> req_f: req_t pre_f -> ens_f: ens_t pre_f a post_f -> #pre_g: (a -> pre_t) -> #pr: (a -> prop) -> req_g: (x: a -> req_t (pre_g x)) -> frame_f: vprop -> frame_g: (a -> vprop) -> squash (can_be_split_forall_dep pr (fun x -> (post_f x) `star` frame_f) (fun x -> (pre_g x) `star` (frame_g x))) -> req_t (pre_f `star` frame_f)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x))))
val bind_req_opaque: #a: Type -> #pre_f: pre_t -> #post_f: post_t a -> req_f: req_t pre_f -> ens_f: ens_t pre_f a post_f -> #pre_g: (a -> pre_t) -> #pr: (a -> prop) -> req_g: (x: a -> req_t (pre_g x)) -> frame_f: vprop -> frame_g: (a -> vprop) -> squash (can_be_split_forall_dep pr (fun x -> (post_f x) `star` frame_f) (fun x -> (pre_g x) `star` (frame_g x))) -> req_t (pre_f `star` frame_f) let bind_req_opaque (#a: Type) (#pre_f: pre_t) (#post_f: post_t a) (req_f: req_t pre_f) (ens_f: ens_t pre_f a post_f) (#pre_g: (a -> pre_t)) (#pr: (a -> prop)) (req_g: (x: a -> req_t (pre_g x))) (frame_f: vprop) (frame_g: (a -> vprop)) (_: squash (can_be_split_forall_dep pr (fun x -> (post_f x) `star` frame_f) (fun x -> (pre_g x) `star` (frame_g x)))) : req_t (pre_f `star` frame_f) =
false
null
false
fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x: a) (h1: hmem ((post_f x) `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem ((post_f x) `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem ((post_f x) `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans ((post_f x) `star` frame_f) ((pre_g x) `star` (frame_g x)) (pre_g x); (req_g x) (focus_rmem (mk_rmem ((post_f x) `star` frame_f) h1) (pre_g x))))
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "total" ]
[ "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.req_t", "Steel.Effect.Common.ens_t", "Prims.prop", "Steel.Effect.Common.vprop", "Prims.squash", "Steel.Effect.Common.can_be_split_forall_dep", "Steel.Effect.Common.star", "Steel.Effect.Common.rmem", "Prims.l_and", "Steel.Effect.Common.focus_rmem", "Prims.l_Forall", "Steel.Effect.Common.hmem", "Prims.l_imp", "Steel.Effect.Common.mk_rmem", "Steel.Effect.frame_opaque", "Prims.unit", "Steel.Effect.Common.can_be_split_trans" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f unfold let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x)))
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bind_req_opaque: #a: Type -> #pre_f: pre_t -> #post_f: post_t a -> req_f: req_t pre_f -> ens_f: ens_t pre_f a post_f -> #pre_g: (a -> pre_t) -> #pr: (a -> prop) -> req_g: (x: a -> req_t (pre_g x)) -> frame_f: vprop -> frame_g: (a -> vprop) -> squash (can_be_split_forall_dep pr (fun x -> (post_f x) `star` frame_f) (fun x -> (pre_g x) `star` (frame_g x))) -> req_t (pre_f `star` frame_f)
[]
Steel.Effect.bind_req_opaque
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
req_f: Steel.Effect.Common.req_t pre_f -> ens_f: Steel.Effect.Common.ens_t pre_f a post_f -> req_g: (x: a -> Steel.Effect.Common.req_t (pre_g x)) -> frame_f: Steel.Effect.Common.vprop -> frame_g: (_: a -> Steel.Effect.Common.vprop) -> _: Prims.squash (Steel.Effect.Common.can_be_split_forall_dep pr (fun x -> Steel.Effect.Common.star (post_f x) frame_f) (fun x -> Steel.Effect.Common.star (pre_g x) (frame_g x))) -> Steel.Effect.Common.req_t (Steel.Effect.Common.star pre_f frame_f)
{ "end_col": 79, "end_line": 280, "start_col": 2, "start_line": 273 }
FStar.Pervasives.Lemma
val lemma_rewrite (p: Type) : Lemma (requires T.rewrite_with_tactic vc_norm p) (ensures p)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_rewrite (p:Type) : Lemma (requires T.rewrite_with_tactic vc_norm p) (ensures p) = T.unfold_rewrite_with_tactic vc_norm p
val lemma_rewrite (p: Type) : Lemma (requires T.rewrite_with_tactic vc_norm p) (ensures p) let lemma_rewrite (p: Type) : Lemma (requires T.rewrite_with_tactic vc_norm p) (ensures p) =
false
null
true
T.unfold_rewrite_with_tactic vc_norm p
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "lemma" ]
[ "FStar.Tactics.Effect.unfold_rewrite_with_tactic", "Steel.Effect.Common.vc_norm", "Prims.unit", "FStar.Tactics.Effect.rewrite_with_tactic", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f unfold let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) unfold let bind_ens_opaque (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_opaque (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) val bind_opaque (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#pre_f:pre_t) (#post_f:post_t a) (#req_f:req_t pre_f) (#ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#req_g:(x:a -> req_t (pre_g x))) (#ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#frame_f:vprop) (#frame_g:a -> vprop) (#post:post_t b) (# _ : squash (maybe_emp framed_f frame_f)) (# _ : squash (maybe_emp_dep framed_g frame_g)) (#pr:a -> prop) (#p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req_opaque req_f ens_f req_g frame_f frame_g p1) (bind_ens_opaque req_f ens_f ens_g frame_f frame_g post p1 p2) #push-options "--z3rlimit 20" let bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem (pre_f `star` frame_f) (core_mem m0) in let x = frame00 f frame_f frame in let m1 = nmst_get () in let h1 = mk_rmem (post_f x `star` frame_f) (core_mem m1) in let h1' = mk_rmem (pre_g x `star` frame_g x) (core_mem m1) in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); focus_is_restrict_mk_rmem (post_f x `star` frame_f) (pre_g x `star` frame_g x) (core_mem m1); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x) (core_mem m1); assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); can_be_split_3_interp (hp_of (post_f x `star` frame_f)) (hp_of (pre_g x `star` frame_g x)) frame (locks_invariant Set.empty m1) m1; let y = frame00 (g x) (frame_g x) frame in let m2 = nmst_get () in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); let h2' = mk_rmem (post_g x y `star` frame_g x) (core_mem m2) in let h2 = mk_rmem (post y) (core_mem m2) in // assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x) (core_mem m1); focus_is_restrict_mk_rmem (post_g x y `star` frame_g x) (post y) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (frame_g x) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (post_g x y) (core_mem m2); can_be_split_3_interp (hp_of (post_g x y `star` frame_g x)) (hp_of (post y)) frame (locks_invariant Set.empty m2) m2; y #pop-options let bind a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = norm_repr (bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g) unfold let subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : pure_pre = (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) val subcomp_opaque (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True) #push-options "--fuel 1 --ifuel 1 --z3rlimit 20" let subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #_ #p1 #p2 f = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem pre_g (core_mem m0) in can_be_split_trans pre_g (pre_f `star` fr) pre_f; can_be_split_trans pre_g (pre_f `star` fr) fr; can_be_split_3_interp (hp_of pre_g) (hp_of (pre_f `star` fr)) frame (locks_invariant Set.empty m0) m0; focus_replace pre_g (pre_f `star` fr) pre_f (core_mem m0); let x = frame00 f fr frame in let m1 = nmst_get () in let h1 = mk_rmem (post_g x) (core_mem m1) in let h0' = mk_rmem (pre_f `star` fr) (core_mem m0) in let h1' = mk_rmem (post_f x `star` fr) (core_mem m1) in // From frame00 assert (frame_opaque fr (focus_rmem h0' fr) (focus_rmem h1' fr)); // Replace h0'/h1' by h0/h1 focus_replace pre_g (pre_f `star` fr) fr (core_mem m0); focus_replace (post_g x) (post_f x `star` fr) fr (core_mem m1); assert (frame_opaque fr (focus_rmem h0 fr) (focus_rmem h1 fr)); can_be_split_trans (post_g x) (post_f x `star` fr) (post_f x); can_be_split_trans (post_g x) (post_f x `star` fr) fr; can_be_split_3_interp (hp_of (post_f x `star` fr)) (hp_of (post_g x)) frame (locks_invariant Set.empty m1) m1; focus_replace (post_g x) (post_f x `star` fr) (post_f x) (core_mem m1); x #pop-options
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_rewrite (p: Type) : Lemma (requires T.rewrite_with_tactic vc_norm p) (ensures p)
[]
Steel.Effect.lemma_rewrite
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: Type0 -> FStar.Pervasives.Lemma (requires FStar.Tactics.Effect.rewrite_with_tactic Steel.Effect.Common.vc_norm p) (ensures p)
{ "end_col": 42, "end_line": 499, "start_col": 4, "start_line": 499 }
FStar.Pervasives.Lemma
val rmem_depends_only_on_post' (#a: Type) (post: post_t a) (x: a) (m0: hmem (post x)) (m1: mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1))
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1
val rmem_depends_only_on_post' (#a: Type) (post: post_t a) (x: a) (m0: hmem (post x)) (m1: mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) let rmem_depends_only_on_post' (#a: Type) (post: post_t a) (x: a) (m0: hmem (post x)) (m1: mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) =
false
null
true
rmem_depends_only_on' (post x) m0 m1
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "lemma" ]
[ "Steel.Effect.Common.post_t", "Steel.Effect.Common.hmem", "Steel.Memory.mem", "Steel.Memory.disjoint", "Steel.Effect.rmem_depends_only_on'", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Steel.Effect.Common.rmem", "Steel.Effect.Common.mk_rmem", "Steel.Memory.join", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1})
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rmem_depends_only_on_post' (#a: Type) (post: post_t a) (x: a) (m0: hmem (post x)) (m1: mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1))
[]
Steel.Effect.rmem_depends_only_on_post'
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
post: Steel.Effect.Common.post_t a -> x: a -> m0: Steel.Effect.Common.hmem (post x) -> m1: Steel.Memory.mem{Steel.Memory.disjoint m0 m1} -> FStar.Pervasives.Lemma (ensures Steel.Effect.Common.mk_rmem (post x) m0 == Steel.Effect.Common.mk_rmem (post x) (Steel.Memory.join m0 m1))
{ "end_col": 40, "end_line": 48, "start_col": 4, "start_line": 48 }
FStar.Pervasives.Lemma
val rmem_depends_only_on' (pre: pre_t) (m0: hmem pre) (m1: mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1))
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1))
val rmem_depends_only_on' (pre: pre_t) (m0: hmem pre) (m1: mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) let rmem_depends_only_on' (pre: pre_t) (m0: hmem pre) (m1: mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) =
false
null
true
Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0: vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1))
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "lemma" ]
[ "Steel.Effect.Common.pre_t", "Steel.Effect.Common.hmem", "Steel.Memory.mem", "Steel.Memory.disjoint", "FStar.FunctionalExtensionality.extensionality_g", "Steel.Effect.Common.vprop", "Steel.Effect.Common.can_be_split", "Steel.Effect.Common.normal", "Steel.Effect.Common.t_of", "Steel.Effect.Common.mk_rmem", "Steel.Memory.join", "Prims.unit", "FStar.Classical.forall_intro", "Prims.eq2", "Steel.Effect.Common.sel_of", "Steel.Effect.Common.reveal_mk_rmem", "Prims.l_True", "Prims.squash", "Steel.Effect.Common.rmem", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1})
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rmem_depends_only_on' (pre: pre_t) (m0: hmem pre) (m1: mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1))
[]
Steel.Effect.rmem_depends_only_on'
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
pre: Steel.Effect.Common.pre_t -> m0: Steel.Effect.Common.hmem pre -> m1: Steel.Memory.mem{Steel.Memory.disjoint m0 m1} -> FStar.Pervasives.Lemma (ensures Steel.Effect.Common.mk_rmem pre m0 == Steel.Effect.Common.mk_rmem pre (Steel.Memory.join m0 m1))
{ "end_col": 32, "end_line": 38, "start_col": 4, "start_line": 32 }
Prims.Tot
val subcomp_pre_opaque: #a: Type -> #pre_f: pre_t -> #post_f: post_t a -> req_f: req_t pre_f -> ens_f: ens_t pre_f a post_f -> #pre_g: pre_t -> #post_g: post_t a -> req_g: req_t pre_g -> ens_g: ens_t pre_g a post_g -> #frame: vprop -> #pr: prop -> squash (can_be_split_dep pr pre_g (pre_f `star` frame)) -> squash (equiv_forall post_g (fun x -> (post_f x) `star` frame)) -> pure_pre
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : pure_pre = (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) ))
val subcomp_pre_opaque: #a: Type -> #pre_f: pre_t -> #post_f: post_t a -> req_f: req_t pre_f -> ens_f: ens_t pre_f a post_f -> #pre_g: pre_t -> #post_g: post_t a -> req_g: req_t pre_g -> ens_g: ens_t pre_g a post_g -> #frame: vprop -> #pr: prop -> squash (can_be_split_dep pr pre_g (pre_f `star` frame)) -> squash (equiv_forall post_g (fun x -> (post_f x) `star` frame)) -> pure_pre let subcomp_pre_opaque (#a: Type) (#pre_f: pre_t) (#post_f: post_t a) (req_f: req_t pre_f) (ens_f: ens_t pre_f a post_f) (#pre_g: pre_t) (#post_g: post_t a) (req_g: req_t pre_g) (ens_g: ens_t pre_g a post_g) (#frame: vprop) (#pr: prop) (_: squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_: squash (equiv_forall post_g (fun x -> (post_f x) `star` frame))) : pure_pre =
false
null
false
(forall (h0: hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ (can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0: hmem pre_g) (x: a) (h1: hmem (post_g x)). (pr ==> (can_be_split_trans (post_g x) ((post_f x) `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) ((post_f x) `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1))))
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "total" ]
[ "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.req_t", "Steel.Effect.Common.ens_t", "Steel.Effect.Common.vprop", "Prims.prop", "Prims.squash", "Steel.Effect.Common.can_be_split_dep", "Steel.Effect.Common.star", "Steel.Effect.Common.equiv_forall", "Prims.l_and", "Prims.l_Forall", "Steel.Effect.Common.hmem", "Prims.l_imp", "Steel.Effect.Common.mk_rmem", "Steel.Effect.Common.focus_rmem", "Prims.unit", "Steel.Effect.Common.can_be_split_trans", "Steel.Effect.frame_opaque", "Prims.pure_pre" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f unfold let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) unfold let bind_ens_opaque (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_opaque (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) val bind_opaque (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#pre_f:pre_t) (#post_f:post_t a) (#req_f:req_t pre_f) (#ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#req_g:(x:a -> req_t (pre_g x))) (#ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#frame_f:vprop) (#frame_g:a -> vprop) (#post:post_t b) (# _ : squash (maybe_emp framed_f frame_f)) (# _ : squash (maybe_emp_dep framed_g frame_g)) (#pr:a -> prop) (#p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req_opaque req_f ens_f req_g frame_f frame_g p1) (bind_ens_opaque req_f ens_f ens_g frame_f frame_g post p1 p2) #push-options "--z3rlimit 20" let bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem (pre_f `star` frame_f) (core_mem m0) in let x = frame00 f frame_f frame in let m1 = nmst_get () in let h1 = mk_rmem (post_f x `star` frame_f) (core_mem m1) in let h1' = mk_rmem (pre_g x `star` frame_g x) (core_mem m1) in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); focus_is_restrict_mk_rmem (post_f x `star` frame_f) (pre_g x `star` frame_g x) (core_mem m1); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x) (core_mem m1); assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); can_be_split_3_interp (hp_of (post_f x `star` frame_f)) (hp_of (pre_g x `star` frame_g x)) frame (locks_invariant Set.empty m1) m1; let y = frame00 (g x) (frame_g x) frame in let m2 = nmst_get () in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); let h2' = mk_rmem (post_g x y `star` frame_g x) (core_mem m2) in let h2 = mk_rmem (post y) (core_mem m2) in // assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x) (core_mem m1); focus_is_restrict_mk_rmem (post_g x y `star` frame_g x) (post y) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (frame_g x) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (post_g x y) (core_mem m2); can_be_split_3_interp (hp_of (post_g x y `star` frame_g x)) (hp_of (post y)) frame (locks_invariant Set.empty m2) m2; y #pop-options let bind a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = norm_repr (bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g) unfold let subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame)))
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val subcomp_pre_opaque: #a: Type -> #pre_f: pre_t -> #post_f: post_t a -> req_f: req_t pre_f -> ens_f: ens_t pre_f a post_f -> #pre_g: pre_t -> #post_g: post_t a -> req_g: req_t pre_g -> ens_g: ens_t pre_g a post_g -> #frame: vprop -> #pr: prop -> squash (can_be_split_dep pr pre_g (pre_f `star` frame)) -> squash (equiv_forall post_g (fun x -> (post_f x) `star` frame)) -> pure_pre
[]
Steel.Effect.subcomp_pre_opaque
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
req_f: Steel.Effect.Common.req_t pre_f -> ens_f: Steel.Effect.Common.ens_t pre_f a post_f -> req_g: Steel.Effect.Common.req_t pre_g -> ens_g: Steel.Effect.Common.ens_t pre_g a post_g -> _: Prims.squash (Steel.Effect.Common.can_be_split_dep pr pre_g (Steel.Effect.Common.star pre_f frame)) -> _: Prims.squash (Steel.Effect.Common.equiv_forall post_g (fun x -> Steel.Effect.Common.star (post_f x) frame)) -> Prims.pure_pre
{ "end_col": 4, "end_line": 441, "start_col": 2, "start_line": 424 }
Prims.Tot
val bind_ens_opaque: #a: Type -> #b: Type -> #pre_f: pre_t -> #post_f: post_t a -> req_f: req_t pre_f -> ens_f: ens_t pre_f a post_f -> #pre_g: (a -> pre_t) -> #post_g: (a -> post_t b) -> #pr: (a -> prop) -> ens_g: (x: a -> ens_t (pre_g x) b (post_g x)) -> frame_f: vprop -> frame_g: (a -> vprop) -> post: post_t b -> squash (can_be_split_forall_dep pr (fun x -> (post_f x) `star` frame_f) (fun x -> (pre_g x) `star` (frame_g x))) -> squash (can_be_split_post (fun x y -> (post_g x y) `star` (frame_g x)) post) -> ens_t (pre_f `star` frame_f) b post
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bind_ens_opaque (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_opaque (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y))))
val bind_ens_opaque: #a: Type -> #b: Type -> #pre_f: pre_t -> #post_f: post_t a -> req_f: req_t pre_f -> ens_f: ens_t pre_f a post_f -> #pre_g: (a -> pre_t) -> #post_g: (a -> post_t b) -> #pr: (a -> prop) -> ens_g: (x: a -> ens_t (pre_g x) b (post_g x)) -> frame_f: vprop -> frame_g: (a -> vprop) -> post: post_t b -> squash (can_be_split_forall_dep pr (fun x -> (post_f x) `star` frame_f) (fun x -> (pre_g x) `star` (frame_g x))) -> squash (can_be_split_post (fun x y -> (post_g x y) `star` (frame_g x)) post) -> ens_t (pre_f `star` frame_f) b post let bind_ens_opaque (#a: Type) (#b: Type) (#pre_f: pre_t) (#post_f: post_t a) (req_f: req_t pre_f) (ens_f: ens_t pre_f a post_f) (#pre_g: (a -> pre_t)) (#post_g: (a -> post_t b)) (#pr: (a -> prop)) (ens_g: (x: a -> ens_t (pre_g x) b (post_g x))) (frame_f: vprop) (frame_g: (a -> vprop)) (post: post_t b) (_: squash (can_be_split_forall_dep pr (fun x -> (post_f x) `star` frame_f) (fun x -> (pre_g x) `star` (frame_g x)))) (_: squash (can_be_split_post (fun x y -> (post_g x y) `star` (frame_g x)) post)) : ens_t (pre_f `star` frame_f) b post =
false
null
false
fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x: a) (h1: hmem ((post_f x) `star` frame_f)). pr x /\ (can_be_split_trans ((post_f x) `star` frame_f) ((pre_g x) `star` (frame_g x)) (pre_g x); can_be_split_trans ((post_f x) `star` frame_f) ((pre_g x) `star` (frame_g x)) (frame_g x); can_be_split_trans (post y) ((post_g x y) `star` (frame_g x)) (post_g x y); can_be_split_trans (post y) ((post_g x y) `star` (frame_g x)) (frame_g x); frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem ((post_f x) `star` frame_f) h1) frame_f) /\ frame_opaque (frame_g x) (focus_rmem (mk_rmem ((post_f x) `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem ((post_f x) `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem ((post_f x) `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y))))
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "total" ]
[ "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.req_t", "Steel.Effect.Common.ens_t", "Prims.prop", "Steel.Effect.Common.vprop", "Prims.squash", "Steel.Effect.Common.can_be_split_forall_dep", "Steel.Effect.Common.star", "Steel.Effect.Common.can_be_split_post", "Steel.Effect.Common.rmem", "Prims.l_and", "Steel.Effect.Common.focus_rmem", "Prims.l_Exists", "Steel.Effect.Common.hmem", "Steel.Effect.frame_opaque", "Steel.Effect.Common.mk_rmem", "Prims.unit", "Steel.Effect.Common.can_be_split_trans" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f unfold let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) unfold let bind_ens_opaque (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post))
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bind_ens_opaque: #a: Type -> #b: Type -> #pre_f: pre_t -> #post_f: post_t a -> req_f: req_t pre_f -> ens_f: ens_t pre_f a post_f -> #pre_g: (a -> pre_t) -> #post_g: (a -> post_t b) -> #pr: (a -> prop) -> ens_g: (x: a -> ens_t (pre_g x) b (post_g x)) -> frame_f: vprop -> frame_g: (a -> vprop) -> post: post_t b -> squash (can_be_split_forall_dep pr (fun x -> (post_f x) `star` frame_f) (fun x -> (pre_g x) `star` (frame_g x))) -> squash (can_be_split_post (fun x y -> (post_g x y) `star` (frame_g x)) post) -> ens_t (pre_f `star` frame_f) b post
[]
Steel.Effect.bind_ens_opaque
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
req_f: Steel.Effect.Common.req_t pre_f -> ens_f: Steel.Effect.Common.ens_t pre_f a post_f -> ens_g: (x: a -> Steel.Effect.Common.ens_t (pre_g x) b (post_g x)) -> frame_f: Steel.Effect.Common.vprop -> frame_g: (_: a -> Steel.Effect.Common.vprop) -> post: Steel.Effect.Common.post_t b -> _: Prims.squash (Steel.Effect.Common.can_be_split_forall_dep pr (fun x -> Steel.Effect.Common.star (post_f x) frame_f) (fun x -> Steel.Effect.Common.star (pre_g x) (frame_g x))) -> _: Prims.squash (Steel.Effect.Common.can_be_split_post (fun x y -> Steel.Effect.Common.star (post_g x y) (frame_g x)) post) -> Steel.Effect.Common.ens_t (Steel.Effect.Common.star pre_f frame_f) b post
{ "end_col": 108, "end_line": 306, "start_col": 2, "start_line": 294 }
Prims.Tot
val bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:a -> post_t b) (#[@@@ framing_implicit] req_g:(x:a -> req_t (pre_g x))) (#[@@@ framing_implicit] ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:a -> vprop) (#[@@@ framing_implicit] post:post_t b) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] _ : squash (maybe_emp_dep framed_g frame_g)) (#[@@@ framing_implicit] pr:a -> prop) (#[@@@ framing_implicit] p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#[@@@ framing_implicit] p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req req_f ens_f req_g frame_f frame_g p1) (bind_ens req_f ens_f ens_g frame_f frame_g post p1 p2)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bind a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = norm_repr (bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g)
val bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:a -> post_t b) (#[@@@ framing_implicit] req_g:(x:a -> req_t (pre_g x))) (#[@@@ framing_implicit] ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:a -> vprop) (#[@@@ framing_implicit] post:post_t b) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] _ : squash (maybe_emp_dep framed_g frame_g)) (#[@@@ framing_implicit] pr:a -> prop) (#[@@@ framing_implicit] p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#[@@@ framing_implicit] p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req req_f ens_f req_g frame_f frame_g p1) (bind_ens req_f ens_f ens_g frame_f frame_g post p1 p2) let bind a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g =
false
null
false
norm_repr (bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g)
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "total" ]
[ "FStar.Pervasives.eqtype_as_type", "Prims.bool", "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.req_t", "Steel.Effect.Common.ens_t", "Steel.Effect.Common.vprop", "Prims.squash", "Steel.Effect.Common.maybe_emp", "Steel.Effect.Common.maybe_emp_dep", "Prims.prop", "Steel.Effect.Common.can_be_split_forall_dep", "Steel.Effect.Common.star", "Steel.Effect.Common.can_be_split_post", "Steel.Effect.repr", "Steel.Effect.norm_repr", "Steel.Effect.bind_req_opaque", "Steel.Effect.bind_ens_opaque", "Steel.Effect.bind_opaque", "Steel.Effect.bind_req", "Steel.Effect.bind_ens" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f unfold let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) unfold let bind_ens_opaque (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_opaque (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) val bind_opaque (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#pre_f:pre_t) (#post_f:post_t a) (#req_f:req_t pre_f) (#ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#req_g:(x:a -> req_t (pre_g x))) (#ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#frame_f:vprop) (#frame_g:a -> vprop) (#post:post_t b) (# _ : squash (maybe_emp framed_f frame_f)) (# _ : squash (maybe_emp_dep framed_g frame_g)) (#pr:a -> prop) (#p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req_opaque req_f ens_f req_g frame_f frame_g p1) (bind_ens_opaque req_f ens_f ens_g frame_f frame_g post p1 p2) #push-options "--z3rlimit 20" let bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem (pre_f `star` frame_f) (core_mem m0) in let x = frame00 f frame_f frame in let m1 = nmst_get () in let h1 = mk_rmem (post_f x `star` frame_f) (core_mem m1) in let h1' = mk_rmem (pre_g x `star` frame_g x) (core_mem m1) in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); focus_is_restrict_mk_rmem (post_f x `star` frame_f) (pre_g x `star` frame_g x) (core_mem m1); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x) (core_mem m1); assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); can_be_split_3_interp (hp_of (post_f x `star` frame_f)) (hp_of (pre_g x `star` frame_g x)) frame (locks_invariant Set.empty m1) m1; let y = frame00 (g x) (frame_g x) frame in let m2 = nmst_get () in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); let h2' = mk_rmem (post_g x y `star` frame_g x) (core_mem m2) in let h2 = mk_rmem (post y) (core_mem m2) in // assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x) (core_mem m1); focus_is_restrict_mk_rmem (post_g x y `star` frame_g x) (post y) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (frame_g x) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (post_g x y) (core_mem m2); can_be_split_3_interp (hp_of (post_g x y `star` frame_g x)) (hp_of (post y)) frame (locks_invariant Set.empty m2) m2; y #pop-options
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:a -> post_t b) (#[@@@ framing_implicit] req_g:(x:a -> req_t (pre_g x))) (#[@@@ framing_implicit] ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:a -> vprop) (#[@@@ framing_implicit] post:post_t b) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] _ : squash (maybe_emp_dep framed_g frame_g)) (#[@@@ framing_implicit] pr:a -> prop) (#[@@@ framing_implicit] p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#[@@@ framing_implicit] p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req req_f ens_f req_g frame_f frame_g p1) (bind_ens req_f ens_f ens_g frame_f frame_g post p1 p2)
[]
Steel.Effect.bind
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Type -> b: Type -> f: Steel.Effect.repr a framed_f pre_f post_f req_f ens_f -> g: (x: a -> Steel.Effect.repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x)) -> Steel.Effect.repr b true (Steel.Effect.Common.star pre_f frame_f) post (Steel.Effect.bind_req req_f ens_f req_g frame_f frame_g p1) (Steel.Effect.bind_ens req_f ens_f ens_g frame_f frame_g post p1 p2)
{ "end_col": 150, "end_line": 414, "start_col": 4, "start_line": 414 }
FStar.Pervasives.Lemma
val rmem_depends_only_on (pre: pre_t) : Lemma (forall (m0: hmem pre) (m1: mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1))
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre)
val rmem_depends_only_on (pre: pre_t) : Lemma (forall (m0: hmem pre) (m1: mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre: pre_t) : Lemma (forall (m0: hmem pre) (m1: mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) =
false
null
true
Classical.forall_intro_2 (rmem_depends_only_on' pre)
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "lemma" ]
[ "Steel.Effect.Common.pre_t", "FStar.Classical.forall_intro_2", "Steel.Effect.Common.hmem", "Steel.Memory.mem", "Steel.Memory.disjoint", "Prims.eq2", "Steel.Effect.Common.rmem", "Steel.Effect.Common.mk_rmem", "Steel.Memory.join", "Steel.Effect.rmem_depends_only_on'", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_Forall", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}).
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rmem_depends_only_on (pre: pre_t) : Lemma (forall (m0: hmem pre) (m1: mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1))
[]
Steel.Effect.rmem_depends_only_on
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
pre: Steel.Effect.Common.pre_t -> FStar.Pervasives.Lemma (ensures forall (m0: Steel.Effect.Common.hmem pre) (m1: Steel.Memory.mem{Steel.Memory.disjoint m0 m1}). Steel.Effect.Common.mk_rmem pre m0 == Steel.Effect.Common.mk_rmem pre (Steel.Memory.join m0 m1))
{ "end_col": 56, "end_line": 43, "start_col": 4, "start_line": 43 }
FStar.Pervasives.Lemma
val lemma_subcomp_pre_opaque (#a: Type) (#pre_f: pre_t) (#post_f: post_t a) (req_f: req_t pre_f) (ens_f: ens_t pre_f a post_f) (#pre_g: pre_t) (#post_g: post_t a) (req_g: req_t pre_g) (ens_g: ens_t pre_g a post_g) (#frame: vprop) (#pr: prop) (p1: squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2: squash (equiv_forall post_g (fun x -> (post_f x) `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr : prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_subcomp_pre_opaque_aux1 req_f ens_f req_g ens_g p1 p2; lemma_subcomp_pre_opaque_aux2 req_f ens_f req_g ens_g p1 p2
val lemma_subcomp_pre_opaque (#a: Type) (#pre_f: pre_t) (#post_f: post_t a) (req_f: req_t pre_f) (ens_f: ens_t pre_f a post_f) (#pre_g: pre_t) (#post_g: post_t a) (req_g: req_t pre_g) (ens_g: ens_t pre_g a post_g) (#frame: vprop) (#pr: prop) (p1: squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2: squash (equiv_forall post_g (fun x -> (post_f x) `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) let lemma_subcomp_pre_opaque (#a: Type) (#pre_f: pre_t) (#post_f: post_t a) (req_f: req_t pre_f) (ens_f: ens_t pre_f a post_f) (#pre_g: pre_t) (#post_g: post_t a) (req_g: req_t pre_g) (ens_g: ens_t pre_g a post_g) (#frame: vprop) (#pr: prop) (p1: squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2: squash (equiv_forall post_g (fun x -> (post_f x) `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) =
false
null
true
lemma_subcomp_pre_opaque_aux1 req_f ens_f req_g ens_g p1 p2; lemma_subcomp_pre_opaque_aux2 req_f ens_f req_g ens_g p1 p2
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "lemma" ]
[ "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.req_t", "Steel.Effect.Common.ens_t", "Steel.Effect.Common.vprop", "Prims.prop", "Prims.squash", "Steel.Effect.Common.can_be_split_dep", "Steel.Effect.Common.star", "Steel.Effect.Common.equiv_forall", "Steel.Effect.lemma_subcomp_pre_opaque_aux2", "Prims.unit", "Steel.Effect.lemma_subcomp_pre_opaque_aux1", "Steel.Effect.subcomp_pre", "Steel.Effect.subcomp_pre_opaque", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f unfold let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) unfold let bind_ens_opaque (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_opaque (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) val bind_opaque (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#pre_f:pre_t) (#post_f:post_t a) (#req_f:req_t pre_f) (#ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#req_g:(x:a -> req_t (pre_g x))) (#ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#frame_f:vprop) (#frame_g:a -> vprop) (#post:post_t b) (# _ : squash (maybe_emp framed_f frame_f)) (# _ : squash (maybe_emp_dep framed_g frame_g)) (#pr:a -> prop) (#p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req_opaque req_f ens_f req_g frame_f frame_g p1) (bind_ens_opaque req_f ens_f ens_g frame_f frame_g post p1 p2) #push-options "--z3rlimit 20" let bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem (pre_f `star` frame_f) (core_mem m0) in let x = frame00 f frame_f frame in let m1 = nmst_get () in let h1 = mk_rmem (post_f x `star` frame_f) (core_mem m1) in let h1' = mk_rmem (pre_g x `star` frame_g x) (core_mem m1) in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); focus_is_restrict_mk_rmem (post_f x `star` frame_f) (pre_g x `star` frame_g x) (core_mem m1); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x) (core_mem m1); assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); can_be_split_3_interp (hp_of (post_f x `star` frame_f)) (hp_of (pre_g x `star` frame_g x)) frame (locks_invariant Set.empty m1) m1; let y = frame00 (g x) (frame_g x) frame in let m2 = nmst_get () in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); let h2' = mk_rmem (post_g x y `star` frame_g x) (core_mem m2) in let h2 = mk_rmem (post y) (core_mem m2) in // assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x) (core_mem m1); focus_is_restrict_mk_rmem (post_g x y `star` frame_g x) (post y) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (frame_g x) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (post_g x y) (core_mem m2); can_be_split_3_interp (hp_of (post_g x y `star` frame_g x)) (hp_of (post y)) frame (locks_invariant Set.empty m2) m2; y #pop-options let bind a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = norm_repr (bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g) unfold let subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : pure_pre = (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) val subcomp_opaque (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True) #push-options "--fuel 1 --ifuel 1 --z3rlimit 20" let subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #_ #p1 #p2 f = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem pre_g (core_mem m0) in can_be_split_trans pre_g (pre_f `star` fr) pre_f; can_be_split_trans pre_g (pre_f `star` fr) fr; can_be_split_3_interp (hp_of pre_g) (hp_of (pre_f `star` fr)) frame (locks_invariant Set.empty m0) m0; focus_replace pre_g (pre_f `star` fr) pre_f (core_mem m0); let x = frame00 f fr frame in let m1 = nmst_get () in let h1 = mk_rmem (post_g x) (core_mem m1) in let h0' = mk_rmem (pre_f `star` fr) (core_mem m0) in let h1' = mk_rmem (post_f x `star` fr) (core_mem m1) in // From frame00 assert (frame_opaque fr (focus_rmem h0' fr) (focus_rmem h1' fr)); // Replace h0'/h1' by h0/h1 focus_replace pre_g (pre_f `star` fr) fr (core_mem m0); focus_replace (post_g x) (post_f x `star` fr) fr (core_mem m1); assert (frame_opaque fr (focus_rmem h0 fr) (focus_rmem h1 fr)); can_be_split_trans (post_g x) (post_f x `star` fr) (post_f x); can_be_split_trans (post_g x) (post_f x `star` fr) fr; can_be_split_3_interp (hp_of (post_f x `star` fr)) (hp_of (post_g x)) frame (locks_invariant Set.empty m1) m1; focus_replace (post_g x) (post_f x `star` fr) (post_f x) (core_mem m1); x #pop-options let lemma_rewrite (p:Type) : Lemma (requires T.rewrite_with_tactic vc_norm p) (ensures p) = T.unfold_rewrite_with_tactic vc_norm p let lemma_norm_opaque (p:Type) : Lemma (requires norm_opaque p) (ensures p) = () (** Need to manually remove the rewrite_with_tactic marker here *) let lemma_subcomp_pre_opaque_aux1 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) = lemma_rewrite (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) #push-options "--no_tactics" let lemma_subcomp_pre_opaque_aux2 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_norm_opaque (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) let lemma_subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr : prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": true, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_subcomp_pre_opaque (#a: Type) (#pre_f: pre_t) (#post_f: post_t a) (req_f: req_t pre_f) (ens_f: ens_t pre_f a post_f) (#pre_g: pre_t) (#post_g: post_t a) (req_g: req_t pre_g) (ens_g: ens_t pre_g a post_g) (#frame: vprop) (#pr: prop) (p1: squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2: squash (equiv_forall post_g (fun x -> (post_f x) `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2)
[]
Steel.Effect.lemma_subcomp_pre_opaque
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
req_f: Steel.Effect.Common.req_t pre_f -> ens_f: Steel.Effect.Common.ens_t pre_f a post_f -> req_g: Steel.Effect.Common.req_t pre_g -> ens_g: Steel.Effect.Common.ens_t pre_g a post_g -> p1: Prims.squash (Steel.Effect.Common.can_be_split_dep pr pre_g (Steel.Effect.Common.star pre_f frame)) -> p2: Prims.squash (Steel.Effect.Common.equiv_forall post_g (fun x -> Steel.Effect.Common.star (post_f x) frame)) -> FStar.Pervasives.Lemma (requires Steel.Effect.subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures Steel.Effect.subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2)
{ "end_col": 63, "end_line": 621, "start_col": 4, "start_line": 620 }
Prims.Tot
val ens_to_act_ens (#pre: pre_t) (#a: Type) (#post: post_t a) (ens: ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1)
val ens_to_act_ens (#pre: pre_t) (#a: Type) (#post: post_t a) (ens: ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) let ens_to_act_ens (#pre: pre_t) (#a: Type) (#post: post_t a) (ens: ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) =
false
null
false
rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1)
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "total" ]
[ "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.ens_t", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__mem", "Steel.Semantics.Instantiate.state", "Prims.l_and", "Steel.Memory.interp", "Steel.Effect.Common.hp_of", "Steel.Effect.Common.mk_rmem", "Prims.prop", "Prims.unit", "Steel.Effect.rmem_depends_only_on_post", "Steel.Effect.rmem_depends_only_on", "Steel.Semantics.Hoare.MST.l_post", "Steel.Effect.to_post" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ens_to_act_ens (#pre: pre_t) (#a: Type) (#post: post_t a) (ens: ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post)
[]
Steel.Effect.ens_to_act_ens
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
ens: Steel.Effect.Common.ens_t pre a post -> Steel.Semantics.Hoare.MST.l_post (Steel.Effect.Common.hp_of pre) (Steel.Effect.to_post post)
{ "end_col": 103, "end_line": 69, "start_col": 2, "start_line": 66 }
FStar.Pervasives.Lemma
val focus_replace (fp0 fp1 fp2: vprop) (m: hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21
val focus_replace (fp0 fp1 fp2: vprop) (m: hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) let focus_replace (fp0 fp1 fp2: vprop) (m: hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) =
false
null
true
let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r: vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0: vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "lemma" ]
[ "Steel.Effect.Common.vprop", "Steel.Effect.Common.hmem", "FStar.FunctionalExtensionality.extensionality_g", "Steel.Effect.Common.can_be_split", "Steel.Effect.Common.normal", "Steel.Effect.Common.t_of", "Prims.unit", "FStar.Classical.forall_intro", "Prims.eq2", "Prims.l_True", "Prims.squash", "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.delta_only", "FStar.Pervasives.delta_qualifier", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "FStar.Pervasives.simplify", "FStar.Pervasives.pattern", "Steel.Effect.reveal_focus_rmem", "Steel.Effect.Common.reveal_mk_rmem", "Steel.Effect.Common.rmem'", "Steel.Effect.Common.valid_rmem", "Steel.Effect.Common.focus_rmem", "Steel.Effect.Common.mk_rmem", "Prims.l_and", "Steel.Effect.Common.rmem" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val focus_replace (fp0 fp1 fp2: vprop) (m: hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2)
[]
Steel.Effect.focus_replace
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
fp0: Steel.Effect.Common.vprop -> fp1: Steel.Effect.Common.vprop -> fp2: Steel.Effect.Common.vprop -> m: Steel.Effect.Common.hmem fp0 -> FStar.Pervasives.Lemma (requires Steel.Effect.Common.can_be_split fp0 fp1 /\ Steel.Effect.Common.can_be_split fp1 fp2 ) (ensures Steel.Effect.Common.focus_rmem (Steel.Effect.Common.mk_rmem fp0 m) fp2 == Steel.Effect.Common.focus_rmem (Steel.Effect.Common.mk_rmem fp1 m) fp2)
{ "end_col": 13, "end_line": 142, "start_col": 3, "start_line": 126 }
Prims.Tot
val bind_div_steel (a b: Type) (wp: pure_wp a) (framed: eqtype_as_type bool) (pre_g: pre_t) (post_g: post_t b) (req_g: (a -> req_t pre_g)) (ens_g: (a -> ens_t pre_g b post_g)) (f: (eqtype_as_type unit -> DIV a wp)) (g: (x: a -> repr b framed pre_g post_g (req_g x) (ens_g x))) : repr b framed pre_g post_g (bind_div_steel_req wp req_g) (bind_div_steel_ens wp ens_g)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bind_div_steel (a:Type) (b:Type) (wp:pure_wp a) (framed:eqtype_as_type bool) (pre_g:pre_t) (post_g:post_t b) (req_g:a -> req_t pre_g) (ens_g:a -> ens_t pre_g b post_g) (f:eqtype_as_type unit -> DIV a wp) (g:(x:a -> repr b framed pre_g post_g (req_g x) (ens_g x))) : repr b framed pre_g post_g (bind_div_steel_req wp req_g) (bind_div_steel_ens wp ens_g) = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun frame -> let x = f () in g x frame
val bind_div_steel (a b: Type) (wp: pure_wp a) (framed: eqtype_as_type bool) (pre_g: pre_t) (post_g: post_t b) (req_g: (a -> req_t pre_g)) (ens_g: (a -> ens_t pre_g b post_g)) (f: (eqtype_as_type unit -> DIV a wp)) (g: (x: a -> repr b framed pre_g post_g (req_g x) (ens_g x))) : repr b framed pre_g post_g (bind_div_steel_req wp req_g) (bind_div_steel_ens wp ens_g) let bind_div_steel (a b: Type) (wp: pure_wp a) (framed: eqtype_as_type bool) (pre_g: pre_t) (post_g: post_t b) (req_g: (a -> req_t pre_g)) (ens_g: (a -> ens_t pre_g b post_g)) (f: (eqtype_as_type unit -> DIV a wp)) (g: (x: a -> repr b framed pre_g post_g (req_g x) (ens_g x))) : repr b framed pre_g post_g (bind_div_steel_req wp req_g) (bind_div_steel_ens wp ens_g) =
false
null
false
FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun frame -> let x = f () in g x frame
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "total" ]
[ "Prims.pure_wp", "FStar.Pervasives.eqtype_as_type", "Prims.bool", "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.req_t", "Steel.Effect.Common.ens_t", "Prims.unit", "Steel.Effect.repr", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__hprop", "Steel.Semantics.Instantiate.state", "FStar.Monotonic.Pure.elim_pure_wp_monotonicity", "Steel.Effect.bind_div_steel_req", "Steel.Effect.bind_div_steel_ens" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f unfold let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) unfold let bind_ens_opaque (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_opaque (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) val bind_opaque (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#pre_f:pre_t) (#post_f:post_t a) (#req_f:req_t pre_f) (#ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#req_g:(x:a -> req_t (pre_g x))) (#ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#frame_f:vprop) (#frame_g:a -> vprop) (#post:post_t b) (# _ : squash (maybe_emp framed_f frame_f)) (# _ : squash (maybe_emp_dep framed_g frame_g)) (#pr:a -> prop) (#p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req_opaque req_f ens_f req_g frame_f frame_g p1) (bind_ens_opaque req_f ens_f ens_g frame_f frame_g post p1 p2) #push-options "--z3rlimit 20" let bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem (pre_f `star` frame_f) (core_mem m0) in let x = frame00 f frame_f frame in let m1 = nmst_get () in let h1 = mk_rmem (post_f x `star` frame_f) (core_mem m1) in let h1' = mk_rmem (pre_g x `star` frame_g x) (core_mem m1) in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); focus_is_restrict_mk_rmem (post_f x `star` frame_f) (pre_g x `star` frame_g x) (core_mem m1); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x) (core_mem m1); assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); can_be_split_3_interp (hp_of (post_f x `star` frame_f)) (hp_of (pre_g x `star` frame_g x)) frame (locks_invariant Set.empty m1) m1; let y = frame00 (g x) (frame_g x) frame in let m2 = nmst_get () in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); let h2' = mk_rmem (post_g x y `star` frame_g x) (core_mem m2) in let h2 = mk_rmem (post y) (core_mem m2) in // assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x) (core_mem m1); focus_is_restrict_mk_rmem (post_g x y `star` frame_g x) (post y) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (frame_g x) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (post_g x y) (core_mem m2); can_be_split_3_interp (hp_of (post_g x y `star` frame_g x)) (hp_of (post y)) frame (locks_invariant Set.empty m2) m2; y #pop-options let bind a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = norm_repr (bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g) unfold let subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : pure_pre = (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) val subcomp_opaque (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True) #push-options "--fuel 1 --ifuel 1 --z3rlimit 20" let subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #_ #p1 #p2 f = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem pre_g (core_mem m0) in can_be_split_trans pre_g (pre_f `star` fr) pre_f; can_be_split_trans pre_g (pre_f `star` fr) fr; can_be_split_3_interp (hp_of pre_g) (hp_of (pre_f `star` fr)) frame (locks_invariant Set.empty m0) m0; focus_replace pre_g (pre_f `star` fr) pre_f (core_mem m0); let x = frame00 f fr frame in let m1 = nmst_get () in let h1 = mk_rmem (post_g x) (core_mem m1) in let h0' = mk_rmem (pre_f `star` fr) (core_mem m0) in let h1' = mk_rmem (post_f x `star` fr) (core_mem m1) in // From frame00 assert (frame_opaque fr (focus_rmem h0' fr) (focus_rmem h1' fr)); // Replace h0'/h1' by h0/h1 focus_replace pre_g (pre_f `star` fr) fr (core_mem m0); focus_replace (post_g x) (post_f x `star` fr) fr (core_mem m1); assert (frame_opaque fr (focus_rmem h0 fr) (focus_rmem h1 fr)); can_be_split_trans (post_g x) (post_f x `star` fr) (post_f x); can_be_split_trans (post_g x) (post_f x `star` fr) fr; can_be_split_3_interp (hp_of (post_f x `star` fr)) (hp_of (post_g x)) frame (locks_invariant Set.empty m1) m1; focus_replace (post_g x) (post_f x `star` fr) (post_f x) (core_mem m1); x #pop-options let lemma_rewrite (p:Type) : Lemma (requires T.rewrite_with_tactic vc_norm p) (ensures p) = T.unfold_rewrite_with_tactic vc_norm p let lemma_norm_opaque (p:Type) : Lemma (requires norm_opaque p) (ensures p) = () (** Need to manually remove the rewrite_with_tactic marker here *) let lemma_subcomp_pre_opaque_aux1 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) = lemma_rewrite (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) #push-options "--no_tactics" let lemma_subcomp_pre_opaque_aux2 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_norm_opaque (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) let lemma_subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr : prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_subcomp_pre_opaque_aux1 req_f ens_f req_g ens_g p1 p2; lemma_subcomp_pre_opaque_aux2 req_f ens_f req_g ens_g p1 p2 #pop-options let subcomp a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #pr #p1 #p2 f = lemma_subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2; subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #pr #_ #p1 #p2 f let bind_pure_steel_ a b #wp #pre #post #req #ens f g = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun frame -> let x = f () in g x frame (* We need a bind with DIV to implement par, using reification *) unfold let bind_div_steel_req (#a:Type) (wp:pure_wp a) (#pre_g:pre_t) (req_g:a -> req_t pre_g) : req_t pre_g = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun h -> wp (fun _ -> True) /\ (forall x. (req_g x) h) unfold let bind_div_steel_ens (#a:Type) (#b:Type) (wp:pure_wp a) (#pre_g:pre_t) (#post_g:post_t b) (ens_g:a -> ens_t pre_g b post_g) : ens_t pre_g b post_g = fun h0 r h1 -> wp (fun _ -> True) /\ (exists x. ens_g x h0 r h1) #push-options "--z3rlimit 20 --fuel 2 --ifuel 1" let bind_div_steel (a:Type) (b:Type) (wp:pure_wp a) (framed:eqtype_as_type bool) (pre_g:pre_t) (post_g:post_t b) (req_g:a -> req_t pre_g) (ens_g:a -> ens_t pre_g b post_g) (f:eqtype_as_type unit -> DIV a wp) (g:(x:a -> repr b framed pre_g post_g (req_g x) (ens_g x))) : repr b framed pre_g post_g (bind_div_steel_req wp req_g)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bind_div_steel (a b: Type) (wp: pure_wp a) (framed: eqtype_as_type bool) (pre_g: pre_t) (post_g: post_t b) (req_g: (a -> req_t pre_g)) (ens_g: (a -> ens_t pre_g b post_g)) (f: (eqtype_as_type unit -> DIV a wp)) (g: (x: a -> repr b framed pre_g post_g (req_g x) (ens_g x))) : repr b framed pre_g post_g (bind_div_steel_req wp req_g) (bind_div_steel_ens wp ens_g)
[]
Steel.Effect.bind_div_steel
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Type -> b: Type -> wp: Prims.pure_wp a -> framed: FStar.Pervasives.eqtype_as_type Prims.bool -> pre_g: Steel.Effect.Common.pre_t -> post_g: Steel.Effect.Common.post_t b -> req_g: (_: a -> Steel.Effect.Common.req_t pre_g) -> ens_g: (_: a -> Steel.Effect.Common.ens_t pre_g b post_g) -> f: (_: FStar.Pervasives.eqtype_as_type Prims.unit -> FStar.Pervasives.DIV a) -> g: (x: a -> Steel.Effect.repr b framed pre_g post_g (req_g x) (ens_g x)) -> Steel.Effect.repr b framed pre_g post_g (Steel.Effect.bind_div_steel_req wp req_g) (Steel.Effect.bind_div_steel_ens wp ens_g)
{ "end_col": 11, "end_line": 665, "start_col": 2, "start_line": 662 }
Prims.Pure
val subcomp (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let subcomp a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #pr #p1 #p2 f = lemma_subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2; subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #pr #_ #p1 #p2 f
val subcomp (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True) let subcomp a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #pr #p1 #p2 f =
false
null
false
lemma_subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2; subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #pr #_ #p1 #p2 f
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[]
[ "FStar.Pervasives.eqtype_as_type", "Prims.bool", "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.req_t", "Steel.Effect.Common.ens_t", "Steel.Effect.Common.vprop", "Prims.squash", "Steel.Effect.Common.maybe_emp", "Prims.prop", "Steel.Effect.Common.can_be_split_dep", "Steel.Effect.Common.star", "Steel.Effect.Common.equiv_forall", "Steel.Effect.repr", "Steel.Effect.subcomp_opaque", "Prims.unit", "Steel.Effect.lemma_subcomp_pre_opaque" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f unfold let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) unfold let bind_ens_opaque (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_opaque (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) val bind_opaque (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#pre_f:pre_t) (#post_f:post_t a) (#req_f:req_t pre_f) (#ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#req_g:(x:a -> req_t (pre_g x))) (#ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#frame_f:vprop) (#frame_g:a -> vprop) (#post:post_t b) (# _ : squash (maybe_emp framed_f frame_f)) (# _ : squash (maybe_emp_dep framed_g frame_g)) (#pr:a -> prop) (#p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req_opaque req_f ens_f req_g frame_f frame_g p1) (bind_ens_opaque req_f ens_f ens_g frame_f frame_g post p1 p2) #push-options "--z3rlimit 20" let bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem (pre_f `star` frame_f) (core_mem m0) in let x = frame00 f frame_f frame in let m1 = nmst_get () in let h1 = mk_rmem (post_f x `star` frame_f) (core_mem m1) in let h1' = mk_rmem (pre_g x `star` frame_g x) (core_mem m1) in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); focus_is_restrict_mk_rmem (post_f x `star` frame_f) (pre_g x `star` frame_g x) (core_mem m1); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x) (core_mem m1); assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); can_be_split_3_interp (hp_of (post_f x `star` frame_f)) (hp_of (pre_g x `star` frame_g x)) frame (locks_invariant Set.empty m1) m1; let y = frame00 (g x) (frame_g x) frame in let m2 = nmst_get () in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); let h2' = mk_rmem (post_g x y `star` frame_g x) (core_mem m2) in let h2 = mk_rmem (post y) (core_mem m2) in // assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x) (core_mem m1); focus_is_restrict_mk_rmem (post_g x y `star` frame_g x) (post y) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (frame_g x) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (post_g x y) (core_mem m2); can_be_split_3_interp (hp_of (post_g x y `star` frame_g x)) (hp_of (post y)) frame (locks_invariant Set.empty m2) m2; y #pop-options let bind a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = norm_repr (bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g) unfold let subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : pure_pre = (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) val subcomp_opaque (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True) #push-options "--fuel 1 --ifuel 1 --z3rlimit 20" let subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #_ #p1 #p2 f = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem pre_g (core_mem m0) in can_be_split_trans pre_g (pre_f `star` fr) pre_f; can_be_split_trans pre_g (pre_f `star` fr) fr; can_be_split_3_interp (hp_of pre_g) (hp_of (pre_f `star` fr)) frame (locks_invariant Set.empty m0) m0; focus_replace pre_g (pre_f `star` fr) pre_f (core_mem m0); let x = frame00 f fr frame in let m1 = nmst_get () in let h1 = mk_rmem (post_g x) (core_mem m1) in let h0' = mk_rmem (pre_f `star` fr) (core_mem m0) in let h1' = mk_rmem (post_f x `star` fr) (core_mem m1) in // From frame00 assert (frame_opaque fr (focus_rmem h0' fr) (focus_rmem h1' fr)); // Replace h0'/h1' by h0/h1 focus_replace pre_g (pre_f `star` fr) fr (core_mem m0); focus_replace (post_g x) (post_f x `star` fr) fr (core_mem m1); assert (frame_opaque fr (focus_rmem h0 fr) (focus_rmem h1 fr)); can_be_split_trans (post_g x) (post_f x `star` fr) (post_f x); can_be_split_trans (post_g x) (post_f x `star` fr) fr; can_be_split_3_interp (hp_of (post_f x `star` fr)) (hp_of (post_g x)) frame (locks_invariant Set.empty m1) m1; focus_replace (post_g x) (post_f x `star` fr) (post_f x) (core_mem m1); x #pop-options let lemma_rewrite (p:Type) : Lemma (requires T.rewrite_with_tactic vc_norm p) (ensures p) = T.unfold_rewrite_with_tactic vc_norm p let lemma_norm_opaque (p:Type) : Lemma (requires norm_opaque p) (ensures p) = () (** Need to manually remove the rewrite_with_tactic marker here *) let lemma_subcomp_pre_opaque_aux1 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) = lemma_rewrite (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) #push-options "--no_tactics" let lemma_subcomp_pre_opaque_aux2 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_norm_opaque (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) let lemma_subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr : prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_subcomp_pre_opaque_aux1 req_f ens_f req_g ens_g p1 p2; lemma_subcomp_pre_opaque_aux2 req_f ens_f req_g ens_g p1 p2 #pop-options
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val subcomp (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True)
[]
Steel.Effect.subcomp
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Type -> f: Steel.Effect.repr a framed_f pre_f post_f req_f ens_f -> Prims.Pure (Steel.Effect.repr a framed_g pre_g post_g req_g ens_g)
{ "end_col": 117, "end_line": 629, "start_col": 2, "start_line": 628 }
FStar.Pervasives.Lemma
val focus_is_restrict_mk_rmem (fp0 fp1: vprop) (m: hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1)
val focus_is_restrict_mk_rmem (fp0 fp1: vprop) (m: hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) let focus_is_restrict_mk_rmem (fp0 fp1: vprop) (m: hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) =
false
null
true
let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r: vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0: vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1)
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "lemma" ]
[ "Steel.Effect.Common.vprop", "Steel.Effect.Common.hmem", "FStar.FunctionalExtensionality.extensionality_g", "Steel.Effect.Common.can_be_split", "Steel.Effect.Common.normal", "Steel.Effect.Common.t_of", "Steel.Effect.Common.mk_rmem", "Steel.Effect.Common.focus_rmem", "Prims.unit", "FStar.Classical.forall_intro", "Prims.eq2", "Prims.l_True", "Prims.squash", "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.delta_only", "FStar.Pervasives.delta_qualifier", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "FStar.Pervasives.simplify", "FStar.Pervasives.pattern", "Steel.Effect.reveal_focus_rmem", "Steel.Effect.Common.reveal_mk_rmem", "Steel.Effect.Common.can_be_split_trans", "Steel.Effect.Common.rmem'", "Steel.Effect.Common.valid_rmem", "Steel.Effect.Common.rmem" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val focus_is_restrict_mk_rmem (fp0 fp1: vprop) (m: hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m)
[]
Steel.Effect.focus_is_restrict_mk_rmem
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
fp0: Steel.Effect.Common.vprop -> fp1: Steel.Effect.Common.vprop -> m: Steel.Effect.Common.hmem fp0 -> FStar.Pervasives.Lemma (requires Steel.Effect.Common.can_be_split fp0 fp1) (ensures Steel.Effect.Common.focus_rmem (Steel.Effect.Common.mk_rmem fp0 m) fp1 == Steel.Effect.Common.mk_rmem fp1 m)
{ "end_col": 38, "end_line": 98, "start_col": 3, "start_line": 82 }
FStar.Pervasives.Lemma
val focus_focus_is_focus (fp0 fp1 fp2: vprop) (m: hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21
val focus_focus_is_focus (fp0 fp1 fp2: vprop) (m: hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) let focus_focus_is_focus (fp0 fp1 fp2: vprop) (m: hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) =
false
null
true
let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r: vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0: vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "lemma" ]
[ "Steel.Effect.Common.vprop", "Steel.Effect.Common.hmem", "FStar.FunctionalExtensionality.extensionality_g", "Steel.Effect.Common.can_be_split", "Steel.Effect.Common.normal", "Steel.Effect.Common.t_of", "Prims.unit", "FStar.Classical.forall_intro", "Prims.eq2", "Prims.l_True", "Prims.squash", "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.delta_only", "FStar.Pervasives.delta_qualifier", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "FStar.Pervasives.simplify", "FStar.Pervasives.pattern", "Steel.Effect.reveal_focus_rmem", "Steel.Effect.Common.reveal_mk_rmem", "Steel.Effect.Common.rmem'", "Steel.Effect.Common.valid_rmem", "Steel.Effect.Common.focus_rmem", "Steel.Effect.Common.mk_rmem", "Prims.l_and", "Steel.Effect.Common.rmem" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val focus_focus_is_focus (fp0 fp1 fp2: vprop) (m: hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2)
[]
Steel.Effect.focus_focus_is_focus
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
fp0: Steel.Effect.Common.vprop -> fp1: Steel.Effect.Common.vprop -> fp2: Steel.Effect.Common.vprop -> m: Steel.Effect.Common.hmem fp0 -> FStar.Pervasives.Lemma (requires Steel.Effect.Common.can_be_split fp0 fp1 /\ Steel.Effect.Common.can_be_split fp1 fp2 ) (ensures Steel.Effect.Common.focus_rmem (Steel.Effect.Common.focus_rmem (Steel.Effect.Common.mk_rmem fp0 m) fp1) fp2 == Steel.Effect.Common.focus_rmem (Steel.Effect.Common.mk_rmem fp0 m) fp2)
{ "end_col": 13, "end_line": 120, "start_col": 3, "start_line": 104 }
Prims.Tot
val action_as_repr (#a: Type) (#p: slprop) (#q: (a -> slprop)) (f: action_except a Set.empty p q) : repr a false (to_vprop p) (fun x -> to_vprop (q x)) (fun _ -> True) (fun _ _ _ -> True)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let action_as_repr (#a:Type) (#p:slprop) (#q:a -> slprop) (f:action_except a Set.empty p q) : repr a false (to_vprop p) (fun x -> to_vprop (q x)) (fun _ -> True) (fun _ _ _ -> True) = Steel.Semantics.Instantiate.state_correspondence Set.empty; f
val action_as_repr (#a: Type) (#p: slprop) (#q: (a -> slprop)) (f: action_except a Set.empty p q) : repr a false (to_vprop p) (fun x -> to_vprop (q x)) (fun _ -> True) (fun _ _ _ -> True) let action_as_repr (#a: Type) (#p: slprop) (#q: (a -> slprop)) (f: action_except a Set.empty p q) : repr a false (to_vprop p) (fun x -> to_vprop (q x)) (fun _ -> True) (fun _ _ _ -> True) =
false
null
false
Steel.Semantics.Instantiate.state_correspondence Set.empty; f
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "total" ]
[ "Steel.Memory.slprop", "Steel.Memory.action_except", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Prims.unit", "Steel.Semantics.Instantiate.state_correspondence", "Steel.Effect.repr", "Steel.Effect.Common.to_vprop", "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem", "Prims.l_True" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f unfold let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) unfold let bind_ens_opaque (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_opaque (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) val bind_opaque (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#pre_f:pre_t) (#post_f:post_t a) (#req_f:req_t pre_f) (#ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#req_g:(x:a -> req_t (pre_g x))) (#ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#frame_f:vprop) (#frame_g:a -> vprop) (#post:post_t b) (# _ : squash (maybe_emp framed_f frame_f)) (# _ : squash (maybe_emp_dep framed_g frame_g)) (#pr:a -> prop) (#p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req_opaque req_f ens_f req_g frame_f frame_g p1) (bind_ens_opaque req_f ens_f ens_g frame_f frame_g post p1 p2) #push-options "--z3rlimit 20" let bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem (pre_f `star` frame_f) (core_mem m0) in let x = frame00 f frame_f frame in let m1 = nmst_get () in let h1 = mk_rmem (post_f x `star` frame_f) (core_mem m1) in let h1' = mk_rmem (pre_g x `star` frame_g x) (core_mem m1) in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); focus_is_restrict_mk_rmem (post_f x `star` frame_f) (pre_g x `star` frame_g x) (core_mem m1); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x) (core_mem m1); assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); can_be_split_3_interp (hp_of (post_f x `star` frame_f)) (hp_of (pre_g x `star` frame_g x)) frame (locks_invariant Set.empty m1) m1; let y = frame00 (g x) (frame_g x) frame in let m2 = nmst_get () in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); let h2' = mk_rmem (post_g x y `star` frame_g x) (core_mem m2) in let h2 = mk_rmem (post y) (core_mem m2) in // assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x) (core_mem m1); focus_is_restrict_mk_rmem (post_g x y `star` frame_g x) (post y) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (frame_g x) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (post_g x y) (core_mem m2); can_be_split_3_interp (hp_of (post_g x y `star` frame_g x)) (hp_of (post y)) frame (locks_invariant Set.empty m2) m2; y #pop-options let bind a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = norm_repr (bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g) unfold let subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : pure_pre = (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) val subcomp_opaque (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True) #push-options "--fuel 1 --ifuel 1 --z3rlimit 20" let subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #_ #p1 #p2 f = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem pre_g (core_mem m0) in can_be_split_trans pre_g (pre_f `star` fr) pre_f; can_be_split_trans pre_g (pre_f `star` fr) fr; can_be_split_3_interp (hp_of pre_g) (hp_of (pre_f `star` fr)) frame (locks_invariant Set.empty m0) m0; focus_replace pre_g (pre_f `star` fr) pre_f (core_mem m0); let x = frame00 f fr frame in let m1 = nmst_get () in let h1 = mk_rmem (post_g x) (core_mem m1) in let h0' = mk_rmem (pre_f `star` fr) (core_mem m0) in let h1' = mk_rmem (post_f x `star` fr) (core_mem m1) in // From frame00 assert (frame_opaque fr (focus_rmem h0' fr) (focus_rmem h1' fr)); // Replace h0'/h1' by h0/h1 focus_replace pre_g (pre_f `star` fr) fr (core_mem m0); focus_replace (post_g x) (post_f x `star` fr) fr (core_mem m1); assert (frame_opaque fr (focus_rmem h0 fr) (focus_rmem h1 fr)); can_be_split_trans (post_g x) (post_f x `star` fr) (post_f x); can_be_split_trans (post_g x) (post_f x `star` fr) fr; can_be_split_3_interp (hp_of (post_f x `star` fr)) (hp_of (post_g x)) frame (locks_invariant Set.empty m1) m1; focus_replace (post_g x) (post_f x `star` fr) (post_f x) (core_mem m1); x #pop-options let lemma_rewrite (p:Type) : Lemma (requires T.rewrite_with_tactic vc_norm p) (ensures p) = T.unfold_rewrite_with_tactic vc_norm p let lemma_norm_opaque (p:Type) : Lemma (requires norm_opaque p) (ensures p) = () (** Need to manually remove the rewrite_with_tactic marker here *) let lemma_subcomp_pre_opaque_aux1 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) = lemma_rewrite (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) #push-options "--no_tactics" let lemma_subcomp_pre_opaque_aux2 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_norm_opaque (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) let lemma_subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr : prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_subcomp_pre_opaque_aux1 req_f ens_f req_g ens_g p1 p2; lemma_subcomp_pre_opaque_aux2 req_f ens_f req_g ens_g p1 p2 #pop-options let subcomp a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #pr #p1 #p2 f = lemma_subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2; subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #pr #_ #p1 #p2 f let bind_pure_steel_ a b #wp #pre #post #req #ens f g = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun frame -> let x = f () in g x frame (* We need a bind with DIV to implement par, using reification *) unfold let bind_div_steel_req (#a:Type) (wp:pure_wp a) (#pre_g:pre_t) (req_g:a -> req_t pre_g) : req_t pre_g = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun h -> wp (fun _ -> True) /\ (forall x. (req_g x) h) unfold let bind_div_steel_ens (#a:Type) (#b:Type) (wp:pure_wp a) (#pre_g:pre_t) (#post_g:post_t b) (ens_g:a -> ens_t pre_g b post_g) : ens_t pre_g b post_g = fun h0 r h1 -> wp (fun _ -> True) /\ (exists x. ens_g x h0 r h1) #push-options "--z3rlimit 20 --fuel 2 --ifuel 1" let bind_div_steel (a:Type) (b:Type) (wp:pure_wp a) (framed:eqtype_as_type bool) (pre_g:pre_t) (post_g:post_t b) (req_g:a -> req_t pre_g) (ens_g:a -> ens_t pre_g b post_g) (f:eqtype_as_type unit -> DIV a wp) (g:(x:a -> repr b framed pre_g post_g (req_g x) (ens_g x))) : repr b framed pre_g post_g (bind_div_steel_req wp req_g) (bind_div_steel_ens wp ens_g) = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun frame -> let x = f () in g x frame #pop-options polymonadic_bind (DIV, SteelBase) |> SteelBase = bind_div_steel #pop-options let par0 (#aL:Type u#a) (#preL:vprop) (#postL:aL -> vprop) (f:repr aL false preL postL (fun _ -> True) (fun _ _ _ -> True)) (#aR:Type u#a) (#preR:vprop) (#postR:aR -> vprop) (g:repr aR false preR postR (fun _ -> True) (fun _ _ _ -> True)) : SteelT (aL & aR) (preL `star` preR) (fun y -> postL (fst y) `star` postR (snd y)) = Steel?.reflect (fun frame -> Sem.run #state #_ #_ #_ #_ #_ frame (Sem.Par (Sem.Act f) (Sem.Act g))) (* * AR: Steel is not marked reifiable since we intend to run Steel programs natively * However to implement the par combinator we need to reify a Steel thunk to its repr * We could implement it better by having support for reification only in the .fst file * But for now assuming a (Dv) function *) assume val reify_steel_comp (#a:Type) (#framed:bool) (#pre:vprop) (#post:a -> vprop) (#req:req_t pre) (#ens:ens_t pre a post) ($f:unit -> SteelBase a framed pre post req ens) : Dv (repr a framed pre post req ens) let par f g = par0 (reify_steel_comp f) (reify_steel_comp g) let action_as_repr (#a:Type) (#p:slprop) (#q:a -> slprop) (f:action_except a Set.empty p q)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val action_as_repr (#a: Type) (#p: slprop) (#q: (a -> slprop)) (f: action_except a Set.empty p q) : repr a false (to_vprop p) (fun x -> to_vprop (q x)) (fun _ -> True) (fun _ _ _ -> True)
[]
Steel.Effect.action_as_repr
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
f: Steel.Memory.action_except a (FStar.Ghost.hide FStar.Set.empty) p q -> Steel.Effect.repr a false (Steel.Effect.Common.to_vprop p) (fun x -> Steel.Effect.Common.to_vprop (q x)) (fun _ -> Prims.l_True) (fun _ _ _ -> Prims.l_True)
{ "end_col": 65, "end_line": 696, "start_col": 4, "start_line": 696 }
FStar.Pervasives.Lemma
val lemma_subcomp_pre_opaque_aux1 (#a: Type) (#pre_f: pre_t) (#post_f: post_t a) (req_f: req_t pre_f) (ens_f: ens_t pre_f a post_f) (#pre_g: pre_t) (#post_g: post_t a) (req_g: req_t pre_g) (ens_g: ens_t pre_g a post_g) (#frame: vprop) (#pr: prop) (p1: squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2: squash (equiv_forall post_g (fun x -> (post_f x) `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures ((forall (h0: hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ (can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0: hmem pre_g) (x: a) (h1: hmem (post_g x)). (pr ==> (can_be_split_trans (post_g x) ((post_f x) `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) ((post_f x) `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1))))))
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_subcomp_pre_opaque_aux1 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) = lemma_rewrite (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) ))
val lemma_subcomp_pre_opaque_aux1 (#a: Type) (#pre_f: pre_t) (#post_f: post_t a) (req_f: req_t pre_f) (ens_f: ens_t pre_f a post_f) (#pre_g: pre_t) (#post_g: post_t a) (req_g: req_t pre_g) (ens_g: ens_t pre_g a post_g) (#frame: vprop) (#pr: prop) (p1: squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2: squash (equiv_forall post_g (fun x -> (post_f x) `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures ((forall (h0: hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ (can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0: hmem pre_g) (x: a) (h1: hmem (post_g x)). (pr ==> (can_be_split_trans (post_g x) ((post_f x) `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) ((post_f x) `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)))))) let lemma_subcomp_pre_opaque_aux1 (#a: Type) (#pre_f: pre_t) (#post_f: post_t a) (req_f: req_t pre_f) (ens_f: ens_t pre_f a post_f) (#pre_g: pre_t) (#post_g: post_t a) (req_g: req_t pre_g) (ens_g: ens_t pre_g a post_g) (#frame: vprop) (#pr: prop) (p1: squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2: squash (equiv_forall post_g (fun x -> (post_f x) `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures ((forall (h0: hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ (can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0: hmem pre_g) (x: a) (h1: hmem (post_g x)). (pr ==> (can_be_split_trans (post_g x) ((post_f x) `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) ((post_f x) `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)))))) =
false
null
true
lemma_rewrite (squash ((forall (h0: hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ (can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0: hmem pre_g) (x: a) (h1: hmem (post_g x)). (pr ==> (can_be_split_trans (post_g x) ((post_f x) `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) ((post_f x) `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1))))))
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[ "lemma" ]
[ "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.req_t", "Steel.Effect.Common.ens_t", "Steel.Effect.Common.vprop", "Prims.prop", "Prims.squash", "Steel.Effect.Common.can_be_split_dep", "Steel.Effect.Common.star", "Steel.Effect.Common.equiv_forall", "Steel.Effect.lemma_rewrite", "Prims.l_and", "Prims.l_Forall", "Steel.Effect.Common.hmem", "Prims.l_imp", "Steel.Effect.Common.mk_rmem", "Steel.Effect.Common.focus_rmem", "Prims.unit", "Steel.Effect.Common.can_be_split_trans", "Steel.Effect.Common.frame_equalities", "Steel.Effect.subcomp_pre", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f unfold let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) unfold let bind_ens_opaque (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_opaque (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) val bind_opaque (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#pre_f:pre_t) (#post_f:post_t a) (#req_f:req_t pre_f) (#ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#req_g:(x:a -> req_t (pre_g x))) (#ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#frame_f:vprop) (#frame_g:a -> vprop) (#post:post_t b) (# _ : squash (maybe_emp framed_f frame_f)) (# _ : squash (maybe_emp_dep framed_g frame_g)) (#pr:a -> prop) (#p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req_opaque req_f ens_f req_g frame_f frame_g p1) (bind_ens_opaque req_f ens_f ens_g frame_f frame_g post p1 p2) #push-options "--z3rlimit 20" let bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem (pre_f `star` frame_f) (core_mem m0) in let x = frame00 f frame_f frame in let m1 = nmst_get () in let h1 = mk_rmem (post_f x `star` frame_f) (core_mem m1) in let h1' = mk_rmem (pre_g x `star` frame_g x) (core_mem m1) in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); focus_is_restrict_mk_rmem (post_f x `star` frame_f) (pre_g x `star` frame_g x) (core_mem m1); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x) (core_mem m1); assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); can_be_split_3_interp (hp_of (post_f x `star` frame_f)) (hp_of (pre_g x `star` frame_g x)) frame (locks_invariant Set.empty m1) m1; let y = frame00 (g x) (frame_g x) frame in let m2 = nmst_get () in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); let h2' = mk_rmem (post_g x y `star` frame_g x) (core_mem m2) in let h2 = mk_rmem (post y) (core_mem m2) in // assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x) (core_mem m1); focus_is_restrict_mk_rmem (post_g x y `star` frame_g x) (post y) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (frame_g x) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (post_g x y) (core_mem m2); can_be_split_3_interp (hp_of (post_g x y `star` frame_g x)) (hp_of (post y)) frame (locks_invariant Set.empty m2) m2; y #pop-options let bind a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = norm_repr (bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g) unfold let subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : pure_pre = (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) val subcomp_opaque (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True) #push-options "--fuel 1 --ifuel 1 --z3rlimit 20" let subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #_ #p1 #p2 f = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem pre_g (core_mem m0) in can_be_split_trans pre_g (pre_f `star` fr) pre_f; can_be_split_trans pre_g (pre_f `star` fr) fr; can_be_split_3_interp (hp_of pre_g) (hp_of (pre_f `star` fr)) frame (locks_invariant Set.empty m0) m0; focus_replace pre_g (pre_f `star` fr) pre_f (core_mem m0); let x = frame00 f fr frame in let m1 = nmst_get () in let h1 = mk_rmem (post_g x) (core_mem m1) in let h0' = mk_rmem (pre_f `star` fr) (core_mem m0) in let h1' = mk_rmem (post_f x `star` fr) (core_mem m1) in // From frame00 assert (frame_opaque fr (focus_rmem h0' fr) (focus_rmem h1' fr)); // Replace h0'/h1' by h0/h1 focus_replace pre_g (pre_f `star` fr) fr (core_mem m0); focus_replace (post_g x) (post_f x `star` fr) fr (core_mem m1); assert (frame_opaque fr (focus_rmem h0 fr) (focus_rmem h1 fr)); can_be_split_trans (post_g x) (post_f x `star` fr) (post_f x); can_be_split_trans (post_g x) (post_f x `star` fr) fr; can_be_split_3_interp (hp_of (post_f x `star` fr)) (hp_of (post_g x)) frame (locks_invariant Set.empty m1) m1; focus_replace (post_g x) (post_f x `star` fr) (post_f x) (core_mem m1); x #pop-options let lemma_rewrite (p:Type) : Lemma (requires T.rewrite_with_tactic vc_norm p) (ensures p) = T.unfold_rewrite_with_tactic vc_norm p let lemma_norm_opaque (p:Type) : Lemma (requires norm_opaque p) (ensures p) = () (** Need to manually remove the rewrite_with_tactic marker here *) let lemma_subcomp_pre_opaque_aux1 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1))
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_subcomp_pre_opaque_aux1 (#a: Type) (#pre_f: pre_t) (#post_f: post_t a) (req_f: req_t pre_f) (ens_f: ens_t pre_f a post_f) (#pre_g: pre_t) (#post_g: post_t a) (req_g: req_t pre_g) (ens_g: ens_t pre_g a post_g) (#frame: vprop) (#pr: prop) (p1: squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2: squash (equiv_forall post_g (fun x -> (post_f x) `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures ((forall (h0: hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ (can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0: hmem pre_g) (x: a) (h1: hmem (post_g x)). (pr ==> (can_be_split_trans (post_g x) ((post_f x) `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) ((post_f x) `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1))))))
[]
Steel.Effect.lemma_subcomp_pre_opaque_aux1
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
req_f: Steel.Effect.Common.req_t pre_f -> ens_f: Steel.Effect.Common.ens_t pre_f a post_f -> req_g: Steel.Effect.Common.req_t pre_g -> ens_g: Steel.Effect.Common.ens_t pre_g a post_g -> p1: Prims.squash (Steel.Effect.Common.can_be_split_dep pr pre_g (Steel.Effect.Common.star pre_f frame)) -> p2: Prims.squash (Steel.Effect.Common.equiv_forall post_g (fun x -> Steel.Effect.Common.star (post_f x) frame)) -> FStar.Pervasives.Lemma (requires Steel.Effect.subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures (forall (h0: Steel.Effect.Common.hmem pre_g). req_g (Steel.Effect.Common.mk_rmem pre_g h0) ==> pr /\ ([@@ FStar.Pervasives.inline_let ]let _ = Steel.Effect.Common.can_be_split_trans pre_g (Steel.Effect.Common.star pre_f frame) pre_f in req_f (Steel.Effect.Common.focus_rmem (Steel.Effect.Common.mk_rmem pre_g h0) pre_f))) /\ (forall (h0: Steel.Effect.Common.hmem pre_g) (x: a) (h1: Steel.Effect.Common.hmem (post_g x)). pr ==> ([@@ FStar.Pervasives.inline_let ]let _ = Steel.Effect.Common.can_be_split_trans (post_g x) (Steel.Effect.Common.star (post_f x) frame) (post_f x) in [@@ FStar.Pervasives.inline_let ]let _ = Steel.Effect.Common.can_be_split_trans pre_g (Steel.Effect.Common.star pre_f frame) frame in [@@ FStar.Pervasives.inline_let ]let _ = Steel.Effect.Common.can_be_split_trans (post_g x) (Steel.Effect.Common.star (post_f x) frame) frame in [@@ FStar.Pervasives.inline_let ]let _ = Steel.Effect.Common.can_be_split_trans pre_g (Steel.Effect.Common.star pre_f frame) pre_f in req_g (Steel.Effect.Common.mk_rmem pre_g h0) /\ ens_f (Steel.Effect.Common.focus_rmem (Steel.Effect.Common.mk_rmem pre_g h0) pre_f) x (Steel.Effect.Common.focus_rmem (Steel.Effect.Common.mk_rmem (post_g x) h1) (post_f x)) /\ Steel.Effect.Common.frame_equalities frame (Steel.Effect.Common.focus_rmem (Steel.Effect.Common.mk_rmem pre_g h0) frame) (Steel.Effect.Common.focus_rmem (Steel.Effect.Common.mk_rmem (post_g x) h1) frame) ==> ens_g (Steel.Effect.Common.mk_rmem pre_g h0) x (Steel.Effect.Common.mk_rmem (post_g x) h1))))
{ "end_col": 6, "end_line": 552, "start_col": 4, "start_line": 533 }
Steel.Effect.SteelT
val par0 (#aL: Type u#a) (#preL: vprop) (#postL: (aL -> vprop)) (f: repr aL false preL postL (fun _ -> True) (fun _ _ _ -> True)) (#aR: Type u#a) (#preR: vprop) (#postR: (aR -> vprop)) (g: repr aR false preR postR (fun _ -> True) (fun _ _ _ -> True)) : SteelT (aL & aR) (preL `star` preR) (fun y -> (postL (fst y)) `star` (postR (snd y)))
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let par0 (#aL:Type u#a) (#preL:vprop) (#postL:aL -> vprop) (f:repr aL false preL postL (fun _ -> True) (fun _ _ _ -> True)) (#aR:Type u#a) (#preR:vprop) (#postR:aR -> vprop) (g:repr aR false preR postR (fun _ -> True) (fun _ _ _ -> True)) : SteelT (aL & aR) (preL `star` preR) (fun y -> postL (fst y) `star` postR (snd y)) = Steel?.reflect (fun frame -> Sem.run #state #_ #_ #_ #_ #_ frame (Sem.Par (Sem.Act f) (Sem.Act g)))
val par0 (#aL: Type u#a) (#preL: vprop) (#postL: (aL -> vprop)) (f: repr aL false preL postL (fun _ -> True) (fun _ _ _ -> True)) (#aR: Type u#a) (#preR: vprop) (#postR: (aR -> vprop)) (g: repr aR false preR postR (fun _ -> True) (fun _ _ _ -> True)) : SteelT (aL & aR) (preL `star` preR) (fun y -> (postL (fst y)) `star` (postR (snd y))) let par0 (#aL: Type u#a) (#preL: vprop) (#postL: (aL -> vprop)) (f: repr aL false preL postL (fun _ -> True) (fun _ _ _ -> True)) (#aR: Type u#a) (#preR: vprop) (#postR: (aR -> vprop)) (g: repr aR false preR postR (fun _ -> True) (fun _ _ _ -> True)) : SteelT (aL & aR) (preL `star` preR) (fun y -> (postL (fst y)) `star` (postR (snd y))) =
true
null
false
Steel?.reflect (fun frame -> Sem.run #state #_ #_ #_ #_ #_ frame (Sem.Par (Sem.Act f) (Sem.Act g)))
{ "checked_file": "Steel.Effect.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.NMST.fst.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.fst" }
[]
[ "Steel.Effect.Common.vprop", "Steel.Effect.repr", "Steel.Effect.Common.rmem", "Prims.l_True", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__hprop", "Steel.Semantics.Instantiate.state", "Steel.Semantics.Hoare.MST.run", "FStar.Pervasives.Native.tuple2", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__star", "Steel.Effect.Common.hp_of", "Steel.Effect.to_post", "Steel.Semantics.Hoare.MST.par_lpre", "Steel.Effect.req_to_act_req", "Steel.Semantics.Hoare.MST.par_lpost", "Steel.Effect.ens_to_act_ens", "Steel.Semantics.Hoare.MST.Par", "Steel.Semantics.Hoare.MST.Act", "Steel.Effect.Common.star", "FStar.Pervasives.Native.fst", "FStar.Pervasives.Native.snd" ]
[]
(* 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.Effect module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality #set-options "--ide_id_info_off" let _:squash (forall p q. can_be_split p q == Mem.slimp (hp_of p) (hp_of q)) = reveal_can_be_split () #set-options "--warn_error -330" //turn off the experimental feature warning let rmem_depends_only_on' (pre:pre_t) (m0:hmem pre) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro (reveal_mk_rmem pre m0); Classical.forall_intro (reveal_mk_rmem pre (join m0 m1)); FExt.extensionality_g (r0:vprop{can_be_split pre r0}) (fun r0 -> normal (t_of r0)) (mk_rmem pre m0) (mk_rmem pre (join m0 m1)) let rmem_depends_only_on (pre:pre_t) : Lemma (forall (m0:hmem pre) (m1:mem{disjoint m0 m1}). mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro_2 (rmem_depends_only_on' pre) let rmem_depends_only_on_post' (#a:Type) (post:post_t a) (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}) : Lemma (mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = rmem_depends_only_on' (post x) m0 m1 let rmem_depends_only_on_post (#a:Type) (post:post_t a) : Lemma (forall (x:a) (m0:hmem (post x)) (m1:mem{disjoint m0 m1}). mk_rmem (post x) m0 == mk_rmem (post x) (join m0 m1)) = Classical.forall_intro_3 (rmem_depends_only_on_post' post) [@@ __steel_reduce__] let req_to_act_req (#pre:pre_t) (req:req_t pre) : Sem.l_pre #state (hp_of pre) = rmem_depends_only_on pre; fun m0 -> interp (hp_of pre) m0 /\ req (mk_rmem pre m0) unfold let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x)) [@@ __steel_reduce__] let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post) : Sem.l_post #state #a (hp_of pre) (to_post post) = rmem_depends_only_on pre; rmem_depends_only_on_post post; fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\ ens (mk_rmem pre m0) x (mk_rmem (post x) m1) let reveal_focus_rmem (#r:vprop) (h:rmem r) (r0:vprop{r `can_be_split` r0}) (r':vprop{r0 `can_be_split` r'}) : Lemma ( r `can_be_split` r' /\ focus_rmem h r0 r' == h r') = can_be_split_trans r r0 r'; FExt.feq_on_domain_g (unrestricted_focus_rmem h r0) let focus_is_restrict_mk_rmem (fp0 fp1:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1) (ensures focus_rmem (mk_rmem fp0 m) fp1 == mk_rmem fp1 m) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f2:rmem fp1 = focus_rmem f0 fp1 in let aux (r:vprop{can_be_split fp1 r}) : Lemma (f1 r == f2 r) = can_be_split_trans fp0 fp1 r; reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp1 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp1 r0}) (fun r0 -> normal (t_of r0)) (mk_rmem fp1 m) (focus_rmem (mk_rmem fp0 m) fp1) let focus_focus_is_focus (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (focus_rmem (mk_rmem fp0 m) fp1) fp2 == focus_rmem (mk_rmem fp0 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = focus_rmem f0 fp1 in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_focus_rmem f0 fp1 r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 let focus_replace (fp0 fp1 fp2:vprop) (m:hmem fp0) : Lemma (requires fp0 `can_be_split` fp1 /\ fp1 `can_be_split` fp2) (ensures focus_rmem (mk_rmem fp0 m) fp2 == focus_rmem (mk_rmem fp1 m) fp2) = let f0:rmem fp0 = mk_rmem fp0 m in let f1:rmem fp1 = mk_rmem fp1 m in let f20:rmem fp2 = focus_rmem f0 fp2 in let f21:rmem fp2 = focus_rmem f1 fp2 in let aux (r:vprop{can_be_split fp2 r}) : Lemma (f20 r == f21 r) = reveal_mk_rmem fp0 m r; reveal_mk_rmem fp1 m r; reveal_focus_rmem f0 fp2 r; reveal_focus_rmem f1 fp2 r in Classical.forall_intro aux; FExt.extensionality_g (r0:vprop{can_be_split fp2 r0}) (fun r0 -> normal (t_of r0)) f20 f21 val can_be_split_3_interp (p1 p2 q r:slprop u#1) (m:mem) : Lemma (requires p1 `slimp` p2 /\ interp (p1 `Mem.star` q `Mem.star` r) m) (ensures interp (p2 `Mem.star` q `Mem.star` r) m) let can_be_split_3_interp p1 p2 q r m = Mem.star_associative p1 q r; Mem.star_associative p2 q r; slimp_star p1 p2 (q `Mem.star` r) (q `Mem.star` r) let repr (a:Type) (_:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) = Sem.action_t #state #a (hp_of pre) (to_post post) ((req_to_act_req req)) ((ens_to_act_ens ens)) let nmst_get (#st:Sem.st) () : Sem.Mst (Sem.full_mem st) (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMST.get () let rec lemma_frame_equalities_refl (frame:vprop) (h:rmem frame) : Lemma (frame_equalities frame h h) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h1 = focus_rmem h p1 in let h2 = focus_rmem h p2 in lemma_frame_equalities_refl p1 h1; lemma_frame_equalities_refl p2 h2 let return_ a x #p = fun _ -> let m0 = nmst_get () in let h0 = mk_rmem (p x) (core_mem m0) in lemma_frame_equalities_refl (p x) h0; x #push-options "--fuel 0 --ifuel 0" val req_frame (frame:vprop) (snap:rmem frame) : mprop (hp_of frame) let req_frame' (frame:vprop) (snap:rmem frame) (m:mem) : prop = interp (hp_of frame) m /\ mk_rmem frame m == snap let req_frame frame snap = rmem_depends_only_on frame; req_frame' frame snap #push-options "--z3rlimit 50 --fuel 1 --ifuel 0" let frame_opaque frame h0 h1 = frame_equalities frame h0 h1 unfold let norm_opaque = norm [delta_only [`%frame_opaque]] let lemma_frame_opaque_refl (frame:vprop) (h:rmem frame) : Lemma (frame_opaque frame h h) = assert (frame_opaque frame h h) by ( T.norm [delta_only [`%frame_opaque]]; T.apply_lemma (`lemma_frame_equalities_refl)) val frame00 (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) ($f:repr a framed pre post req ens) (frame:vprop) : repr a true (pre `star` frame) (fun x -> post x `star` frame) (fun h -> req (focus_rmem h pre)) (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\ frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame)) let frame00 #a #framed #pre #post #req #ens f frame = fun frame' -> let m0 = nmst_get () in let snap:rmem frame = mk_rmem frame (core_mem m0) in focus_is_restrict_mk_rmem (pre `star` frame) pre (core_mem m0); assert (state.interp (((hp_of pre `state.star` hp_of frame) `state.star` frame' `state.star` state.locks_invariant m0)) m0); let req' = (Steel.Semantics.Hoare.MST.frame_lpre #Steel.Semantics.Instantiate.state #(Steel.Effect.Common.hp_of pre) (req_to_act_req #pre req) #(Steel.Effect.Common.hp_of frame) (req_frame frame snap)) in assert (req' (state.core m0)); let x = Sem.run #state #_ #_ #_ #_ #_ frame' (Sem.Frame (Sem.Act f) (hp_of frame) (req_frame frame snap)) in let m1 = nmst_get () in can_be_split_star_r pre frame; focus_is_restrict_mk_rmem (pre `star` frame) frame (core_mem m0); can_be_split_star_r (post x) frame; focus_is_restrict_mk_rmem (post x `star` frame) frame (core_mem m1); focus_is_restrict_mk_rmem (post x `star` frame) (post x) (core_mem m1); // We proved focus_rmem h0 frame == focus_rmem h1 frame so far let h0:rmem (pre `star` frame) = mk_rmem (pre `star` frame) (core_mem m0) in lemma_frame_opaque_refl frame (focus_rmem h0 frame); x #pop-options let norm_repr (#a:Type) (#framed:bool) (#pre:pre_t) (#post:post_t a) (#req:req_t pre) (#ens:ens_t pre a post) (f:repr a framed pre post req ens) : repr a framed pre post (fun h -> norm_opaque (req h)) (fun h0 x h1 -> norm_opaque (ens h0 x h1)) = f unfold let bind_req_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) unfold let bind_ens_opaque (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_opaque frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_opaque (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) val bind_opaque (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#pre_f:pre_t) (#post_f:post_t a) (#req_f:req_t pre_f) (#ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#req_g:(x:a -> req_t (pre_g x))) (#ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#frame_f:vprop) (#frame_g:a -> vprop) (#post:post_t b) (# _ : squash (maybe_emp framed_f frame_f)) (# _ : squash (maybe_emp_dep framed_g frame_g)) (#pr:a -> prop) (#p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req_opaque req_f ens_f req_g frame_f frame_g p1) (bind_ens_opaque req_f ens_f ens_g frame_f frame_g post p1 p2) #push-options "--z3rlimit 20" let bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem (pre_f `star` frame_f) (core_mem m0) in let x = frame00 f frame_f frame in let m1 = nmst_get () in let h1 = mk_rmem (post_f x `star` frame_f) (core_mem m1) in let h1' = mk_rmem (pre_g x `star` frame_g x) (core_mem m1) in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); focus_is_restrict_mk_rmem (post_f x `star` frame_f) (pre_g x `star` frame_g x) (core_mem m1); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x) (core_mem m1); assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); can_be_split_3_interp (hp_of (post_f x `star` frame_f)) (hp_of (pre_g x `star` frame_g x)) frame (locks_invariant Set.empty m1) m1; let y = frame00 (g x) (frame_g x) frame in let m2 = nmst_get () in can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); let h2' = mk_rmem (post_g x y `star` frame_g x) (core_mem m2) in let h2 = mk_rmem (post y) (core_mem m2) in // assert (focus_rmem h1' (pre_g x) == focus_rmem h1 (pre_g x)); focus_focus_is_focus (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x) (core_mem m1); focus_is_restrict_mk_rmem (post_g x y `star` frame_g x) (post y) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (frame_g x) (core_mem m2); focus_focus_is_focus (post_g x y `star` frame_g x) (post y) (post_g x y) (core_mem m2); can_be_split_3_interp (hp_of (post_g x y `star` frame_g x)) (hp_of (post y)) frame (locks_invariant Set.empty m2) m2; y #pop-options let bind a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g = norm_repr (bind_opaque a b #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #frame_f #frame_g #post #_ #_ #p #p2 f g) unfold let subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : pure_pre = (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) val subcomp_opaque (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True) #push-options "--fuel 1 --ifuel 1 --z3rlimit 20" let subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #_ #p1 #p2 f = fun frame -> let m0 = nmst_get () in let h0 = mk_rmem pre_g (core_mem m0) in can_be_split_trans pre_g (pre_f `star` fr) pre_f; can_be_split_trans pre_g (pre_f `star` fr) fr; can_be_split_3_interp (hp_of pre_g) (hp_of (pre_f `star` fr)) frame (locks_invariant Set.empty m0) m0; focus_replace pre_g (pre_f `star` fr) pre_f (core_mem m0); let x = frame00 f fr frame in let m1 = nmst_get () in let h1 = mk_rmem (post_g x) (core_mem m1) in let h0' = mk_rmem (pre_f `star` fr) (core_mem m0) in let h1' = mk_rmem (post_f x `star` fr) (core_mem m1) in // From frame00 assert (frame_opaque fr (focus_rmem h0' fr) (focus_rmem h1' fr)); // Replace h0'/h1' by h0/h1 focus_replace pre_g (pre_f `star` fr) fr (core_mem m0); focus_replace (post_g x) (post_f x `star` fr) fr (core_mem m1); assert (frame_opaque fr (focus_rmem h0 fr) (focus_rmem h1 fr)); can_be_split_trans (post_g x) (post_f x `star` fr) (post_f x); can_be_split_trans (post_g x) (post_f x `star` fr) fr; can_be_split_3_interp (hp_of (post_f x `star` fr)) (hp_of (post_g x)) frame (locks_invariant Set.empty m1) m1; focus_replace (post_g x) (post_f x `star` fr) (post_f x) (core_mem m1); x #pop-options let lemma_rewrite (p:Type) : Lemma (requires T.rewrite_with_tactic vc_norm p) (ensures p) = T.unfold_rewrite_with_tactic vc_norm p let lemma_norm_opaque (p:Type) : Lemma (requires norm_opaque p) (ensures p) = () (** Need to manually remove the rewrite_with_tactic marker here *) let lemma_subcomp_pre_opaque_aux1 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) = lemma_rewrite (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) #push-options "--no_tactics" let lemma_subcomp_pre_opaque_aux2 (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )))) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_norm_opaque (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ ( can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_opaque frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) let lemma_subcomp_pre_opaque (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr : prop) (p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : Lemma (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2) = lemma_subcomp_pre_opaque_aux1 req_f ens_f req_g ens_g p1 p2; lemma_subcomp_pre_opaque_aux2 req_f ens_f req_g ens_g p1 p2 #pop-options let subcomp a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #_ #pr #p1 #p2 f = lemma_subcomp_pre_opaque req_f ens_f req_g ens_g p1 p2; subcomp_opaque a #framed_f #framed_g #pre_f #post_f #req_f #ens_f #pre_g #post_g #req_g #ens_g #fr #pr #_ #p1 #p2 f let bind_pure_steel_ a b #wp #pre #post #req #ens f g = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun frame -> let x = f () in g x frame (* We need a bind with DIV to implement par, using reification *) unfold let bind_div_steel_req (#a:Type) (wp:pure_wp a) (#pre_g:pre_t) (req_g:a -> req_t pre_g) : req_t pre_g = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun h -> wp (fun _ -> True) /\ (forall x. (req_g x) h) unfold let bind_div_steel_ens (#a:Type) (#b:Type) (wp:pure_wp a) (#pre_g:pre_t) (#post_g:post_t b) (ens_g:a -> ens_t pre_g b post_g) : ens_t pre_g b post_g = fun h0 r h1 -> wp (fun _ -> True) /\ (exists x. ens_g x h0 r h1) #push-options "--z3rlimit 20 --fuel 2 --ifuel 1" let bind_div_steel (a:Type) (b:Type) (wp:pure_wp a) (framed:eqtype_as_type bool) (pre_g:pre_t) (post_g:post_t b) (req_g:a -> req_t pre_g) (ens_g:a -> ens_t pre_g b post_g) (f:eqtype_as_type unit -> DIV a wp) (g:(x:a -> repr b framed pre_g post_g (req_g x) (ens_g x))) : repr b framed pre_g post_g (bind_div_steel_req wp req_g) (bind_div_steel_ens wp ens_g) = FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; fun frame -> let x = f () in g x frame #pop-options polymonadic_bind (DIV, SteelBase) |> SteelBase = bind_div_steel #pop-options let par0 (#aL:Type u#a) (#preL:vprop) (#postL:aL -> vprop) (f:repr aL false preL postL (fun _ -> True) (fun _ _ _ -> True)) (#aR:Type u#a) (#preR:vprop) (#postR:aR -> vprop) (g:repr aR false preR postR (fun _ -> True) (fun _ _ _ -> True)) : SteelT (aL & aR) (preL `star` preR)
false
false
Steel.Effect.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val par0 (#aL: Type u#a) (#preL: vprop) (#postL: (aL -> vprop)) (f: repr aL false preL postL (fun _ -> True) (fun _ _ _ -> True)) (#aR: Type u#a) (#preR: vprop) (#postR: (aR -> vprop)) (g: repr aR false preR postR (fun _ -> True) (fun _ _ _ -> True)) : SteelT (aL & aR) (preL `star` preR) (fun y -> (postL (fst y)) `star` (postR (snd y)))
[]
Steel.Effect.par0
{ "file_name": "lib/steel/Steel.Effect.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
f: Steel.Effect.repr aL false preL postL (fun _ -> Prims.l_True) (fun _ _ _ -> Prims.l_True) -> g: Steel.Effect.repr aR false preR postR (fun _ -> Prims.l_True) (fun _ _ _ -> Prims.l_True) -> Steel.Effect.SteelT (aL * aR)
{ "end_col": 103, "end_line": 678, "start_col": 4, "start_line": 678 }
Prims.Tot
val va_wp_Compute_ghash_incremental_register (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "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.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "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.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_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.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.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 } ]
false
let va_wp_Compute_ghash_incremental_register (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051) /\ (forall (va_x_xmm1:quad32) (va_x_efl:Vale.X64.Flags.t) (va_x_r12:nat64) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) . let va_sM = va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_reg64 rR12 va_x_r12 (va_upd_flags va_x_efl (va_upd_xmm 1 va_x_xmm1 va_s0))))))) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.AES.GHash.ghash_incremental (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_sM)) (va_get_xmm 1 va_s0) (FStar.Seq.Base.create #quad32 1 (va_get_xmm 2 va_s0)) ==> va_k va_sM (())))
val va_wp_Compute_ghash_incremental_register (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_Compute_ghash_incremental_register (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051) /\ (forall (va_x_xmm1: quad32) (va_x_efl: Vale.X64.Flags.t) (va_x_r12: nat64) (va_x_xmm2: quad32) (va_x_xmm3: quad32) (va_x_xmm4: quad32) (va_x_xmm5: quad32) (va_x_xmm6: quad32). let va_sM = va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_reg64 rR12 va_x_r12 (va_upd_flags va_x_efl (va_upd_xmm 1 va_x_xmm1 va_s0))))))) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.AES.GHash.ghash_incremental (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_sM)) (va_get_xmm 1 va_s0) (FStar.Seq.Base.create #quad32 1 (va_get_xmm 2 va_s0)) ==> va_k va_sM (())))
{ "checked_file": "Vale.AES.X64.GHash.fsti.checked", "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.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.X64.GHash.fsti" }
[ "total" ]
[ "Vale.X64.Decls.va_state", "Prims.unit", "Prims.l_and", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.X64.CPU_Features_s.pclmulqdq_enabled", "Vale.X64.CPU_Features_s.avx_enabled", "Vale.X64.CPU_Features_s.sse_enabled", "Prims.eq2", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat32", "Vale.X64.Decls.va_get_xmm", "Vale.Def.Words_s.Mkfour", "Prims.l_Forall", "Vale.X64.Decls.quad32", "Vale.X64.Flags.t", "Vale.X64.Memory.nat64", "Prims.l_imp", "Vale.Def.Types_s.quad32", "Vale.AES.GHash.ghash_incremental", "Vale.Def.Types_s.reverse_bytes_quad32", "FStar.Seq.Base.create", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_upd_xmm", "Vale.X64.Decls.va_upd_reg64", "Vale.X64.Machine_s.rR12", "Vale.X64.Decls.va_upd_flags" ]
[]
module Vale.AES.X64.GHash open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open Vale.Math.Poly2_s open Vale.Poly1305.Math open Vale.AES.X64.GF128_Mul 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.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 30" let get_last_slice_workaround (s:seq quad32) (start_pos end_pos:int) = if 0 <= start_pos && start_pos < end_pos && end_pos <= length s then last (slice s start_pos end_pos) else Mkfour 0 0 0 0 //let slice (s:seq quad32) (start_pos end_pos:int) = // if 0 <= start_pos && start_pos < end_pos && end_pos <= length s then // slice s start_pos end_pos // else // create 1 (Mkfour 0 0 0 0) //-- Compute_ghash_incremental_register val va_code_Compute_ghash_incremental_register : va_dummy:unit -> Tot va_code val va_codegen_success_Compute_ghash_incremental_register : va_dummy:unit -> Tot va_pbool val va_lemma_Compute_ghash_incremental_register : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Compute_ghash_incremental_register ()) va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.AES.GHash.ghash_incremental (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_sM)) (va_get_xmm 1 va_s0) (FStar.Seq.Base.create #quad32 1 (va_get_xmm 2 va_s0)) /\ va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0))))))))))) [@ va_qattr] let va_wp_Compute_ghash_incremental_register (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) :
false
true
Vale.AES.X64.GHash.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wp_Compute_ghash_incremental_register (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.AES.X64.GHash.va_wp_Compute_ghash_incremental_register
{ "file_name": "obj/Vale.AES.X64.GHash.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 10, "end_line": 69, "start_col": 2, "start_line": 60 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "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.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "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.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_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.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.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 } ]
false
let get_last_slice_workaround (s:seq quad32) (start_pos end_pos:int) = if 0 <= start_pos && start_pos < end_pos && end_pos <= length s then last (slice s start_pos end_pos) else Mkfour 0 0 0 0
let get_last_slice_workaround (s: seq quad32) (start_pos end_pos: int) =
false
null
false
if 0 <= start_pos && start_pos < end_pos && end_pos <= length s then last (slice s start_pos end_pos) else Mkfour 0 0 0 0
{ "checked_file": "Vale.AES.X64.GHash.fsti.checked", "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.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.X64.GHash.fsti" }
[ "total" ]
[ "FStar.Seq.Base.seq", "Vale.X64.Decls.quad32", "Prims.int", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "FStar.Seq.Base.length", "FStar.Seq.Properties.last", "FStar.Seq.Base.slice", "Prims.bool", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four" ]
[]
module Vale.AES.X64.GHash open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open Vale.Math.Poly2_s open Vale.Poly1305.Math open Vale.AES.X64.GF128_Mul 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.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 30"
false
true
Vale.AES.X64.GHash.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_last_slice_workaround : s: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> start_pos: Prims.int -> end_pos: Prims.int -> Vale.Def.Words_s.four Vale.Def.Types_s.nat32
[]
Vale.AES.X64.GHash.get_last_slice_workaround
{ "file_name": "obj/Vale.AES.X64.GHash.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> start_pos: Prims.int -> end_pos: Prims.int -> Vale.Def.Words_s.four Vale.Def.Types_s.nat32
{ "end_col": 18, "end_line": 33, "start_col": 2, "start_line": 30 }
Prims.Tot
val va_quick_Compute_ghash_incremental_register: Prims.unit -> (va_quickCode unit (va_code_Compute_ghash_incremental_register ()))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "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.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "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.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_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.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.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 } ]
false
let va_quick_Compute_ghash_incremental_register () : (va_quickCode unit (va_code_Compute_ghash_incremental_register ())) = (va_QProc (va_code_Compute_ghash_incremental_register ()) ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_xmm 1]) va_wp_Compute_ghash_incremental_register va_wpProof_Compute_ghash_incremental_register)
val va_quick_Compute_ghash_incremental_register: Prims.unit -> (va_quickCode unit (va_code_Compute_ghash_incremental_register ())) let va_quick_Compute_ghash_incremental_register () : (va_quickCode unit (va_code_Compute_ghash_incremental_register ())) =
false
null
false
(va_QProc (va_code_Compute_ghash_incremental_register ()) ([ va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_xmm 1 ]) va_wp_Compute_ghash_incremental_register va_wpProof_Compute_ghash_incremental_register)
{ "checked_file": "Vale.AES.X64.GHash.fsti.checked", "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.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.X64.GHash.fsti" }
[ "total" ]
[ "Prims.unit", "Vale.X64.QuickCode.va_QProc", "Vale.AES.X64.GHash.va_code_Compute_ghash_incremental_register", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR12", "Vale.X64.QuickCode.va_Mod_flags", "Prims.Nil", "Vale.AES.X64.GHash.va_wp_Compute_ghash_incremental_register", "Vale.AES.X64.GHash.va_wpProof_Compute_ghash_incremental_register", "Vale.X64.QuickCode.va_quickCode" ]
[]
module Vale.AES.X64.GHash open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open Vale.Math.Poly2_s open Vale.Poly1305.Math open Vale.AES.X64.GF128_Mul 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.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 30" let get_last_slice_workaround (s:seq quad32) (start_pos end_pos:int) = if 0 <= start_pos && start_pos < end_pos && end_pos <= length s then last (slice s start_pos end_pos) else Mkfour 0 0 0 0 //let slice (s:seq quad32) (start_pos end_pos:int) = // if 0 <= start_pos && start_pos < end_pos && end_pos <= length s then // slice s start_pos end_pos // else // create 1 (Mkfour 0 0 0 0) //-- Compute_ghash_incremental_register val va_code_Compute_ghash_incremental_register : va_dummy:unit -> Tot va_code val va_codegen_success_Compute_ghash_incremental_register : va_dummy:unit -> Tot va_pbool val va_lemma_Compute_ghash_incremental_register : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Compute_ghash_incremental_register ()) va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.AES.GHash.ghash_incremental (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_sM)) (va_get_xmm 1 va_s0) (FStar.Seq.Base.create #quad32 1 (va_get_xmm 2 va_s0)) /\ va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0))))))))))) [@ va_qattr] let va_wp_Compute_ghash_incremental_register (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051) /\ (forall (va_x_xmm1:quad32) (va_x_efl:Vale.X64.Flags.t) (va_x_r12:nat64) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) . let va_sM = va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_reg64 rR12 va_x_r12 (va_upd_flags va_x_efl (va_upd_xmm 1 va_x_xmm1 va_s0))))))) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.AES.GHash.ghash_incremental (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_sM)) (va_get_xmm 1 va_s0) (FStar.Seq.Base.create #quad32 1 (va_get_xmm 2 va_s0)) ==> va_k va_sM (()))) val va_wpProof_Compute_ghash_incremental_register : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Compute_ghash_incremental_register va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Compute_ghash_incremental_register ()) ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_xmm 1]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Compute_ghash_incremental_register () : (va_quickCode unit
false
false
Vale.AES.X64.GHash.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_quick_Compute_ghash_incremental_register: Prims.unit -> (va_quickCode unit (va_code_Compute_ghash_incremental_register ()))
[]
Vale.AES.X64.GHash.va_quick_Compute_ghash_incremental_register
{ "file_name": "obj/Vale.AES.X64.GHash.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.GHash.va_code_Compute_ghash_incremental_register ())
{ "end_col": 91, "end_line": 83, "start_col": 2, "start_line": 81 }
Prims.Tot
val last_carry (a b: nat) (c: nat1) : int
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let last_carry (a b:nat) (c:nat1) : int = if c = 0 then 0 else pow_int a b
val last_carry (a b: nat) (c: nat1) : int let last_carry (a b: nat) (c: nat1) : int =
false
null
false
if c = 0 then 0 else pow_int a b
{ "checked_file": "Vale.Bignum.Lemmas.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Bignum.Defs.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Lemmas.fsti" }
[ "total" ]
[ "Prims.nat", "Vale.Def.Words_s.nat1", "Prims.op_Equality", "Prims.int", "Prims.bool", "Vale.Bignum.Defs.pow_int" ]
[]
module Vale.Bignum.Lemmas open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Bignum.Defs unfold let (.[]) = Seq.index let rec seq_add_c (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then c0 else add_hi as0.[i - 1] bs.[i - 1] (seq_add_c as0 bs c0 (i - 1)) let seq_add_i (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True) = add_lo as0.[i] bs.[i] (seq_add_c as0 bs c0 i) // as0 + bs let seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs) (ensures fun (xs, _) -> length xs == length as0) = let f (i:nat{i < length as0}) = seq_add_i as0 bs c0 i in (init (length as0) f, seq_add_c as0 bs c0 (length as0))
false
true
Vale.Bignum.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val last_carry (a b: nat) (c: nat1) : int
[]
Vale.Bignum.Lemmas.last_carry
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Prims.nat -> b: Prims.nat -> c: Vale.Def.Words_s.nat1 -> Prims.int
{ "end_col": 34, "end_line": 30, "start_col": 2, "start_line": 30 }
Prims.Tot
val ys_init (#n: nat) (a: natN n) (bs: seq (natN n)) (i: nat{i <= length bs}) : natN n
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ys_init (#n:nat) (a:natN n) (bs:seq (natN n)) (i:nat{i <= length bs}) : natN n = if i = length bs then 0 else mul_lo a bs.[i]
val ys_init (#n: nat) (a: natN n) (bs: seq (natN n)) (i: nat{i <= length bs}) : natN n let ys_init (#n: nat) (a: natN n) (bs: seq (natN n)) (i: nat{i <= length bs}) : natN n =
false
null
false
if i = length bs then 0 else mul_lo a bs.[ i ]
{ "checked_file": "Vale.Bignum.Lemmas.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Bignum.Defs.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Lemmas.fsti" }
[ "total" ]
[ "Prims.nat", "Vale.Def.Words_s.natN", "FStar.Seq.Base.seq", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Prims.op_Equality", "Prims.bool", "Vale.Bignum.Defs.mul_lo", "Vale.Bignum.Lemmas.op_String_Access" ]
[]
module Vale.Bignum.Lemmas open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Bignum.Defs unfold let (.[]) = Seq.index let rec seq_add_c (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then c0 else add_hi as0.[i - 1] bs.[i - 1] (seq_add_c as0 bs c0 (i - 1)) let seq_add_i (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True) = add_lo as0.[i] bs.[i] (seq_add_c as0 bs c0 i) // as0 + bs let seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs) (ensures fun (xs, _) -> length xs == length as0) = let f (i:nat{i < length as0}) = seq_add_i as0 bs c0 i in (init (length as0) f, seq_add_c as0 bs c0 (length as0)) let last_carry (a b:nat) (c:nat1) : int = if c = 0 then 0 else pow_int a b let seq_scale_lo (#n:pos) (a:natN n) (bs:seq (natN n)) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = length bs then 0 else mul_lo a bs.[i] in init (length bs + 1) f let seq_scale_hi (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = 0 then d else mul_hi a bs.[i - 1] in init (length bs + 1) f // a * bs + d let seq_scale (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = fst (seq_add (seq_scale_lo a bs) (seq_scale_hi a bs d) 0) val lemma_sum_seq_left_right (s:seq int) (i j:nat) : Lemma (requires i <= j /\ j <= length s) (ensures sum_seq_left s i j == sum_seq_right s i j) val lemma_pow_nat (a:nat) (b:nat) : Lemma (0 <= pow_int a b) val lemma_sum_pow_seq_bound (#n:nat) (s:seq (natN n)) : Lemma (ensures 0 <= sum_pow_seq s /\ sum_pow_seq s < pow_int n (length s)) let rec seq_add_is (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then True else seq_add_is as0 bs c0 (i - 1) /\ (fst (seq_add as0 bs c0)).[i - 1] == seq_add_i as0 bs c0 (i - 1) unfold let seq_add_is_norm (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = norm [iota; zeta; primops; delta_only [`%seq_add_is]] (seq_add_is as0 bs c0 i) val lemma_seq_add_is_norm (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Lemma (requires length as0 == length bs /\ i <= length as0) (ensures seq_add_is as0 bs c0 i == seq_add_is_norm as0 bs c0 i) val lemma_last_carry_mul (a b:nat) (c:nat1) : Lemma (last_carry a b c == c * pow_int a b) val lemma_add_lo_mul_right (#n:nat) (a b:natN n) (c:nat1) (m:int) : Lemma (add_lo a b c * m == (let x = a * m + b * m + c * m in if a + b + c < n then x else x - n * m)) val lemma_seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Lemma (requires length bs == length as0) (ensures ( let (xs, ci) = seq_add as0 bs c0 in sum_pow_seq xs + last_carry n (length as0) ci == sum_pow_seq as0 + sum_pow_seq bs + c0 )) val lemma_seq_scale_carry (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) : Lemma (ensures ( snd (seq_add (seq_scale_lo a bs) (seq_scale_hi a bs d) 0) == 0 )) val lemma_seq_scale (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) : Lemma (ensures ( sum_pow_seq (seq_scale a bs d) == sum_pow_seq (seq_scale_lo a bs) + sum_pow_seq (seq_scale_hi a bs d) /\ sum_pow_seq (seq_scale a bs d) == a * sum_pow_seq bs + d ))
false
false
Vale.Bignum.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ys_init (#n: nat) (a: natN n) (bs: seq (natN n)) (i: nat{i <= length bs}) : natN n
[]
Vale.Bignum.Lemmas.ys_init
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Vale.Def.Words_s.natN n -> bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> i: Prims.nat{i <= FStar.Seq.Base.length bs} -> Vale.Def.Words_s.natN n
{ "end_col": 46, "end_line": 103, "start_col": 2, "start_line": 103 }
Prims.Tot
val zs_init (#n: nat) (a: natN n) (bs: seq (natN n)) (d: natN n) (i: nat{i <= length bs}) : natN n
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let zs_init (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) (i:nat{i <= length bs}) : natN n = if i = 0 then d else mul_hi a bs.[i - 1]
val zs_init (#n: nat) (a: natN n) (bs: seq (natN n)) (d: natN n) (i: nat{i <= length bs}) : natN n let zs_init (#n: nat) (a: natN n) (bs: seq (natN n)) (d: natN n) (i: nat{i <= length bs}) : natN n =
false
null
false
if i = 0 then d else mul_hi a bs.[ i - 1 ]
{ "checked_file": "Vale.Bignum.Lemmas.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Bignum.Defs.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Lemmas.fsti" }
[ "total" ]
[ "Prims.nat", "Vale.Def.Words_s.natN", "FStar.Seq.Base.seq", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Prims.op_Equality", "Prims.int", "Prims.bool", "Vale.Bignum.Defs.mul_hi", "Vale.Bignum.Lemmas.op_String_Access", "Prims.op_Subtraction" ]
[]
module Vale.Bignum.Lemmas open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Bignum.Defs unfold let (.[]) = Seq.index let rec seq_add_c (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then c0 else add_hi as0.[i - 1] bs.[i - 1] (seq_add_c as0 bs c0 (i - 1)) let seq_add_i (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True) = add_lo as0.[i] bs.[i] (seq_add_c as0 bs c0 i) // as0 + bs let seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs) (ensures fun (xs, _) -> length xs == length as0) = let f (i:nat{i < length as0}) = seq_add_i as0 bs c0 i in (init (length as0) f, seq_add_c as0 bs c0 (length as0)) let last_carry (a b:nat) (c:nat1) : int = if c = 0 then 0 else pow_int a b let seq_scale_lo (#n:pos) (a:natN n) (bs:seq (natN n)) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = length bs then 0 else mul_lo a bs.[i] in init (length bs + 1) f let seq_scale_hi (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = 0 then d else mul_hi a bs.[i - 1] in init (length bs + 1) f // a * bs + d let seq_scale (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = fst (seq_add (seq_scale_lo a bs) (seq_scale_hi a bs d) 0) val lemma_sum_seq_left_right (s:seq int) (i j:nat) : Lemma (requires i <= j /\ j <= length s) (ensures sum_seq_left s i j == sum_seq_right s i j) val lemma_pow_nat (a:nat) (b:nat) : Lemma (0 <= pow_int a b) val lemma_sum_pow_seq_bound (#n:nat) (s:seq (natN n)) : Lemma (ensures 0 <= sum_pow_seq s /\ sum_pow_seq s < pow_int n (length s)) let rec seq_add_is (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then True else seq_add_is as0 bs c0 (i - 1) /\ (fst (seq_add as0 bs c0)).[i - 1] == seq_add_i as0 bs c0 (i - 1) unfold let seq_add_is_norm (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = norm [iota; zeta; primops; delta_only [`%seq_add_is]] (seq_add_is as0 bs c0 i) val lemma_seq_add_is_norm (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Lemma (requires length as0 == length bs /\ i <= length as0) (ensures seq_add_is as0 bs c0 i == seq_add_is_norm as0 bs c0 i) val lemma_last_carry_mul (a b:nat) (c:nat1) : Lemma (last_carry a b c == c * pow_int a b) val lemma_add_lo_mul_right (#n:nat) (a b:natN n) (c:nat1) (m:int) : Lemma (add_lo a b c * m == (let x = a * m + b * m + c * m in if a + b + c < n then x else x - n * m)) val lemma_seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Lemma (requires length bs == length as0) (ensures ( let (xs, ci) = seq_add as0 bs c0 in sum_pow_seq xs + last_carry n (length as0) ci == sum_pow_seq as0 + sum_pow_seq bs + c0 )) val lemma_seq_scale_carry (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) : Lemma (ensures ( snd (seq_add (seq_scale_lo a bs) (seq_scale_hi a bs d) 0) == 0 )) val lemma_seq_scale (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) : Lemma (ensures ( sum_pow_seq (seq_scale a bs d) == sum_pow_seq (seq_scale_lo a bs) + sum_pow_seq (seq_scale_hi a bs d) /\ sum_pow_seq (seq_scale a bs d) == a * sum_pow_seq bs + d )) let ys_init (#n:nat) (a:natN n) (bs:seq (natN n)) (i:nat{i <= length bs}) : natN n = if i = length bs then 0 else mul_lo a bs.[i]
false
false
Vale.Bignum.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val zs_init (#n: nat) (a: natN n) (bs: seq (natN n)) (d: natN n) (i: nat{i <= length bs}) : natN n
[]
Vale.Bignum.Lemmas.zs_init
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Vale.Def.Words_s.natN n -> bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> d: Vale.Def.Words_s.natN n -> i: Prims.nat{i <= FStar.Seq.Base.length bs} -> Vale.Def.Words_s.natN n
{ "end_col": 42, "end_line": 106, "start_col": 2, "start_line": 106 }
Prims.Pure
val seq_add_i (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True)
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let seq_add_i (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True) = add_lo as0.[i] bs.[i] (seq_add_c as0 bs c0 i)
val seq_add_i (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True) let seq_add_i (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True) =
false
null
false
add_lo as0.[ i ] bs.[ i ] (seq_add_c as0 bs c0 i)
{ "checked_file": "Vale.Bignum.Lemmas.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Bignum.Defs.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Lemmas.fsti" }
[]
[ "Prims.nat", "FStar.Seq.Base.seq", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.nat1", "Vale.Bignum.Defs.add_lo", "Vale.Bignum.Lemmas.op_String_Access", "Vale.Bignum.Lemmas.seq_add_c", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.length", "Prims.b2t", "Prims.op_LessThan", "Prims.l_True" ]
[]
module Vale.Bignum.Lemmas open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Bignum.Defs unfold let (.[]) = Seq.index let rec seq_add_c (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then c0 else add_hi as0.[i - 1] bs.[i - 1] (seq_add_c as0 bs c0 (i - 1)) let seq_add_i (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True)
false
false
Vale.Bignum.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val seq_add_i (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True)
[]
Vale.Bignum.Lemmas.seq_add_i
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
as0: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> c0: Vale.Def.Words_s.nat1 -> i: Prims.nat -> Prims.Pure (Vale.Def.Words_s.natN n)
{ "end_col": 47, "end_line": 19, "start_col": 2, "start_line": 19 }
Prims.Tot
val init_zs (#n: nat) (a: natN n) (bs: seq (natN n)) (d: natN n) : seq (natN n)
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let init_zs (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) : seq (natN n) = init (length bs + 1) (zs_init a bs d)
val init_zs (#n: nat) (a: natN n) (bs: seq (natN n)) (d: natN n) : seq (natN n) let init_zs (#n: nat) (a: natN n) (bs: seq (natN n)) (d: natN n) : seq (natN n) =
false
null
false
init (length bs + 1) (zs_init a bs d)
{ "checked_file": "Vale.Bignum.Lemmas.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Bignum.Defs.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Lemmas.fsti" }
[ "total" ]
[ "Prims.nat", "Vale.Def.Words_s.natN", "FStar.Seq.Base.seq", "FStar.Seq.Base.init", "Prims.op_Addition", "FStar.Seq.Base.length", "Vale.Bignum.Lemmas.zs_init" ]
[]
module Vale.Bignum.Lemmas open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Bignum.Defs unfold let (.[]) = Seq.index let rec seq_add_c (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then c0 else add_hi as0.[i - 1] bs.[i - 1] (seq_add_c as0 bs c0 (i - 1)) let seq_add_i (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True) = add_lo as0.[i] bs.[i] (seq_add_c as0 bs c0 i) // as0 + bs let seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs) (ensures fun (xs, _) -> length xs == length as0) = let f (i:nat{i < length as0}) = seq_add_i as0 bs c0 i in (init (length as0) f, seq_add_c as0 bs c0 (length as0)) let last_carry (a b:nat) (c:nat1) : int = if c = 0 then 0 else pow_int a b let seq_scale_lo (#n:pos) (a:natN n) (bs:seq (natN n)) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = length bs then 0 else mul_lo a bs.[i] in init (length bs + 1) f let seq_scale_hi (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = 0 then d else mul_hi a bs.[i - 1] in init (length bs + 1) f // a * bs + d let seq_scale (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = fst (seq_add (seq_scale_lo a bs) (seq_scale_hi a bs d) 0) val lemma_sum_seq_left_right (s:seq int) (i j:nat) : Lemma (requires i <= j /\ j <= length s) (ensures sum_seq_left s i j == sum_seq_right s i j) val lemma_pow_nat (a:nat) (b:nat) : Lemma (0 <= pow_int a b) val lemma_sum_pow_seq_bound (#n:nat) (s:seq (natN n)) : Lemma (ensures 0 <= sum_pow_seq s /\ sum_pow_seq s < pow_int n (length s)) let rec seq_add_is (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then True else seq_add_is as0 bs c0 (i - 1) /\ (fst (seq_add as0 bs c0)).[i - 1] == seq_add_i as0 bs c0 (i - 1) unfold let seq_add_is_norm (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = norm [iota; zeta; primops; delta_only [`%seq_add_is]] (seq_add_is as0 bs c0 i) val lemma_seq_add_is_norm (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Lemma (requires length as0 == length bs /\ i <= length as0) (ensures seq_add_is as0 bs c0 i == seq_add_is_norm as0 bs c0 i) val lemma_last_carry_mul (a b:nat) (c:nat1) : Lemma (last_carry a b c == c * pow_int a b) val lemma_add_lo_mul_right (#n:nat) (a b:natN n) (c:nat1) (m:int) : Lemma (add_lo a b c * m == (let x = a * m + b * m + c * m in if a + b + c < n then x else x - n * m)) val lemma_seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Lemma (requires length bs == length as0) (ensures ( let (xs, ci) = seq_add as0 bs c0 in sum_pow_seq xs + last_carry n (length as0) ci == sum_pow_seq as0 + sum_pow_seq bs + c0 )) val lemma_seq_scale_carry (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) : Lemma (ensures ( snd (seq_add (seq_scale_lo a bs) (seq_scale_hi a bs d) 0) == 0 )) val lemma_seq_scale (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) : Lemma (ensures ( sum_pow_seq (seq_scale a bs d) == sum_pow_seq (seq_scale_lo a bs) + sum_pow_seq (seq_scale_hi a bs d) /\ sum_pow_seq (seq_scale a bs d) == a * sum_pow_seq bs + d )) let ys_init (#n:nat) (a:natN n) (bs:seq (natN n)) (i:nat{i <= length bs}) : natN n = if i = length bs then 0 else mul_lo a bs.[i] let zs_init (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) (i:nat{i <= length bs}) : natN n = if i = 0 then d else mul_hi a bs.[i - 1] let init_ys (#n:nat) (a:natN n) (bs:seq (natN n)) : seq (natN n) = init (length bs + 1) (ys_init a bs)
false
false
Vale.Bignum.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val init_zs (#n: nat) (a: natN n) (bs: seq (natN n)) (d: natN n) : seq (natN n)
[]
Vale.Bignum.Lemmas.init_zs
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Vale.Def.Words_s.natN n -> bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> d: Vale.Def.Words_s.natN n -> FStar.Seq.Base.seq (Vale.Def.Words_s.natN n)
{ "end_col": 39, "end_line": 112, "start_col": 2, "start_line": 112 }
Prims.Tot
val init_ys (#n: nat) (a: natN n) (bs: seq (natN n)) : seq (natN n)
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let init_ys (#n:nat) (a:natN n) (bs:seq (natN n)) : seq (natN n) = init (length bs + 1) (ys_init a bs)
val init_ys (#n: nat) (a: natN n) (bs: seq (natN n)) : seq (natN n) let init_ys (#n: nat) (a: natN n) (bs: seq (natN n)) : seq (natN n) =
false
null
false
init (length bs + 1) (ys_init a bs)
{ "checked_file": "Vale.Bignum.Lemmas.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Bignum.Defs.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Lemmas.fsti" }
[ "total" ]
[ "Prims.nat", "Vale.Def.Words_s.natN", "FStar.Seq.Base.seq", "FStar.Seq.Base.init", "Prims.op_Addition", "FStar.Seq.Base.length", "Vale.Bignum.Lemmas.ys_init" ]
[]
module Vale.Bignum.Lemmas open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Bignum.Defs unfold let (.[]) = Seq.index let rec seq_add_c (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then c0 else add_hi as0.[i - 1] bs.[i - 1] (seq_add_c as0 bs c0 (i - 1)) let seq_add_i (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True) = add_lo as0.[i] bs.[i] (seq_add_c as0 bs c0 i) // as0 + bs let seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs) (ensures fun (xs, _) -> length xs == length as0) = let f (i:nat{i < length as0}) = seq_add_i as0 bs c0 i in (init (length as0) f, seq_add_c as0 bs c0 (length as0)) let last_carry (a b:nat) (c:nat1) : int = if c = 0 then 0 else pow_int a b let seq_scale_lo (#n:pos) (a:natN n) (bs:seq (natN n)) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = length bs then 0 else mul_lo a bs.[i] in init (length bs + 1) f let seq_scale_hi (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = 0 then d else mul_hi a bs.[i - 1] in init (length bs + 1) f // a * bs + d let seq_scale (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = fst (seq_add (seq_scale_lo a bs) (seq_scale_hi a bs d) 0) val lemma_sum_seq_left_right (s:seq int) (i j:nat) : Lemma (requires i <= j /\ j <= length s) (ensures sum_seq_left s i j == sum_seq_right s i j) val lemma_pow_nat (a:nat) (b:nat) : Lemma (0 <= pow_int a b) val lemma_sum_pow_seq_bound (#n:nat) (s:seq (natN n)) : Lemma (ensures 0 <= sum_pow_seq s /\ sum_pow_seq s < pow_int n (length s)) let rec seq_add_is (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then True else seq_add_is as0 bs c0 (i - 1) /\ (fst (seq_add as0 bs c0)).[i - 1] == seq_add_i as0 bs c0 (i - 1) unfold let seq_add_is_norm (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = norm [iota; zeta; primops; delta_only [`%seq_add_is]] (seq_add_is as0 bs c0 i) val lemma_seq_add_is_norm (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Lemma (requires length as0 == length bs /\ i <= length as0) (ensures seq_add_is as0 bs c0 i == seq_add_is_norm as0 bs c0 i) val lemma_last_carry_mul (a b:nat) (c:nat1) : Lemma (last_carry a b c == c * pow_int a b) val lemma_add_lo_mul_right (#n:nat) (a b:natN n) (c:nat1) (m:int) : Lemma (add_lo a b c * m == (let x = a * m + b * m + c * m in if a + b + c < n then x else x - n * m)) val lemma_seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Lemma (requires length bs == length as0) (ensures ( let (xs, ci) = seq_add as0 bs c0 in sum_pow_seq xs + last_carry n (length as0) ci == sum_pow_seq as0 + sum_pow_seq bs + c0 )) val lemma_seq_scale_carry (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) : Lemma (ensures ( snd (seq_add (seq_scale_lo a bs) (seq_scale_hi a bs d) 0) == 0 )) val lemma_seq_scale (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) : Lemma (ensures ( sum_pow_seq (seq_scale a bs d) == sum_pow_seq (seq_scale_lo a bs) + sum_pow_seq (seq_scale_hi a bs d) /\ sum_pow_seq (seq_scale a bs d) == a * sum_pow_seq bs + d )) let ys_init (#n:nat) (a:natN n) (bs:seq (natN n)) (i:nat{i <= length bs}) : natN n = if i = length bs then 0 else mul_lo a bs.[i] let zs_init (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) (i:nat{i <= length bs}) : natN n = if i = 0 then d else mul_hi a bs.[i - 1]
false
false
Vale.Bignum.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val init_ys (#n: nat) (a: natN n) (bs: seq (natN n)) : seq (natN n)
[]
Vale.Bignum.Lemmas.init_ys
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Vale.Def.Words_s.natN n -> bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> FStar.Seq.Base.seq (Vale.Def.Words_s.natN n)
{ "end_col": 37, "end_line": 109, "start_col": 2, "start_line": 109 }
Prims.Pure
val seq_add (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs) (ensures fun (xs, _) -> length xs == length as0)
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs) (ensures fun (xs, _) -> length xs == length as0) = let f (i:nat{i < length as0}) = seq_add_i as0 bs c0 i in (init (length as0) f, seq_add_c as0 bs c0 (length as0))
val seq_add (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs) (ensures fun (xs, _) -> length xs == length as0) let seq_add (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs) (ensures fun (xs, _) -> length xs == length as0) =
false
null
false
let f (i: nat{i < length as0}) = seq_add_i as0 bs c0 i in (init (length as0) f, seq_add_c as0 bs c0 (length as0))
{ "checked_file": "Vale.Bignum.Lemmas.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Bignum.Defs.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Lemmas.fsti" }
[]
[ "Prims.nat", "FStar.Seq.Base.seq", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.nat1", "FStar.Pervasives.Native.Mktuple2", "FStar.Seq.Base.init", "FStar.Seq.Base.length", "Vale.Bignum.Lemmas.seq_add_c", "Prims.b2t", "Prims.op_LessThan", "Vale.Bignum.Lemmas.seq_add_i", "FStar.Pervasives.Native.tuple2", "Prims.eq2" ]
[]
module Vale.Bignum.Lemmas open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Bignum.Defs unfold let (.[]) = Seq.index let rec seq_add_c (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then c0 else add_hi as0.[i - 1] bs.[i - 1] (seq_add_c as0 bs c0 (i - 1)) let seq_add_i (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True) = add_lo as0.[i] bs.[i] (seq_add_c as0 bs c0 i) // as0 + bs let seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs)
false
false
Vale.Bignum.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val seq_add (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs) (ensures fun (xs, _) -> length xs == length as0)
[]
Vale.Bignum.Lemmas.seq_add
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
as0: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> c0: Vale.Def.Words_s.nat1 -> Prims.Pure (FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) * Vale.Def.Words_s.nat1)
{ "end_col": 57, "end_line": 27, "start_col": 3, "start_line": 25 }
Prims.Pure
val seq_add_c (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True)
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec seq_add_c (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then c0 else add_hi as0.[i - 1] bs.[i - 1] (seq_add_c as0 bs c0 (i - 1))
val seq_add_c (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) let rec seq_add_c (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) =
false
null
false
if i = 0 then c0 else add_hi as0.[ i - 1 ] bs.[ i - 1 ] (seq_add_c as0 bs c0 (i - 1))
{ "checked_file": "Vale.Bignum.Lemmas.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Bignum.Defs.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Lemmas.fsti" }
[]
[ "Prims.nat", "FStar.Seq.Base.seq", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.nat1", "Prims.op_Equality", "Prims.int", "Prims.bool", "Vale.Bignum.Defs.add_hi", "Vale.Bignum.Lemmas.op_String_Access", "Prims.op_Subtraction", "Vale.Bignum.Lemmas.seq_add_c", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.length", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.l_True" ]
[]
module Vale.Bignum.Lemmas open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Bignum.Defs unfold let (.[]) = Seq.index let rec seq_add_c (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True)
false
false
Vale.Bignum.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val seq_add_c (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True)
[ "recursion" ]
Vale.Bignum.Lemmas.seq_add_c
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
as0: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> c0: Vale.Def.Words_s.nat1 -> i: Prims.nat -> Prims.Pure Vale.Def.Words_s.nat1
{ "end_col": 83, "end_line": 13, "start_col": 2, "start_line": 13 }
Prims.Pure
val seq_add_is_norm (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True)
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let seq_add_is_norm (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = norm [iota; zeta; primops; delta_only [`%seq_add_is]] (seq_add_is as0 bs c0 i)
val seq_add_is_norm (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) let seq_add_is_norm (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) =
false
null
false
norm [iota; zeta; primops; delta_only [`%seq_add_is]] (seq_add_is as0 bs c0 i)
{ "checked_file": "Vale.Bignum.Lemmas.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Bignum.Defs.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Lemmas.fsti" }
[]
[ "Prims.nat", "FStar.Seq.Base.seq", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.nat1", "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "FStar.Pervasives.delta_only", "Prims.string", "Prims.Nil", "Vale.Bignum.Lemmas.seq_add_is", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.length", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.l_True" ]
[]
module Vale.Bignum.Lemmas open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Bignum.Defs unfold let (.[]) = Seq.index let rec seq_add_c (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then c0 else add_hi as0.[i - 1] bs.[i - 1] (seq_add_c as0 bs c0 (i - 1)) let seq_add_i (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True) = add_lo as0.[i] bs.[i] (seq_add_c as0 bs c0 i) // as0 + bs let seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs) (ensures fun (xs, _) -> length xs == length as0) = let f (i:nat{i < length as0}) = seq_add_i as0 bs c0 i in (init (length as0) f, seq_add_c as0 bs c0 (length as0)) let last_carry (a b:nat) (c:nat1) : int = if c = 0 then 0 else pow_int a b let seq_scale_lo (#n:pos) (a:natN n) (bs:seq (natN n)) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = length bs then 0 else mul_lo a bs.[i] in init (length bs + 1) f let seq_scale_hi (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = 0 then d else mul_hi a bs.[i - 1] in init (length bs + 1) f // a * bs + d let seq_scale (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = fst (seq_add (seq_scale_lo a bs) (seq_scale_hi a bs d) 0) val lemma_sum_seq_left_right (s:seq int) (i j:nat) : Lemma (requires i <= j /\ j <= length s) (ensures sum_seq_left s i j == sum_seq_right s i j) val lemma_pow_nat (a:nat) (b:nat) : Lemma (0 <= pow_int a b) val lemma_sum_pow_seq_bound (#n:nat) (s:seq (natN n)) : Lemma (ensures 0 <= sum_pow_seq s /\ sum_pow_seq s < pow_int n (length s)) let rec seq_add_is (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then True else seq_add_is as0 bs c0 (i - 1) /\ (fst (seq_add as0 bs c0)).[i - 1] == seq_add_i as0 bs c0 (i - 1) unfold let seq_add_is_norm (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True)
false
false
Vale.Bignum.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val seq_add_is_norm (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True)
[]
Vale.Bignum.Lemmas.seq_add_is_norm
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
as0: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> c0: Vale.Def.Words_s.nat1 -> i: Prims.nat -> Prims.Pure Type0
{ "end_col": 80, "end_line": 73, "start_col": 2, "start_line": 73 }
Prims.Pure
val seq_add_is (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True)
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec seq_add_is (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then True else seq_add_is as0 bs c0 (i - 1) /\ (fst (seq_add as0 bs c0)).[i - 1] == seq_add_i as0 bs c0 (i - 1)
val seq_add_is (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) let rec seq_add_is (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) =
false
null
false
if i = 0 then True else seq_add_is as0 bs c0 (i - 1) /\ (fst (seq_add as0 bs c0)).[ i - 1 ] == seq_add_i as0 bs c0 (i - 1)
{ "checked_file": "Vale.Bignum.Lemmas.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Bignum.Defs.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Lemmas.fsti" }
[]
[ "Prims.nat", "FStar.Seq.Base.seq", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.nat1", "Prims.op_Equality", "Prims.int", "Prims.l_True", "Prims.bool", "Prims.l_and", "Vale.Bignum.Lemmas.seq_add_is", "Prims.op_Subtraction", "Prims.eq2", "Vale.Bignum.Lemmas.op_String_Access", "FStar.Pervasives.Native.fst", "Vale.Bignum.Lemmas.seq_add", "Vale.Bignum.Lemmas.seq_add_i", "FStar.Seq.Base.length", "Prims.b2t", "Prims.op_LessThanOrEqual" ]
[]
module Vale.Bignum.Lemmas open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Bignum.Defs unfold let (.[]) = Seq.index let rec seq_add_c (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then c0 else add_hi as0.[i - 1] bs.[i - 1] (seq_add_c as0 bs c0 (i - 1)) let seq_add_i (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True) = add_lo as0.[i] bs.[i] (seq_add_c as0 bs c0 i) // as0 + bs let seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs) (ensures fun (xs, _) -> length xs == length as0) = let f (i:nat{i < length as0}) = seq_add_i as0 bs c0 i in (init (length as0) f, seq_add_c as0 bs c0 (length as0)) let last_carry (a b:nat) (c:nat1) : int = if c = 0 then 0 else pow_int a b let seq_scale_lo (#n:pos) (a:natN n) (bs:seq (natN n)) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = length bs then 0 else mul_lo a bs.[i] in init (length bs + 1) f let seq_scale_hi (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = 0 then d else mul_hi a bs.[i - 1] in init (length bs + 1) f // a * bs + d let seq_scale (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = fst (seq_add (seq_scale_lo a bs) (seq_scale_hi a bs d) 0) val lemma_sum_seq_left_right (s:seq int) (i j:nat) : Lemma (requires i <= j /\ j <= length s) (ensures sum_seq_left s i j == sum_seq_right s i j) val lemma_pow_nat (a:nat) (b:nat) : Lemma (0 <= pow_int a b) val lemma_sum_pow_seq_bound (#n:nat) (s:seq (natN n)) : Lemma (ensures 0 <= sum_pow_seq s /\ sum_pow_seq s < pow_int n (length s)) let rec seq_add_is (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True)
false
false
Vale.Bignum.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val seq_add_is (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat) : Pure Type0 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True)
[ "recursion" ]
Vale.Bignum.Lemmas.seq_add_is
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
as0: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> c0: Vale.Def.Words_s.nat1 -> i: Prims.nat -> Prims.Pure Type0
{ "end_col": 98, "end_line": 67, "start_col": 2, "start_line": 66 }
Prims.Pure
val seq_scale (#n: pos) (a: natN n) (bs: seq (natN n)) (d: natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1)
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let seq_scale (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = fst (seq_add (seq_scale_lo a bs) (seq_scale_hi a bs d) 0)
val seq_scale (#n: pos) (a: natN n) (bs: seq (natN n)) (d: natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) let seq_scale (#n: pos) (a: natN n) (bs: seq (natN n)) (d: natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) =
false
null
false
fst (seq_add (seq_scale_lo a bs) (seq_scale_hi a bs d) 0)
{ "checked_file": "Vale.Bignum.Lemmas.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Bignum.Defs.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Lemmas.fsti" }
[]
[ "Prims.pos", "Vale.Def.Words_s.natN", "FStar.Seq.Base.seq", "FStar.Pervasives.Native.fst", "Vale.Def.Words_s.nat1", "Vale.Bignum.Lemmas.seq_add", "Vale.Bignum.Lemmas.seq_scale_lo", "Vale.Bignum.Lemmas.seq_scale_hi", "Prims.l_True", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "Prims.op_Addition" ]
[]
module Vale.Bignum.Lemmas open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Bignum.Defs unfold let (.[]) = Seq.index let rec seq_add_c (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then c0 else add_hi as0.[i - 1] bs.[i - 1] (seq_add_c as0 bs c0 (i - 1)) let seq_add_i (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True) = add_lo as0.[i] bs.[i] (seq_add_c as0 bs c0 i) // as0 + bs let seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs) (ensures fun (xs, _) -> length xs == length as0) = let f (i:nat{i < length as0}) = seq_add_i as0 bs c0 i in (init (length as0) f, seq_add_c as0 bs c0 (length as0)) let last_carry (a b:nat) (c:nat1) : int = if c = 0 then 0 else pow_int a b let seq_scale_lo (#n:pos) (a:natN n) (bs:seq (natN n)) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = length bs then 0 else mul_lo a bs.[i] in init (length bs + 1) f let seq_scale_hi (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = 0 then d else mul_hi a bs.[i - 1] in init (length bs + 1) f // a * bs + d let seq_scale (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1)
false
false
Vale.Bignum.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val seq_scale (#n: pos) (a: natN n) (bs: seq (natN n)) (d: natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1)
[]
Vale.Bignum.Lemmas.seq_scale
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Vale.Def.Words_s.natN n -> bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> d: Vale.Def.Words_s.natN n -> Prims.Pure (FStar.Seq.Base.seq (Vale.Def.Words_s.natN n))
{ "end_col": 59, "end_line": 51, "start_col": 2, "start_line": 51 }
Prims.Pure
val seq_scale_lo (#n: pos) (a: natN n) (bs: seq (natN n)) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1)
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let seq_scale_lo (#n:pos) (a:natN n) (bs:seq (natN n)) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = length bs then 0 else mul_lo a bs.[i] in init (length bs + 1) f
val seq_scale_lo (#n: pos) (a: natN n) (bs: seq (natN n)) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) let seq_scale_lo (#n: pos) (a: natN n) (bs: seq (natN n)) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) =
false
null
false
let f (i: nat{i <= length bs}) : natN n = if i = length bs then 0 else mul_lo a bs.[ i ] in init (length bs + 1) f
{ "checked_file": "Vale.Bignum.Lemmas.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Bignum.Defs.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Lemmas.fsti" }
[]
[ "Prims.pos", "Vale.Def.Words_s.natN", "FStar.Seq.Base.seq", "FStar.Seq.Base.init", "Prims.op_Addition", "FStar.Seq.Base.length", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Equality", "Prims.bool", "Vale.Bignum.Defs.mul_lo", "Vale.Bignum.Lemmas.op_String_Access", "Prims.l_True", "Prims.int" ]
[]
module Vale.Bignum.Lemmas open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Bignum.Defs unfold let (.[]) = Seq.index let rec seq_add_c (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then c0 else add_hi as0.[i - 1] bs.[i - 1] (seq_add_c as0 bs c0 (i - 1)) let seq_add_i (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True) = add_lo as0.[i] bs.[i] (seq_add_c as0 bs c0 i) // as0 + bs let seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs) (ensures fun (xs, _) -> length xs == length as0) = let f (i:nat{i < length as0}) = seq_add_i as0 bs c0 i in (init (length as0) f, seq_add_c as0 bs c0 (length as0)) let last_carry (a b:nat) (c:nat1) : int = if c = 0 then 0 else pow_int a b let seq_scale_lo (#n:pos) (a:natN n) (bs:seq (natN n)) : Pure (seq (natN n)) (requires True)
false
false
Vale.Bignum.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val seq_scale_lo (#n: pos) (a: natN n) (bs: seq (natN n)) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1)
[]
Vale.Bignum.Lemmas.seq_scale_lo
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Vale.Def.Words_s.natN n -> bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> Prims.Pure (FStar.Seq.Base.seq (Vale.Def.Words_s.natN n))
{ "end_col": 24, "end_line": 37, "start_col": 3, "start_line": 35 }
Prims.Pure
val seq_scale_hi (#n: pos) (a: natN n) (bs: seq (natN n)) (d: natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1)
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let seq_scale_hi (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = 0 then d else mul_hi a bs.[i - 1] in init (length bs + 1) f
val seq_scale_hi (#n: pos) (a: natN n) (bs: seq (natN n)) (d: natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) let seq_scale_hi (#n: pos) (a: natN n) (bs: seq (natN n)) (d: natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) =
false
null
false
let f (i: nat{i <= length bs}) : natN n = if i = 0 then d else mul_hi a bs.[ i - 1 ] in init (length bs + 1) f
{ "checked_file": "Vale.Bignum.Lemmas.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Bignum.Defs.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Lemmas.fsti" }
[]
[ "Prims.pos", "Vale.Def.Words_s.natN", "FStar.Seq.Base.seq", "FStar.Seq.Base.init", "Prims.op_Addition", "FStar.Seq.Base.length", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Equality", "Prims.int", "Prims.bool", "Vale.Bignum.Defs.mul_hi", "Vale.Bignum.Lemmas.op_String_Access", "Prims.op_Subtraction", "Prims.l_True" ]
[]
module Vale.Bignum.Lemmas open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Bignum.Defs unfold let (.[]) = Seq.index let rec seq_add_c (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure nat1 (requires length as0 == length bs /\ i <= length as0) (ensures fun _ -> True) = if i = 0 then c0 else add_hi as0.[i - 1] bs.[i - 1] (seq_add_c as0 bs c0 (i - 1)) let seq_add_i (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Pure (natN n) (requires length as0 == length bs /\ i < length as0) (ensures fun _ -> True) = add_lo as0.[i] bs.[i] (seq_add_c as0 bs c0 i) // as0 + bs let seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Pure (seq (natN n) & nat1) (requires length as0 == length bs) (ensures fun (xs, _) -> length xs == length as0) = let f (i:nat{i < length as0}) = seq_add_i as0 bs c0 i in (init (length as0) f, seq_add_c as0 bs c0 (length as0)) let last_carry (a b:nat) (c:nat1) : int = if c = 0 then 0 else pow_int a b let seq_scale_lo (#n:pos) (a:natN n) (bs:seq (natN n)) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1) = let f (i:nat{i <= length bs}) : natN n = if i = length bs then 0 else mul_lo a bs.[i] in init (length bs + 1) f let seq_scale_hi (#n:pos) (a:natN n) (bs:seq (natN n)) (d:natN n) : Pure (seq (natN n)) (requires True)
false
false
Vale.Bignum.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val seq_scale_hi (#n: pos) (a: natN n) (bs: seq (natN n)) (d: natN n) : Pure (seq (natN n)) (requires True) (ensures fun xs -> length xs = length bs + 1)
[]
Vale.Bignum.Lemmas.seq_scale_hi
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Vale.Def.Words_s.natN n -> bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> d: Vale.Def.Words_s.natN n -> Prims.Pure (FStar.Seq.Base.seq (Vale.Def.Words_s.natN n))
{ "end_col": 24, "end_line": 44, "start_col": 3, "start_line": 42 }
FStar.All.ML
val resolve_typ_param (env: qenv) (p: typ_param) : ML typ_param
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let resolve_typ_param (env:qenv) (p:typ_param) : ML typ_param = match p with | Inl e -> resolve_expr env e |> Inl | _ -> p
val resolve_typ_param (env: qenv) (p: typ_param) : ML typ_param let resolve_typ_param (env: qenv) (p: typ_param) : ML typ_param =
true
null
false
match p with | Inl e -> resolve_expr env e |> Inl | _ -> p
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "ml" ]
[ "Desugar.qenv", "Ast.typ_param", "Ast.expr", "FStar.All.op_Bar_Greater", "Ast.Inl", "Ast.out_expr", "Desugar.resolve_expr", "Ast.either" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *) let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases let desugar_enum_cases (ityp:integer_type) (cases:list enum_case) (export:bool) : ML (list enum_case & list decl) = let find_definition (i:ident) (d:decl) = match d.d_decl.v with | Define j _ (Int _ _) -> i.v = j.v | _ -> false in let _, cases_rev, ds_rev = List.fold_left (fun (next, cases_rev, ds_rev) (i, jopt) -> let next = match jopt with | Some (Inl j) -> j | Some (Inr j) -> begin match List.Tot.find (find_definition j) ds_rev with | Some ({d_decl={v=Define _ _ (Int _ k)}}) -> k | _ -> error (Printf.sprintf "Enum identifier %s not found" (print_ident j)) j.range end | None -> next in let case = (i, None) in let d = mk_decl (Define i None (Int ityp next)) i.range ["Enum constant"] export in (next + 1, case :: cases_rev, d :: ds_rev)) (0, [], []) cases in List.rev cases_rev, List.rev ds_rev let desugar_one_enum (d:decl) : ML (list decl) = match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] //no enum value assignments; no desugaring to do else //if we have any assignments at all, then we treat all the //tags as fresh constants and assign them values in sequence //with respect to the assigned values of preceding tags let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds@[enum] | _ -> [d] (* This code is currently not used It desugars an Enum to a record with a single refined field *) // let eliminate_enum (d:decl) : ML decl = // match d.v with // | Enum t i cases -> // let names = { // typedef_name = { i with v = { i.v with name=Ast.reserved_prefix ^ Ast.reserved_prefix ^ i.v.name }}; // typedef_abbrev = i; // typedef_ptr_abbrev = { i with v = {i.v with // name = Ast.reserved_prefix ^ Ast.reserved_prefix ^ "P" ^ i.v.name }}; // typedef_attributes = []; // } in // let params = [] in // let where = None in // let field_ident = with_dummy_range (to_ident' (Ast.reserved_prefix ^ "enum_field")) in // let field_ident_expr = with_dummy_range (Identifier field_ident) in // let field_constraint = // List.fold_right // (fun (case, _) out -> // let eq = with_range (App Eq [field_ident_expr; with_range (Identifier case) case.range]) case.range in // with_dummy_range (App Or [eq; out])) // cases // (with_dummy_range (Constant (Bool false))) // in // let field = { // field_dependence = false; // field_ident = field_ident; // field_type = t; // field_array_opt = FieldScalar; // field_constraint = Some field_constraint; // field_number = None; // field_bitwidth = None; // field_action = None // } in // let d' = Record names params where [with_dummy_range field] in // {d with v = d'} // | _ -> d (* * output_types and extern_types tables to set the kind in the Typ_app nodes *) noeq type qenv = { mname : string; module_abbrevs : H.t string string; output_types : H.t ident' unit; extern_types : H.t ident' unit; local_names : list string; global_env: GlobalEnv.global_env; } let push_module_abbrev (env:qenv) (i m:string) : ML unit = H.insert env.module_abbrevs i m let push_output_type (env:qenv) (out_t:out_typ) : ML unit = H.insert env.output_types out_t.out_typ_names.typedef_name.v (); H.insert env.output_types out_t.out_typ_names.typedef_abbrev.v () let push_extern_type (env:qenv) (td:typedef_names) : ML unit = H.insert env.extern_types td.typedef_name.v (); H.insert env.extern_types td.typedef_abbrev.v () let push_name (env:qenv) (name:string) : qenv = { env with local_names = name::env.local_names } let prim_consts = [ "unit"; "Bool"; "UINT8"; "UINT16"; "UINT32"; "UINT64"; "UINT8BE"; "UINT16BE"; "UINT32BE"; "UINT64BE"; "field_id"; "PUINT8"; "all_bytes"; "all_zeros"; "is_range_okay"; "void" ] let resolve_ident (env:qenv) (i:ident) : ML ident = let resolve_to_current_module i = { i with v = { i.v with modul_name = Some env.mname } } in let maybe_resolve_as_ifdef i : ML ident = match env.global_env.ge_cfg with | None -> resolve_to_current_module i | Some (cfg, cfg_module_name) -> if List.mem i.v.name cfg.compile_time_flags.flags then { i with v = { i.v with modul_name = Some cfg_module_name } } else resolve_to_current_module i in if List.mem i.v.name prim_consts //it's a primitive constant, e.g. UINT8, leave as is then i else if List.mem i.v.name env.local_names //it's a local name (e.g. a parameter name) then (if Some? i.v.modul_name //must have module name set to None then error (Printf.sprintf "Ident %s is a local name but has a qualifying modul %s" i.v.name (Some?.v i.v.modul_name)) i.range else i) //return the local name as is else (match i.v.modul_name with //it's a top-level name | None -> maybe_resolve_as_ifdef i | Some m -> //if already qualified, check if it is an abbreviation (match H.try_find env.module_abbrevs m with | None -> i | Some m -> { i with v = { i.v with modul_name = Some m } })) let rec collect_ifdef_guards (env:qenv) (e:expr) : ML unit = let check_resolved_to_ifdef i = match env.global_env.ge_cfg with | None -> false | Some (cfg, cfg_module_name) -> List.mem i.v.name cfg.compile_time_flags.flags && i.v.modul_name = Some cfg_module_name in match e.v with | This -> error "'this' is not allowed in the guard of an #if" e.range | Static _ -> failwith "static should have been eliminated already" | Constant _ -> () | Identifier i -> if not (check_resolved_to_ifdef i) then error (Printf.sprintf "Identifier %s is not a compile-time macro but is used in a #if" i.v.name) e.range | App op args -> begin match op with | And | Or | Not -> List.iter (collect_ifdef_guards env) args | _ -> error "Only boolean expressions over identifiers are supported in #if guards" e.range end let rec resolve_expr' (env:qenv) (e:expr') r : ML expr' = match e with | Constant _ -> e | Identifier i -> Identifier (resolve_ident env i) | This -> e | Static e' -> let e' = resolve_expr env e' in collect_ifdef_guards env e';//mark any variables as top-level IfDef symbols e'.v | App op args -> let args = List.map (resolve_expr env) args in App op args and resolve_expr (env:qenv) (e:expr) : ML expr = { e with v = resolve_expr' env e.v e.range }
false
false
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val resolve_typ_param (env: qenv) (p: typ_param) : ML typ_param
[]
Desugar.resolve_typ_param
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: Desugar.qenv -> p: Ast.typ_param -> FStar.All.ML Ast.typ_param
{ "end_col": 10, "end_line": 249, "start_col": 2, "start_line": 247 }
FStar.All.ML
val resolve_params (env: qenv) (params: list param) : ML (list param & qenv)
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let resolve_params (env:qenv) (params:list param) : ML (list param & qenv) = List.fold_left (fun (params, env) p -> let p, env = resolve_param env p in params@[p], env) ([], env) params
val resolve_params (env: qenv) (params: list param) : ML (list param & qenv) let resolve_params (env: qenv) (params: list param) : ML (list param & qenv) =
true
null
false
List.fold_left (fun (params, env) p -> let p, env = resolve_param env p in params @ [p], env) ([], env) params
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "ml" ]
[ "Desugar.qenv", "Prims.list", "Ast.param", "FStar.List.fold_left", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "FStar.List.Tot.Base.op_At", "Prims.Cons", "Prims.Nil", "Desugar.resolve_param" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *) let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases let desugar_enum_cases (ityp:integer_type) (cases:list enum_case) (export:bool) : ML (list enum_case & list decl) = let find_definition (i:ident) (d:decl) = match d.d_decl.v with | Define j _ (Int _ _) -> i.v = j.v | _ -> false in let _, cases_rev, ds_rev = List.fold_left (fun (next, cases_rev, ds_rev) (i, jopt) -> let next = match jopt with | Some (Inl j) -> j | Some (Inr j) -> begin match List.Tot.find (find_definition j) ds_rev with | Some ({d_decl={v=Define _ _ (Int _ k)}}) -> k | _ -> error (Printf.sprintf "Enum identifier %s not found" (print_ident j)) j.range end | None -> next in let case = (i, None) in let d = mk_decl (Define i None (Int ityp next)) i.range ["Enum constant"] export in (next + 1, case :: cases_rev, d :: ds_rev)) (0, [], []) cases in List.rev cases_rev, List.rev ds_rev let desugar_one_enum (d:decl) : ML (list decl) = match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] //no enum value assignments; no desugaring to do else //if we have any assignments at all, then we treat all the //tags as fresh constants and assign them values in sequence //with respect to the assigned values of preceding tags let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds@[enum] | _ -> [d] (* This code is currently not used It desugars an Enum to a record with a single refined field *) // let eliminate_enum (d:decl) : ML decl = // match d.v with // | Enum t i cases -> // let names = { // typedef_name = { i with v = { i.v with name=Ast.reserved_prefix ^ Ast.reserved_prefix ^ i.v.name }}; // typedef_abbrev = i; // typedef_ptr_abbrev = { i with v = {i.v with // name = Ast.reserved_prefix ^ Ast.reserved_prefix ^ "P" ^ i.v.name }}; // typedef_attributes = []; // } in // let params = [] in // let where = None in // let field_ident = with_dummy_range (to_ident' (Ast.reserved_prefix ^ "enum_field")) in // let field_ident_expr = with_dummy_range (Identifier field_ident) in // let field_constraint = // List.fold_right // (fun (case, _) out -> // let eq = with_range (App Eq [field_ident_expr; with_range (Identifier case) case.range]) case.range in // with_dummy_range (App Or [eq; out])) // cases // (with_dummy_range (Constant (Bool false))) // in // let field = { // field_dependence = false; // field_ident = field_ident; // field_type = t; // field_array_opt = FieldScalar; // field_constraint = Some field_constraint; // field_number = None; // field_bitwidth = None; // field_action = None // } in // let d' = Record names params where [with_dummy_range field] in // {d with v = d'} // | _ -> d (* * output_types and extern_types tables to set the kind in the Typ_app nodes *) noeq type qenv = { mname : string; module_abbrevs : H.t string string; output_types : H.t ident' unit; extern_types : H.t ident' unit; local_names : list string; global_env: GlobalEnv.global_env; } let push_module_abbrev (env:qenv) (i m:string) : ML unit = H.insert env.module_abbrevs i m let push_output_type (env:qenv) (out_t:out_typ) : ML unit = H.insert env.output_types out_t.out_typ_names.typedef_name.v (); H.insert env.output_types out_t.out_typ_names.typedef_abbrev.v () let push_extern_type (env:qenv) (td:typedef_names) : ML unit = H.insert env.extern_types td.typedef_name.v (); H.insert env.extern_types td.typedef_abbrev.v () let push_name (env:qenv) (name:string) : qenv = { env with local_names = name::env.local_names } let prim_consts = [ "unit"; "Bool"; "UINT8"; "UINT16"; "UINT32"; "UINT64"; "UINT8BE"; "UINT16BE"; "UINT32BE"; "UINT64BE"; "field_id"; "PUINT8"; "all_bytes"; "all_zeros"; "is_range_okay"; "void" ] let resolve_ident (env:qenv) (i:ident) : ML ident = let resolve_to_current_module i = { i with v = { i.v with modul_name = Some env.mname } } in let maybe_resolve_as_ifdef i : ML ident = match env.global_env.ge_cfg with | None -> resolve_to_current_module i | Some (cfg, cfg_module_name) -> if List.mem i.v.name cfg.compile_time_flags.flags then { i with v = { i.v with modul_name = Some cfg_module_name } } else resolve_to_current_module i in if List.mem i.v.name prim_consts //it's a primitive constant, e.g. UINT8, leave as is then i else if List.mem i.v.name env.local_names //it's a local name (e.g. a parameter name) then (if Some? i.v.modul_name //must have module name set to None then error (Printf.sprintf "Ident %s is a local name but has a qualifying modul %s" i.v.name (Some?.v i.v.modul_name)) i.range else i) //return the local name as is else (match i.v.modul_name with //it's a top-level name | None -> maybe_resolve_as_ifdef i | Some m -> //if already qualified, check if it is an abbreviation (match H.try_find env.module_abbrevs m with | None -> i | Some m -> { i with v = { i.v with modul_name = Some m } })) let rec collect_ifdef_guards (env:qenv) (e:expr) : ML unit = let check_resolved_to_ifdef i = match env.global_env.ge_cfg with | None -> false | Some (cfg, cfg_module_name) -> List.mem i.v.name cfg.compile_time_flags.flags && i.v.modul_name = Some cfg_module_name in match e.v with | This -> error "'this' is not allowed in the guard of an #if" e.range | Static _ -> failwith "static should have been eliminated already" | Constant _ -> () | Identifier i -> if not (check_resolved_to_ifdef i) then error (Printf.sprintf "Identifier %s is not a compile-time macro but is used in a #if" i.v.name) e.range | App op args -> begin match op with | And | Or | Not -> List.iter (collect_ifdef_guards env) args | _ -> error "Only boolean expressions over identifiers are supported in #if guards" e.range end let rec resolve_expr' (env:qenv) (e:expr') r : ML expr' = match e with | Constant _ -> e | Identifier i -> Identifier (resolve_ident env i) | This -> e | Static e' -> let e' = resolve_expr env e' in collect_ifdef_guards env e';//mark any variables as top-level IfDef symbols e'.v | App op args -> let args = List.map (resolve_expr env) args in App op args and resolve_expr (env:qenv) (e:expr) : ML expr = { e with v = resolve_expr' env e.v e.range } let resolve_typ_param (env:qenv) (p:typ_param) : ML typ_param = match p with | Inl e -> resolve_expr env e |> Inl | _ -> p //Currently not going inside output expressions, should we? let kind_of_ident (env:qenv) (i:ident) : ML t_kind = let _or_ (b0 b1:bool) = b0 || b1 in if Some? (H.try_find env.output_types i.v) `_or_` Some? (H.try_find env.global_env.ge_out_t i.v) then KindOutput else if Some? (H.try_find env.extern_types i.v) `_or_` Some? (H.try_find env.global_env.ge_extern_t i.v) then KindExtern else KindSpec let rec resolve_typ' (env:qenv) (t:typ') : ML typ' = match t with | Type_app hd _ args -> let hd = resolve_ident env hd in //Set is_out argument to the Type_app appropriately let k = kind_of_ident env hd in Type_app hd k (List.map (resolve_typ_param env) args) | Pointer t -> Pointer (resolve_typ env t) and resolve_typ (env:qenv) (t:typ) : ML typ = { t with v = resolve_typ' env t.v } let resolve_atomic_action (env:qenv) (ac:atomic_action) : ML atomic_action = match ac with | Action_return e -> Action_return (resolve_expr env e) | Action_abort | Action_field_pos_64 | Action_field_pos_32 | Action_field_ptr -> ac | Action_field_ptr_after e write_to -> Action_field_ptr_after (resolve_expr env e) write_to | Action_deref i -> Action_deref i //most certainly a type parameter | Action_assignment lhs rhs -> Action_assignment lhs (resolve_expr env rhs) //lhs is an action-local variable | Action_call f args -> Action_call (resolve_ident env f) (List.map (resolve_expr env) args) let rec resolve_action' (env:qenv) (act:action') : ML action' = match act with | Atomic_action ac -> Atomic_action (resolve_atomic_action env ac) | Action_seq hd tl -> Action_seq (resolve_atomic_action env hd) (resolve_action env tl) | Action_ite hd then_ else_ -> Action_ite (resolve_expr env hd) (resolve_action env then_) (map_opt (resolve_action env) else_) | Action_let i a k -> Action_let i (resolve_atomic_action env a) (resolve_action (push_name env i.v.name) k) | Action_act a -> Action_act (resolve_action env a) and resolve_action (env:qenv) (act:action) : ML action = { act with v = resolve_action' env act.v } let resolve_param (env:qenv) (p:param) : ML (param & qenv) = let t, i, q = p in (resolve_typ env t, i, q), push_name env i.v.name
false
false
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val resolve_params (env: qenv) (params: list param) : ML (list param & qenv)
[]
Desugar.resolve_params
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: Desugar.qenv -> params: Prims.list Ast.param -> FStar.All.ML (Prims.list Ast.param * Desugar.qenv)
{ "end_col": 37, "end_line": 312, "start_col": 2, "start_line": 310 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let prim_consts = [ "unit"; "Bool"; "UINT8"; "UINT16"; "UINT32"; "UINT64"; "UINT8BE"; "UINT16BE"; "UINT32BE"; "UINT64BE"; "field_id"; "PUINT8"; "all_bytes"; "all_zeros"; "is_range_okay"; "void" ]
let prim_consts =
false
null
false
[ "unit"; "Bool"; "UINT8"; "UINT16"; "UINT32"; "UINT64"; "UINT8BE"; "UINT16BE"; "UINT32BE"; "UINT64BE"; "field_id"; "PUINT8"; "all_bytes"; "all_zeros"; "is_range_okay"; "void" ]
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "total" ]
[ "Prims.Cons", "Prims.string", "Prims.Nil" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *) let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases let desugar_enum_cases (ityp:integer_type) (cases:list enum_case) (export:bool) : ML (list enum_case & list decl) = let find_definition (i:ident) (d:decl) = match d.d_decl.v with | Define j _ (Int _ _) -> i.v = j.v | _ -> false in let _, cases_rev, ds_rev = List.fold_left (fun (next, cases_rev, ds_rev) (i, jopt) -> let next = match jopt with | Some (Inl j) -> j | Some (Inr j) -> begin match List.Tot.find (find_definition j) ds_rev with | Some ({d_decl={v=Define _ _ (Int _ k)}}) -> k | _ -> error (Printf.sprintf "Enum identifier %s not found" (print_ident j)) j.range end | None -> next in let case = (i, None) in let d = mk_decl (Define i None (Int ityp next)) i.range ["Enum constant"] export in (next + 1, case :: cases_rev, d :: ds_rev)) (0, [], []) cases in List.rev cases_rev, List.rev ds_rev let desugar_one_enum (d:decl) : ML (list decl) = match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] //no enum value assignments; no desugaring to do else //if we have any assignments at all, then we treat all the //tags as fresh constants and assign them values in sequence //with respect to the assigned values of preceding tags let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds@[enum] | _ -> [d] (* This code is currently not used It desugars an Enum to a record with a single refined field *) // let eliminate_enum (d:decl) : ML decl = // match d.v with // | Enum t i cases -> // let names = { // typedef_name = { i with v = { i.v with name=Ast.reserved_prefix ^ Ast.reserved_prefix ^ i.v.name }}; // typedef_abbrev = i; // typedef_ptr_abbrev = { i with v = {i.v with // name = Ast.reserved_prefix ^ Ast.reserved_prefix ^ "P" ^ i.v.name }}; // typedef_attributes = []; // } in // let params = [] in // let where = None in // let field_ident = with_dummy_range (to_ident' (Ast.reserved_prefix ^ "enum_field")) in // let field_ident_expr = with_dummy_range (Identifier field_ident) in // let field_constraint = // List.fold_right // (fun (case, _) out -> // let eq = with_range (App Eq [field_ident_expr; with_range (Identifier case) case.range]) case.range in // with_dummy_range (App Or [eq; out])) // cases // (with_dummy_range (Constant (Bool false))) // in // let field = { // field_dependence = false; // field_ident = field_ident; // field_type = t; // field_array_opt = FieldScalar; // field_constraint = Some field_constraint; // field_number = None; // field_bitwidth = None; // field_action = None // } in // let d' = Record names params where [with_dummy_range field] in // {d with v = d'} // | _ -> d (* * output_types and extern_types tables to set the kind in the Typ_app nodes *) noeq type qenv = { mname : string; module_abbrevs : H.t string string; output_types : H.t ident' unit; extern_types : H.t ident' unit; local_names : list string; global_env: GlobalEnv.global_env; } let push_module_abbrev (env:qenv) (i m:string) : ML unit = H.insert env.module_abbrevs i m let push_output_type (env:qenv) (out_t:out_typ) : ML unit = H.insert env.output_types out_t.out_typ_names.typedef_name.v (); H.insert env.output_types out_t.out_typ_names.typedef_abbrev.v () let push_extern_type (env:qenv) (td:typedef_names) : ML unit = H.insert env.extern_types td.typedef_name.v (); H.insert env.extern_types td.typedef_abbrev.v () let push_name (env:qenv) (name:string) : qenv = { env with local_names = name::env.local_names }
false
true
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val prim_consts : Prims.list Prims.string
[]
Desugar.prim_consts
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
Prims.list Prims.string
{ "end_col": 10, "end_line": 172, "start_col": 18, "start_line": 166 }
FStar.All.ML
val check_desugared_enum_cases (cases: list enum_case) : ML (list ident)
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases
val check_desugared_enum_cases (cases: list enum_case) : ML (list ident) let check_desugared_enum_cases (cases: list enum_case) : ML (list ident) =
true
null
false
List.map (function | i, None -> i | i, _ -> failwith "Enum should already have been desugared") cases
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "ml" ]
[ "Prims.list", "Ast.enum_case", "FStar.List.map", "FStar.Pervasives.Native.tuple2", "Ast.ident", "FStar.Pervasives.Native.option", "Ast.either", "Prims.int", "FStar.All.failwith" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *)
false
false
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val check_desugared_enum_cases (cases: list enum_case) : ML (list ident)
[]
Desugar.check_desugared_enum_cases
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
cases: Prims.list Ast.enum_case -> FStar.All.ML (Prims.list Ast.ident)
{ "end_col": 10, "end_line": 44, "start_col": 4, "start_line": 40 }
FStar.All.ML
val resolve_atomic_field (env: qenv) (f: atomic_field) : ML (atomic_field & qenv)
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec resolve_field (env:qenv) (ff:field) : ML (field & qenv) = match ff.v with | AtomicField f -> let f, e = resolve_atomic_field env f in {ff with v = AtomicField f}, e | RecordField f i -> let fs, _ = resolve_fields env f in {ff with v = RecordField fs i}, env //record fields are not in scope outside the record | SwitchCaseField f i -> let f = resolve_switch_case env f in {ff with v = SwitchCaseField f i}, env and resolve_atomic_field (env:qenv) (f:atomic_field) : ML (atomic_field & qenv) = let resolve_atomic_field' (env:qenv) (sf:atomic_field') : ML atomic_field' = { sf with field_type = resolve_typ env sf.field_type; field_array_opt = resolve_field_array_t env sf.field_array_opt; field_constraint = map_opt (resolve_expr env) sf.field_constraint; field_bitwidth = map_opt (resolve_field_bitwidth_t env) sf.field_bitwidth; field_action = map_opt (fun (a, b) -> resolve_action env a, b) sf.field_action } in let env = push_name env f.v.field_ident.v.name in { f with v = resolve_atomic_field' env f.v }, env and resolve_fields (env:qenv) (flds:list field) : ML (list field & qenv) = List.fold_left (fun (flds, env) f -> let f, env = resolve_field env f in flds@[f], env) ([], env) flds and resolve_switch_case (env:qenv) (sc:switch_case) : ML switch_case = //case fields do not escape their scope let resolve_case (env:qenv) (c:case) : ML case = match c with | Case e f -> Case (resolve_expr env e) (fst (resolve_field env f)) | DefaultCase f -> DefaultCase (fst (resolve_field env f)) in let e, l = sc in resolve_expr env e, List.map (resolve_case env) l
val resolve_atomic_field (env: qenv) (f: atomic_field) : ML (atomic_field & qenv) let rec resolve_atomic_field (env: qenv) (f: atomic_field) : ML (atomic_field & qenv) =
true
null
false
let resolve_atomic_field' (env: qenv) (sf: atomic_field') : ML atomic_field' = { sf with field_type = resolve_typ env sf.field_type; field_array_opt = resolve_field_array_t env sf.field_array_opt; field_constraint = map_opt (resolve_expr env) sf.field_constraint; field_bitwidth = map_opt (resolve_field_bitwidth_t env) sf.field_bitwidth; field_action = map_opt (fun (a, b) -> resolve_action env a, b) sf.field_action } in let env = push_name env f.v.field_ident.v.name in { f with v = resolve_atomic_field' env f.v }, env
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "ml" ]
[ "Desugar.qenv", "Ast.atomic_field", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "Ast.Mkwith_meta_t", "Ast.atomic_field'", "Ast.__proj__Mkwith_meta_t__item__range", "Ast.__proj__Mkwith_meta_t__item__comments", "Ast.__proj__Mkwith_meta_t__item__v", "Desugar.push_name", "Ast.__proj__Mkident'__item__name", "Ast.ident'", "Ast.__proj__Mkatomic_field'__item__field_ident", "Ast.Mkatomic_field'", "Ast.__proj__Mkatomic_field'__item__field_dependence", "FStar.Pervasives.Native.option", "Ast.action", "Prims.bool", "Ast.map_opt", "Desugar.resolve_action", "Ast.__proj__Mkatomic_field'__item__field_action", "Ast.field_bitwidth_t", "Desugar.resolve_field_bitwidth_t", "Ast.__proj__Mkatomic_field'__item__field_bitwidth", "Ast.expr", "Desugar.resolve_expr", "Ast.__proj__Mkatomic_field'__item__field_constraint", "Ast.field_array_t", "Desugar.resolve_field_array_t", "Ast.__proj__Mkatomic_field'__item__field_array_opt", "Ast.typ", "Desugar.resolve_typ", "Ast.__proj__Mkatomic_field'__item__field_type" ]
[ "resolve_field", "resolve_atomic_field", "resolve_fields", "resolve_switch_case" ]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *) let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases let desugar_enum_cases (ityp:integer_type) (cases:list enum_case) (export:bool) : ML (list enum_case & list decl) = let find_definition (i:ident) (d:decl) = match d.d_decl.v with | Define j _ (Int _ _) -> i.v = j.v | _ -> false in let _, cases_rev, ds_rev = List.fold_left (fun (next, cases_rev, ds_rev) (i, jopt) -> let next = match jopt with | Some (Inl j) -> j | Some (Inr j) -> begin match List.Tot.find (find_definition j) ds_rev with | Some ({d_decl={v=Define _ _ (Int _ k)}}) -> k | _ -> error (Printf.sprintf "Enum identifier %s not found" (print_ident j)) j.range end | None -> next in let case = (i, None) in let d = mk_decl (Define i None (Int ityp next)) i.range ["Enum constant"] export in (next + 1, case :: cases_rev, d :: ds_rev)) (0, [], []) cases in List.rev cases_rev, List.rev ds_rev let desugar_one_enum (d:decl) : ML (list decl) = match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] //no enum value assignments; no desugaring to do else //if we have any assignments at all, then we treat all the //tags as fresh constants and assign them values in sequence //with respect to the assigned values of preceding tags let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds@[enum] | _ -> [d] (* This code is currently not used It desugars an Enum to a record with a single refined field *) // let eliminate_enum (d:decl) : ML decl = // match d.v with // | Enum t i cases -> // let names = { // typedef_name = { i with v = { i.v with name=Ast.reserved_prefix ^ Ast.reserved_prefix ^ i.v.name }}; // typedef_abbrev = i; // typedef_ptr_abbrev = { i with v = {i.v with // name = Ast.reserved_prefix ^ Ast.reserved_prefix ^ "P" ^ i.v.name }}; // typedef_attributes = []; // } in // let params = [] in // let where = None in // let field_ident = with_dummy_range (to_ident' (Ast.reserved_prefix ^ "enum_field")) in // let field_ident_expr = with_dummy_range (Identifier field_ident) in // let field_constraint = // List.fold_right // (fun (case, _) out -> // let eq = with_range (App Eq [field_ident_expr; with_range (Identifier case) case.range]) case.range in // with_dummy_range (App Or [eq; out])) // cases // (with_dummy_range (Constant (Bool false))) // in // let field = { // field_dependence = false; // field_ident = field_ident; // field_type = t; // field_array_opt = FieldScalar; // field_constraint = Some field_constraint; // field_number = None; // field_bitwidth = None; // field_action = None // } in // let d' = Record names params where [with_dummy_range field] in // {d with v = d'} // | _ -> d (* * output_types and extern_types tables to set the kind in the Typ_app nodes *) noeq type qenv = { mname : string; module_abbrevs : H.t string string; output_types : H.t ident' unit; extern_types : H.t ident' unit; local_names : list string; global_env: GlobalEnv.global_env; } let push_module_abbrev (env:qenv) (i m:string) : ML unit = H.insert env.module_abbrevs i m let push_output_type (env:qenv) (out_t:out_typ) : ML unit = H.insert env.output_types out_t.out_typ_names.typedef_name.v (); H.insert env.output_types out_t.out_typ_names.typedef_abbrev.v () let push_extern_type (env:qenv) (td:typedef_names) : ML unit = H.insert env.extern_types td.typedef_name.v (); H.insert env.extern_types td.typedef_abbrev.v () let push_name (env:qenv) (name:string) : qenv = { env with local_names = name::env.local_names } let prim_consts = [ "unit"; "Bool"; "UINT8"; "UINT16"; "UINT32"; "UINT64"; "UINT8BE"; "UINT16BE"; "UINT32BE"; "UINT64BE"; "field_id"; "PUINT8"; "all_bytes"; "all_zeros"; "is_range_okay"; "void" ] let resolve_ident (env:qenv) (i:ident) : ML ident = let resolve_to_current_module i = { i with v = { i.v with modul_name = Some env.mname } } in let maybe_resolve_as_ifdef i : ML ident = match env.global_env.ge_cfg with | None -> resolve_to_current_module i | Some (cfg, cfg_module_name) -> if List.mem i.v.name cfg.compile_time_flags.flags then { i with v = { i.v with modul_name = Some cfg_module_name } } else resolve_to_current_module i in if List.mem i.v.name prim_consts //it's a primitive constant, e.g. UINT8, leave as is then i else if List.mem i.v.name env.local_names //it's a local name (e.g. a parameter name) then (if Some? i.v.modul_name //must have module name set to None then error (Printf.sprintf "Ident %s is a local name but has a qualifying modul %s" i.v.name (Some?.v i.v.modul_name)) i.range else i) //return the local name as is else (match i.v.modul_name with //it's a top-level name | None -> maybe_resolve_as_ifdef i | Some m -> //if already qualified, check if it is an abbreviation (match H.try_find env.module_abbrevs m with | None -> i | Some m -> { i with v = { i.v with modul_name = Some m } })) let rec collect_ifdef_guards (env:qenv) (e:expr) : ML unit = let check_resolved_to_ifdef i = match env.global_env.ge_cfg with | None -> false | Some (cfg, cfg_module_name) -> List.mem i.v.name cfg.compile_time_flags.flags && i.v.modul_name = Some cfg_module_name in match e.v with | This -> error "'this' is not allowed in the guard of an #if" e.range | Static _ -> failwith "static should have been eliminated already" | Constant _ -> () | Identifier i -> if not (check_resolved_to_ifdef i) then error (Printf.sprintf "Identifier %s is not a compile-time macro but is used in a #if" i.v.name) e.range | App op args -> begin match op with | And | Or | Not -> List.iter (collect_ifdef_guards env) args | _ -> error "Only boolean expressions over identifiers are supported in #if guards" e.range end let rec resolve_expr' (env:qenv) (e:expr') r : ML expr' = match e with | Constant _ -> e | Identifier i -> Identifier (resolve_ident env i) | This -> e | Static e' -> let e' = resolve_expr env e' in collect_ifdef_guards env e';//mark any variables as top-level IfDef symbols e'.v | App op args -> let args = List.map (resolve_expr env) args in App op args and resolve_expr (env:qenv) (e:expr) : ML expr = { e with v = resolve_expr' env e.v e.range } let resolve_typ_param (env:qenv) (p:typ_param) : ML typ_param = match p with | Inl e -> resolve_expr env e |> Inl | _ -> p //Currently not going inside output expressions, should we? let kind_of_ident (env:qenv) (i:ident) : ML t_kind = let _or_ (b0 b1:bool) = b0 || b1 in if Some? (H.try_find env.output_types i.v) `_or_` Some? (H.try_find env.global_env.ge_out_t i.v) then KindOutput else if Some? (H.try_find env.extern_types i.v) `_or_` Some? (H.try_find env.global_env.ge_extern_t i.v) then KindExtern else KindSpec let rec resolve_typ' (env:qenv) (t:typ') : ML typ' = match t with | Type_app hd _ args -> let hd = resolve_ident env hd in //Set is_out argument to the Type_app appropriately let k = kind_of_ident env hd in Type_app hd k (List.map (resolve_typ_param env) args) | Pointer t -> Pointer (resolve_typ env t) and resolve_typ (env:qenv) (t:typ) : ML typ = { t with v = resolve_typ' env t.v } let resolve_atomic_action (env:qenv) (ac:atomic_action) : ML atomic_action = match ac with | Action_return e -> Action_return (resolve_expr env e) | Action_abort | Action_field_pos_64 | Action_field_pos_32 | Action_field_ptr -> ac | Action_field_ptr_after e write_to -> Action_field_ptr_after (resolve_expr env e) write_to | Action_deref i -> Action_deref i //most certainly a type parameter | Action_assignment lhs rhs -> Action_assignment lhs (resolve_expr env rhs) //lhs is an action-local variable | Action_call f args -> Action_call (resolve_ident env f) (List.map (resolve_expr env) args) let rec resolve_action' (env:qenv) (act:action') : ML action' = match act with | Atomic_action ac -> Atomic_action (resolve_atomic_action env ac) | Action_seq hd tl -> Action_seq (resolve_atomic_action env hd) (resolve_action env tl) | Action_ite hd then_ else_ -> Action_ite (resolve_expr env hd) (resolve_action env then_) (map_opt (resolve_action env) else_) | Action_let i a k -> Action_let i (resolve_atomic_action env a) (resolve_action (push_name env i.v.name) k) | Action_act a -> Action_act (resolve_action env a) and resolve_action (env:qenv) (act:action) : ML action = { act with v = resolve_action' env act.v } let resolve_param (env:qenv) (p:param) : ML (param & qenv) = let t, i, q = p in (resolve_typ env t, i, q), push_name env i.v.name let resolve_params (env:qenv) (params:list param) : ML (list param & qenv) = List.fold_left (fun (params, env) p -> let p, env = resolve_param env p in params@[p], env) ([], env) params let resolve_field_bitwidth_t (env:qenv) (fb:field_bitwidth_t) : ML field_bitwidth_t = let resolve_bitfield_attr' (env:qenv) (b:bitfield_attr') : ML bitfield_attr' = { b with bitfield_type = resolve_typ env b.bitfield_type } in let resolve_bitfield_attr (env:qenv) (b:bitfield_attr) : ML bitfield_attr = { b with v = resolve_bitfield_attr' env b.v } in match fb with | Inl _ -> fb | Inr b -> Inr (resolve_bitfield_attr env b) let resolve_field_array_t (env:qenv) (farr:field_array_t) : ML field_array_t = match farr with | FieldScalar -> farr | FieldArrayQualified (e, aq) -> FieldArrayQualified (resolve_expr env e, aq) | FieldString None -> farr | FieldString (Some e) -> FieldString (Some (resolve_expr env e)) let rec resolve_field (env:qenv) (ff:field) : ML (field & qenv) = match ff.v with | AtomicField f -> let f, e = resolve_atomic_field env f in {ff with v = AtomicField f}, e | RecordField f i -> let fs, _ = resolve_fields env f in {ff with v = RecordField fs i}, env //record fields are not in scope outside the record | SwitchCaseField f i -> let f = resolve_switch_case env f in {ff with v = SwitchCaseField f i}, env
false
false
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val resolve_atomic_field (env: qenv) (f: atomic_field) : ML (atomic_field & qenv)
[ "mutual recursion" ]
Desugar.resolve_atomic_field
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: Desugar.qenv -> f: Ast.atomic_field -> FStar.All.ML (Ast.atomic_field * Desugar.qenv)
{ "end_col": 51, "end_line": 349, "start_col": 81, "start_line": 339 }
FStar.All.ML
val desugar_one_enum (d: decl) : ML (list decl)
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let desugar_one_enum (d:decl) : ML (list decl) = match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] //no enum value assignments; no desugaring to do else //if we have any assignments at all, then we treat all the //tags as fresh constants and assign them values in sequence //with respect to the assigned values of preceding tags let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds@[enum] | _ -> [d]
val desugar_one_enum (d: decl) : ML (list decl) let desugar_one_enum (d: decl) : ML (list decl) =
true
null
false
match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] else let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds @ [enum] | _ -> [d]
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "ml" ]
[ "Ast.decl", "Ast.__proj__Mkwith_meta_t__item__v", "Ast.decl'", "Ast.__proj__Mkdecl__item__d_decl", "Ast.typ", "Ast.ident", "Prims.list", "Ast.enum_case", "Prims.Cons", "Prims.Nil", "Prims.bool", "FStar.List.Tot.Base.op_At", "Ast.decl_with_v", "Ast.Enum", "FStar.Pervasives.Native.tuple2", "Desugar.desugar_enum_cases", "Ast.__proj__Mkdecl__item__d_exported", "Ast.integer_type", "Ast.typ_as_integer_type", "FStar.List.for_all", "FStar.Pervasives.Native.option", "Ast.either", "Prims.int", "FStar.Pervasives.Native.uu___is_None" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *) let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases let desugar_enum_cases (ityp:integer_type) (cases:list enum_case) (export:bool) : ML (list enum_case & list decl) = let find_definition (i:ident) (d:decl) = match d.d_decl.v with | Define j _ (Int _ _) -> i.v = j.v | _ -> false in let _, cases_rev, ds_rev = List.fold_left (fun (next, cases_rev, ds_rev) (i, jopt) -> let next = match jopt with | Some (Inl j) -> j | Some (Inr j) -> begin match List.Tot.find (find_definition j) ds_rev with | Some ({d_decl={v=Define _ _ (Int _ k)}}) -> k | _ -> error (Printf.sprintf "Enum identifier %s not found" (print_ident j)) j.range end | None -> next in let case = (i, None) in let d = mk_decl (Define i None (Int ityp next)) i.range ["Enum constant"] export in (next + 1, case :: cases_rev, d :: ds_rev)) (0, [], []) cases in List.rev cases_rev, List.rev ds_rev
false
false
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val desugar_one_enum (d: decl) : ML (list decl)
[]
Desugar.desugar_one_enum
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
d: Ast.decl -> FStar.All.ML (Prims.list Ast.decl)
{ "end_col": 12, "end_line": 96, "start_col": 2, "start_line": 86 }
FStar.All.ML
val push_module_abbrev (env: qenv) (i m: string) : ML unit
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let push_module_abbrev (env:qenv) (i m:string) : ML unit = H.insert env.module_abbrevs i m
val push_module_abbrev (env: qenv) (i m: string) : ML unit let push_module_abbrev (env: qenv) (i m: string) : ML unit =
true
null
false
H.insert env.module_abbrevs i m
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "ml" ]
[ "Desugar.qenv", "Prims.string", "Hashtable.insert", "Desugar.__proj__Mkqenv__item__module_abbrevs", "Prims.unit" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *) let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases let desugar_enum_cases (ityp:integer_type) (cases:list enum_case) (export:bool) : ML (list enum_case & list decl) = let find_definition (i:ident) (d:decl) = match d.d_decl.v with | Define j _ (Int _ _) -> i.v = j.v | _ -> false in let _, cases_rev, ds_rev = List.fold_left (fun (next, cases_rev, ds_rev) (i, jopt) -> let next = match jopt with | Some (Inl j) -> j | Some (Inr j) -> begin match List.Tot.find (find_definition j) ds_rev with | Some ({d_decl={v=Define _ _ (Int _ k)}}) -> k | _ -> error (Printf.sprintf "Enum identifier %s not found" (print_ident j)) j.range end | None -> next in let case = (i, None) in let d = mk_decl (Define i None (Int ityp next)) i.range ["Enum constant"] export in (next + 1, case :: cases_rev, d :: ds_rev)) (0, [], []) cases in List.rev cases_rev, List.rev ds_rev let desugar_one_enum (d:decl) : ML (list decl) = match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] //no enum value assignments; no desugaring to do else //if we have any assignments at all, then we treat all the //tags as fresh constants and assign them values in sequence //with respect to the assigned values of preceding tags let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds@[enum] | _ -> [d] (* This code is currently not used It desugars an Enum to a record with a single refined field *) // let eliminate_enum (d:decl) : ML decl = // match d.v with // | Enum t i cases -> // let names = { // typedef_name = { i with v = { i.v with name=Ast.reserved_prefix ^ Ast.reserved_prefix ^ i.v.name }}; // typedef_abbrev = i; // typedef_ptr_abbrev = { i with v = {i.v with // name = Ast.reserved_prefix ^ Ast.reserved_prefix ^ "P" ^ i.v.name }}; // typedef_attributes = []; // } in // let params = [] in // let where = None in // let field_ident = with_dummy_range (to_ident' (Ast.reserved_prefix ^ "enum_field")) in // let field_ident_expr = with_dummy_range (Identifier field_ident) in // let field_constraint = // List.fold_right // (fun (case, _) out -> // let eq = with_range (App Eq [field_ident_expr; with_range (Identifier case) case.range]) case.range in // with_dummy_range (App Or [eq; out])) // cases // (with_dummy_range (Constant (Bool false))) // in // let field = { // field_dependence = false; // field_ident = field_ident; // field_type = t; // field_array_opt = FieldScalar; // field_constraint = Some field_constraint; // field_number = None; // field_bitwidth = None; // field_action = None // } in // let d' = Record names params where [with_dummy_range field] in // {d with v = d'} // | _ -> d (* * output_types and extern_types tables to set the kind in the Typ_app nodes *) noeq type qenv = { mname : string; module_abbrevs : H.t string string; output_types : H.t ident' unit; extern_types : H.t ident' unit; local_names : list string; global_env: GlobalEnv.global_env; }
false
false
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val push_module_abbrev (env: qenv) (i m: string) : ML unit
[]
Desugar.push_module_abbrev
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: Desugar.qenv -> i: Prims.string -> m: Prims.string -> FStar.All.ML Prims.unit
{ "end_col": 33, "end_line": 153, "start_col": 2, "start_line": 153 }
FStar.All.ML
val resolve_typedef_names (env: qenv) (td_names: typedef_names) : ML typedef_names
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let resolve_typedef_names (env:qenv) (td_names:typedef_names) : ML typedef_names = { td_names with typedef_name = resolve_ident env td_names.typedef_name; typedef_abbrev = resolve_ident env td_names.typedef_abbrev; typedef_ptr_abbrev = resolve_ident env td_names.typedef_ptr_abbrev }
val resolve_typedef_names (env: qenv) (td_names: typedef_names) : ML typedef_names let resolve_typedef_names (env: qenv) (td_names: typedef_names) : ML typedef_names =
true
null
false
{ td_names with typedef_name = resolve_ident env td_names.typedef_name; typedef_abbrev = resolve_ident env td_names.typedef_abbrev; typedef_ptr_abbrev = resolve_ident env td_names.typedef_ptr_abbrev }
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "ml" ]
[ "Desugar.qenv", "Ast.typedef_names", "Ast.Mktypedef_names", "Ast.__proj__Mktypedef_names__item__typedef_attributes", "Ast.ident", "Desugar.resolve_ident", "Ast.__proj__Mktypedef_names__item__typedef_ptr_abbrev", "Ast.__proj__Mktypedef_names__item__typedef_abbrev", "Ast.__proj__Mktypedef_names__item__typedef_name" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *) let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases let desugar_enum_cases (ityp:integer_type) (cases:list enum_case) (export:bool) : ML (list enum_case & list decl) = let find_definition (i:ident) (d:decl) = match d.d_decl.v with | Define j _ (Int _ _) -> i.v = j.v | _ -> false in let _, cases_rev, ds_rev = List.fold_left (fun (next, cases_rev, ds_rev) (i, jopt) -> let next = match jopt with | Some (Inl j) -> j | Some (Inr j) -> begin match List.Tot.find (find_definition j) ds_rev with | Some ({d_decl={v=Define _ _ (Int _ k)}}) -> k | _ -> error (Printf.sprintf "Enum identifier %s not found" (print_ident j)) j.range end | None -> next in let case = (i, None) in let d = mk_decl (Define i None (Int ityp next)) i.range ["Enum constant"] export in (next + 1, case :: cases_rev, d :: ds_rev)) (0, [], []) cases in List.rev cases_rev, List.rev ds_rev let desugar_one_enum (d:decl) : ML (list decl) = match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] //no enum value assignments; no desugaring to do else //if we have any assignments at all, then we treat all the //tags as fresh constants and assign them values in sequence //with respect to the assigned values of preceding tags let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds@[enum] | _ -> [d] (* This code is currently not used It desugars an Enum to a record with a single refined field *) // let eliminate_enum (d:decl) : ML decl = // match d.v with // | Enum t i cases -> // let names = { // typedef_name = { i with v = { i.v with name=Ast.reserved_prefix ^ Ast.reserved_prefix ^ i.v.name }}; // typedef_abbrev = i; // typedef_ptr_abbrev = { i with v = {i.v with // name = Ast.reserved_prefix ^ Ast.reserved_prefix ^ "P" ^ i.v.name }}; // typedef_attributes = []; // } in // let params = [] in // let where = None in // let field_ident = with_dummy_range (to_ident' (Ast.reserved_prefix ^ "enum_field")) in // let field_ident_expr = with_dummy_range (Identifier field_ident) in // let field_constraint = // List.fold_right // (fun (case, _) out -> // let eq = with_range (App Eq [field_ident_expr; with_range (Identifier case) case.range]) case.range in // with_dummy_range (App Or [eq; out])) // cases // (with_dummy_range (Constant (Bool false))) // in // let field = { // field_dependence = false; // field_ident = field_ident; // field_type = t; // field_array_opt = FieldScalar; // field_constraint = Some field_constraint; // field_number = None; // field_bitwidth = None; // field_action = None // } in // let d' = Record names params where [with_dummy_range field] in // {d with v = d'} // | _ -> d (* * output_types and extern_types tables to set the kind in the Typ_app nodes *) noeq type qenv = { mname : string; module_abbrevs : H.t string string; output_types : H.t ident' unit; extern_types : H.t ident' unit; local_names : list string; global_env: GlobalEnv.global_env; } let push_module_abbrev (env:qenv) (i m:string) : ML unit = H.insert env.module_abbrevs i m let push_output_type (env:qenv) (out_t:out_typ) : ML unit = H.insert env.output_types out_t.out_typ_names.typedef_name.v (); H.insert env.output_types out_t.out_typ_names.typedef_abbrev.v () let push_extern_type (env:qenv) (td:typedef_names) : ML unit = H.insert env.extern_types td.typedef_name.v (); H.insert env.extern_types td.typedef_abbrev.v () let push_name (env:qenv) (name:string) : qenv = { env with local_names = name::env.local_names } let prim_consts = [ "unit"; "Bool"; "UINT8"; "UINT16"; "UINT32"; "UINT64"; "UINT8BE"; "UINT16BE"; "UINT32BE"; "UINT64BE"; "field_id"; "PUINT8"; "all_bytes"; "all_zeros"; "is_range_okay"; "void" ] let resolve_ident (env:qenv) (i:ident) : ML ident = let resolve_to_current_module i = { i with v = { i.v with modul_name = Some env.mname } } in let maybe_resolve_as_ifdef i : ML ident = match env.global_env.ge_cfg with | None -> resolve_to_current_module i | Some (cfg, cfg_module_name) -> if List.mem i.v.name cfg.compile_time_flags.flags then { i with v = { i.v with modul_name = Some cfg_module_name } } else resolve_to_current_module i in if List.mem i.v.name prim_consts //it's a primitive constant, e.g. UINT8, leave as is then i else if List.mem i.v.name env.local_names //it's a local name (e.g. a parameter name) then (if Some? i.v.modul_name //must have module name set to None then error (Printf.sprintf "Ident %s is a local name but has a qualifying modul %s" i.v.name (Some?.v i.v.modul_name)) i.range else i) //return the local name as is else (match i.v.modul_name with //it's a top-level name | None -> maybe_resolve_as_ifdef i | Some m -> //if already qualified, check if it is an abbreviation (match H.try_find env.module_abbrevs m with | None -> i | Some m -> { i with v = { i.v with modul_name = Some m } })) let rec collect_ifdef_guards (env:qenv) (e:expr) : ML unit = let check_resolved_to_ifdef i = match env.global_env.ge_cfg with | None -> false | Some (cfg, cfg_module_name) -> List.mem i.v.name cfg.compile_time_flags.flags && i.v.modul_name = Some cfg_module_name in match e.v with | This -> error "'this' is not allowed in the guard of an #if" e.range | Static _ -> failwith "static should have been eliminated already" | Constant _ -> () | Identifier i -> if not (check_resolved_to_ifdef i) then error (Printf.sprintf "Identifier %s is not a compile-time macro but is used in a #if" i.v.name) e.range | App op args -> begin match op with | And | Or | Not -> List.iter (collect_ifdef_guards env) args | _ -> error "Only boolean expressions over identifiers are supported in #if guards" e.range end let rec resolve_expr' (env:qenv) (e:expr') r : ML expr' = match e with | Constant _ -> e | Identifier i -> Identifier (resolve_ident env i) | This -> e | Static e' -> let e' = resolve_expr env e' in collect_ifdef_guards env e';//mark any variables as top-level IfDef symbols e'.v | App op args -> let args = List.map (resolve_expr env) args in App op args and resolve_expr (env:qenv) (e:expr) : ML expr = { e with v = resolve_expr' env e.v e.range } let resolve_typ_param (env:qenv) (p:typ_param) : ML typ_param = match p with | Inl e -> resolve_expr env e |> Inl | _ -> p //Currently not going inside output expressions, should we? let kind_of_ident (env:qenv) (i:ident) : ML t_kind = let _or_ (b0 b1:bool) = b0 || b1 in if Some? (H.try_find env.output_types i.v) `_or_` Some? (H.try_find env.global_env.ge_out_t i.v) then KindOutput else if Some? (H.try_find env.extern_types i.v) `_or_` Some? (H.try_find env.global_env.ge_extern_t i.v) then KindExtern else KindSpec let rec resolve_typ' (env:qenv) (t:typ') : ML typ' = match t with | Type_app hd _ args -> let hd = resolve_ident env hd in //Set is_out argument to the Type_app appropriately let k = kind_of_ident env hd in Type_app hd k (List.map (resolve_typ_param env) args) | Pointer t -> Pointer (resolve_typ env t) and resolve_typ (env:qenv) (t:typ) : ML typ = { t with v = resolve_typ' env t.v } let resolve_atomic_action (env:qenv) (ac:atomic_action) : ML atomic_action = match ac with | Action_return e -> Action_return (resolve_expr env e) | Action_abort | Action_field_pos_64 | Action_field_pos_32 | Action_field_ptr -> ac | Action_field_ptr_after e write_to -> Action_field_ptr_after (resolve_expr env e) write_to | Action_deref i -> Action_deref i //most certainly a type parameter | Action_assignment lhs rhs -> Action_assignment lhs (resolve_expr env rhs) //lhs is an action-local variable | Action_call f args -> Action_call (resolve_ident env f) (List.map (resolve_expr env) args) let rec resolve_action' (env:qenv) (act:action') : ML action' = match act with | Atomic_action ac -> Atomic_action (resolve_atomic_action env ac) | Action_seq hd tl -> Action_seq (resolve_atomic_action env hd) (resolve_action env tl) | Action_ite hd then_ else_ -> Action_ite (resolve_expr env hd) (resolve_action env then_) (map_opt (resolve_action env) else_) | Action_let i a k -> Action_let i (resolve_atomic_action env a) (resolve_action (push_name env i.v.name) k) | Action_act a -> Action_act (resolve_action env a) and resolve_action (env:qenv) (act:action) : ML action = { act with v = resolve_action' env act.v } let resolve_param (env:qenv) (p:param) : ML (param & qenv) = let t, i, q = p in (resolve_typ env t, i, q), push_name env i.v.name let resolve_params (env:qenv) (params:list param) : ML (list param & qenv) = List.fold_left (fun (params, env) p -> let p, env = resolve_param env p in params@[p], env) ([], env) params let resolve_field_bitwidth_t (env:qenv) (fb:field_bitwidth_t) : ML field_bitwidth_t = let resolve_bitfield_attr' (env:qenv) (b:bitfield_attr') : ML bitfield_attr' = { b with bitfield_type = resolve_typ env b.bitfield_type } in let resolve_bitfield_attr (env:qenv) (b:bitfield_attr) : ML bitfield_attr = { b with v = resolve_bitfield_attr' env b.v } in match fb with | Inl _ -> fb | Inr b -> Inr (resolve_bitfield_attr env b) let resolve_field_array_t (env:qenv) (farr:field_array_t) : ML field_array_t = match farr with | FieldScalar -> farr | FieldArrayQualified (e, aq) -> FieldArrayQualified (resolve_expr env e, aq) | FieldString None -> farr | FieldString (Some e) -> FieldString (Some (resolve_expr env e)) let rec resolve_field (env:qenv) (ff:field) : ML (field & qenv) = match ff.v with | AtomicField f -> let f, e = resolve_atomic_field env f in {ff with v = AtomicField f}, e | RecordField f i -> let fs, _ = resolve_fields env f in {ff with v = RecordField fs i}, env //record fields are not in scope outside the record | SwitchCaseField f i -> let f = resolve_switch_case env f in {ff with v = SwitchCaseField f i}, env and resolve_atomic_field (env:qenv) (f:atomic_field) : ML (atomic_field & qenv) = let resolve_atomic_field' (env:qenv) (sf:atomic_field') : ML atomic_field' = { sf with field_type = resolve_typ env sf.field_type; field_array_opt = resolve_field_array_t env sf.field_array_opt; field_constraint = map_opt (resolve_expr env) sf.field_constraint; field_bitwidth = map_opt (resolve_field_bitwidth_t env) sf.field_bitwidth; field_action = map_opt (fun (a, b) -> resolve_action env a, b) sf.field_action } in let env = push_name env f.v.field_ident.v.name in { f with v = resolve_atomic_field' env f.v }, env and resolve_fields (env:qenv) (flds:list field) : ML (list field & qenv) = List.fold_left (fun (flds, env) f -> let f, env = resolve_field env f in flds@[f], env) ([], env) flds and resolve_switch_case (env:qenv) (sc:switch_case) : ML switch_case = //case fields do not escape their scope let resolve_case (env:qenv) (c:case) : ML case = match c with | Case e f -> Case (resolve_expr env e) (fst (resolve_field env f)) | DefaultCase f -> DefaultCase (fst (resolve_field env f)) in let e, l = sc in resolve_expr env e, List.map (resolve_case env) l
false
false
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val resolve_typedef_names (env: qenv) (td_names: typedef_names) : ML typedef_names
[]
Desugar.resolve_typedef_names
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: Desugar.qenv -> td_names: Ast.typedef_names -> FStar.All.ML Ast.typedef_names
{ "end_col": 70, "end_line": 369, "start_col": 4, "start_line": 366 }
FStar.All.ML
val resolve_param (env: qenv) (p: param) : ML (param & qenv)
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let resolve_param (env:qenv) (p:param) : ML (param & qenv) = let t, i, q = p in (resolve_typ env t, i, q), push_name env i.v.name
val resolve_param (env: qenv) (p: param) : ML (param & qenv) let resolve_param (env: qenv) (p: param) : ML (param & qenv) =
true
null
false
let t, i, q = p in (resolve_typ env t, i, q), push_name env i.v.name
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "ml" ]
[ "Desugar.qenv", "Ast.param", "Ast.typ", "Ast.ident", "Ast.qualifier", "FStar.Pervasives.Native.Mktuple2", "Desugar.push_name", "Ast.__proj__Mkident'__item__name", "Ast.__proj__Mkwith_meta_t__item__v", "Ast.ident'", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple3", "Desugar.resolve_typ" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *) let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases let desugar_enum_cases (ityp:integer_type) (cases:list enum_case) (export:bool) : ML (list enum_case & list decl) = let find_definition (i:ident) (d:decl) = match d.d_decl.v with | Define j _ (Int _ _) -> i.v = j.v | _ -> false in let _, cases_rev, ds_rev = List.fold_left (fun (next, cases_rev, ds_rev) (i, jopt) -> let next = match jopt with | Some (Inl j) -> j | Some (Inr j) -> begin match List.Tot.find (find_definition j) ds_rev with | Some ({d_decl={v=Define _ _ (Int _ k)}}) -> k | _ -> error (Printf.sprintf "Enum identifier %s not found" (print_ident j)) j.range end | None -> next in let case = (i, None) in let d = mk_decl (Define i None (Int ityp next)) i.range ["Enum constant"] export in (next + 1, case :: cases_rev, d :: ds_rev)) (0, [], []) cases in List.rev cases_rev, List.rev ds_rev let desugar_one_enum (d:decl) : ML (list decl) = match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] //no enum value assignments; no desugaring to do else //if we have any assignments at all, then we treat all the //tags as fresh constants and assign them values in sequence //with respect to the assigned values of preceding tags let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds@[enum] | _ -> [d] (* This code is currently not used It desugars an Enum to a record with a single refined field *) // let eliminate_enum (d:decl) : ML decl = // match d.v with // | Enum t i cases -> // let names = { // typedef_name = { i with v = { i.v with name=Ast.reserved_prefix ^ Ast.reserved_prefix ^ i.v.name }}; // typedef_abbrev = i; // typedef_ptr_abbrev = { i with v = {i.v with // name = Ast.reserved_prefix ^ Ast.reserved_prefix ^ "P" ^ i.v.name }}; // typedef_attributes = []; // } in // let params = [] in // let where = None in // let field_ident = with_dummy_range (to_ident' (Ast.reserved_prefix ^ "enum_field")) in // let field_ident_expr = with_dummy_range (Identifier field_ident) in // let field_constraint = // List.fold_right // (fun (case, _) out -> // let eq = with_range (App Eq [field_ident_expr; with_range (Identifier case) case.range]) case.range in // with_dummy_range (App Or [eq; out])) // cases // (with_dummy_range (Constant (Bool false))) // in // let field = { // field_dependence = false; // field_ident = field_ident; // field_type = t; // field_array_opt = FieldScalar; // field_constraint = Some field_constraint; // field_number = None; // field_bitwidth = None; // field_action = None // } in // let d' = Record names params where [with_dummy_range field] in // {d with v = d'} // | _ -> d (* * output_types and extern_types tables to set the kind in the Typ_app nodes *) noeq type qenv = { mname : string; module_abbrevs : H.t string string; output_types : H.t ident' unit; extern_types : H.t ident' unit; local_names : list string; global_env: GlobalEnv.global_env; } let push_module_abbrev (env:qenv) (i m:string) : ML unit = H.insert env.module_abbrevs i m let push_output_type (env:qenv) (out_t:out_typ) : ML unit = H.insert env.output_types out_t.out_typ_names.typedef_name.v (); H.insert env.output_types out_t.out_typ_names.typedef_abbrev.v () let push_extern_type (env:qenv) (td:typedef_names) : ML unit = H.insert env.extern_types td.typedef_name.v (); H.insert env.extern_types td.typedef_abbrev.v () let push_name (env:qenv) (name:string) : qenv = { env with local_names = name::env.local_names } let prim_consts = [ "unit"; "Bool"; "UINT8"; "UINT16"; "UINT32"; "UINT64"; "UINT8BE"; "UINT16BE"; "UINT32BE"; "UINT64BE"; "field_id"; "PUINT8"; "all_bytes"; "all_zeros"; "is_range_okay"; "void" ] let resolve_ident (env:qenv) (i:ident) : ML ident = let resolve_to_current_module i = { i with v = { i.v with modul_name = Some env.mname } } in let maybe_resolve_as_ifdef i : ML ident = match env.global_env.ge_cfg with | None -> resolve_to_current_module i | Some (cfg, cfg_module_name) -> if List.mem i.v.name cfg.compile_time_flags.flags then { i with v = { i.v with modul_name = Some cfg_module_name } } else resolve_to_current_module i in if List.mem i.v.name prim_consts //it's a primitive constant, e.g. UINT8, leave as is then i else if List.mem i.v.name env.local_names //it's a local name (e.g. a parameter name) then (if Some? i.v.modul_name //must have module name set to None then error (Printf.sprintf "Ident %s is a local name but has a qualifying modul %s" i.v.name (Some?.v i.v.modul_name)) i.range else i) //return the local name as is else (match i.v.modul_name with //it's a top-level name | None -> maybe_resolve_as_ifdef i | Some m -> //if already qualified, check if it is an abbreviation (match H.try_find env.module_abbrevs m with | None -> i | Some m -> { i with v = { i.v with modul_name = Some m } })) let rec collect_ifdef_guards (env:qenv) (e:expr) : ML unit = let check_resolved_to_ifdef i = match env.global_env.ge_cfg with | None -> false | Some (cfg, cfg_module_name) -> List.mem i.v.name cfg.compile_time_flags.flags && i.v.modul_name = Some cfg_module_name in match e.v with | This -> error "'this' is not allowed in the guard of an #if" e.range | Static _ -> failwith "static should have been eliminated already" | Constant _ -> () | Identifier i -> if not (check_resolved_to_ifdef i) then error (Printf.sprintf "Identifier %s is not a compile-time macro but is used in a #if" i.v.name) e.range | App op args -> begin match op with | And | Or | Not -> List.iter (collect_ifdef_guards env) args | _ -> error "Only boolean expressions over identifiers are supported in #if guards" e.range end let rec resolve_expr' (env:qenv) (e:expr') r : ML expr' = match e with | Constant _ -> e | Identifier i -> Identifier (resolve_ident env i) | This -> e | Static e' -> let e' = resolve_expr env e' in collect_ifdef_guards env e';//mark any variables as top-level IfDef symbols e'.v | App op args -> let args = List.map (resolve_expr env) args in App op args and resolve_expr (env:qenv) (e:expr) : ML expr = { e with v = resolve_expr' env e.v e.range } let resolve_typ_param (env:qenv) (p:typ_param) : ML typ_param = match p with | Inl e -> resolve_expr env e |> Inl | _ -> p //Currently not going inside output expressions, should we? let kind_of_ident (env:qenv) (i:ident) : ML t_kind = let _or_ (b0 b1:bool) = b0 || b1 in if Some? (H.try_find env.output_types i.v) `_or_` Some? (H.try_find env.global_env.ge_out_t i.v) then KindOutput else if Some? (H.try_find env.extern_types i.v) `_or_` Some? (H.try_find env.global_env.ge_extern_t i.v) then KindExtern else KindSpec let rec resolve_typ' (env:qenv) (t:typ') : ML typ' = match t with | Type_app hd _ args -> let hd = resolve_ident env hd in //Set is_out argument to the Type_app appropriately let k = kind_of_ident env hd in Type_app hd k (List.map (resolve_typ_param env) args) | Pointer t -> Pointer (resolve_typ env t) and resolve_typ (env:qenv) (t:typ) : ML typ = { t with v = resolve_typ' env t.v } let resolve_atomic_action (env:qenv) (ac:atomic_action) : ML atomic_action = match ac with | Action_return e -> Action_return (resolve_expr env e) | Action_abort | Action_field_pos_64 | Action_field_pos_32 | Action_field_ptr -> ac | Action_field_ptr_after e write_to -> Action_field_ptr_after (resolve_expr env e) write_to | Action_deref i -> Action_deref i //most certainly a type parameter | Action_assignment lhs rhs -> Action_assignment lhs (resolve_expr env rhs) //lhs is an action-local variable | Action_call f args -> Action_call (resolve_ident env f) (List.map (resolve_expr env) args) let rec resolve_action' (env:qenv) (act:action') : ML action' = match act with | Atomic_action ac -> Atomic_action (resolve_atomic_action env ac) | Action_seq hd tl -> Action_seq (resolve_atomic_action env hd) (resolve_action env tl) | Action_ite hd then_ else_ -> Action_ite (resolve_expr env hd) (resolve_action env then_) (map_opt (resolve_action env) else_) | Action_let i a k -> Action_let i (resolve_atomic_action env a) (resolve_action (push_name env i.v.name) k) | Action_act a -> Action_act (resolve_action env a) and resolve_action (env:qenv) (act:action) : ML action = { act with v = resolve_action' env act.v }
false
false
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val resolve_param (env: qenv) (p: param) : ML (param & qenv)
[]
Desugar.resolve_param
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: Desugar.qenv -> p: Ast.param -> FStar.All.ML (Ast.param * Desugar.qenv)
{ "end_col": 24, "end_line": 307, "start_col": 60, "start_line": 304 }
Prims.Tot
val push_name (env: qenv) (name: string) : qenv
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let push_name (env:qenv) (name:string) : qenv = { env with local_names = name::env.local_names }
val push_name (env: qenv) (name: string) : qenv let push_name (env: qenv) (name: string) : qenv =
false
null
false
{ env with local_names = name :: env.local_names }
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "total" ]
[ "Desugar.qenv", "Prims.string", "Desugar.Mkqenv", "Desugar.__proj__Mkqenv__item__mname", "Desugar.__proj__Mkqenv__item__module_abbrevs", "Desugar.__proj__Mkqenv__item__output_types", "Desugar.__proj__Mkqenv__item__extern_types", "Prims.Cons", "Desugar.__proj__Mkqenv__item__local_names", "Desugar.__proj__Mkqenv__item__global_env" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *) let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases let desugar_enum_cases (ityp:integer_type) (cases:list enum_case) (export:bool) : ML (list enum_case & list decl) = let find_definition (i:ident) (d:decl) = match d.d_decl.v with | Define j _ (Int _ _) -> i.v = j.v | _ -> false in let _, cases_rev, ds_rev = List.fold_left (fun (next, cases_rev, ds_rev) (i, jopt) -> let next = match jopt with | Some (Inl j) -> j | Some (Inr j) -> begin match List.Tot.find (find_definition j) ds_rev with | Some ({d_decl={v=Define _ _ (Int _ k)}}) -> k | _ -> error (Printf.sprintf "Enum identifier %s not found" (print_ident j)) j.range end | None -> next in let case = (i, None) in let d = mk_decl (Define i None (Int ityp next)) i.range ["Enum constant"] export in (next + 1, case :: cases_rev, d :: ds_rev)) (0, [], []) cases in List.rev cases_rev, List.rev ds_rev let desugar_one_enum (d:decl) : ML (list decl) = match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] //no enum value assignments; no desugaring to do else //if we have any assignments at all, then we treat all the //tags as fresh constants and assign them values in sequence //with respect to the assigned values of preceding tags let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds@[enum] | _ -> [d] (* This code is currently not used It desugars an Enum to a record with a single refined field *) // let eliminate_enum (d:decl) : ML decl = // match d.v with // | Enum t i cases -> // let names = { // typedef_name = { i with v = { i.v with name=Ast.reserved_prefix ^ Ast.reserved_prefix ^ i.v.name }}; // typedef_abbrev = i; // typedef_ptr_abbrev = { i with v = {i.v with // name = Ast.reserved_prefix ^ Ast.reserved_prefix ^ "P" ^ i.v.name }}; // typedef_attributes = []; // } in // let params = [] in // let where = None in // let field_ident = with_dummy_range (to_ident' (Ast.reserved_prefix ^ "enum_field")) in // let field_ident_expr = with_dummy_range (Identifier field_ident) in // let field_constraint = // List.fold_right // (fun (case, _) out -> // let eq = with_range (App Eq [field_ident_expr; with_range (Identifier case) case.range]) case.range in // with_dummy_range (App Or [eq; out])) // cases // (with_dummy_range (Constant (Bool false))) // in // let field = { // field_dependence = false; // field_ident = field_ident; // field_type = t; // field_array_opt = FieldScalar; // field_constraint = Some field_constraint; // field_number = None; // field_bitwidth = None; // field_action = None // } in // let d' = Record names params where [with_dummy_range field] in // {d with v = d'} // | _ -> d (* * output_types and extern_types tables to set the kind in the Typ_app nodes *) noeq type qenv = { mname : string; module_abbrevs : H.t string string; output_types : H.t ident' unit; extern_types : H.t ident' unit; local_names : list string; global_env: GlobalEnv.global_env; } let push_module_abbrev (env:qenv) (i m:string) : ML unit = H.insert env.module_abbrevs i m let push_output_type (env:qenv) (out_t:out_typ) : ML unit = H.insert env.output_types out_t.out_typ_names.typedef_name.v (); H.insert env.output_types out_t.out_typ_names.typedef_abbrev.v () let push_extern_type (env:qenv) (td:typedef_names) : ML unit = H.insert env.extern_types td.typedef_name.v (); H.insert env.extern_types td.typedef_abbrev.v ()
false
true
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val push_name (env: qenv) (name: string) : qenv
[]
Desugar.push_name
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: Desugar.qenv -> name: Prims.string -> Desugar.qenv
{ "end_col": 48, "end_line": 164, "start_col": 4, "start_line": 164 }
FStar.All.ML
val resolve_decl (env: qenv) (d: decl) : ML decl
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let resolve_decl (env:qenv) (d:decl) : ML decl = decl_with_v d (resolve_decl' env d.d_decl.v)
val resolve_decl (env: qenv) (d: decl) : ML decl let resolve_decl (env: qenv) (d: decl) : ML decl =
true
null
false
decl_with_v d (resolve_decl' env d.d_decl.v)
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "ml" ]
[ "Desugar.qenv", "Ast.decl", "Ast.decl_with_v", "Ast.decl'", "Desugar.resolve_decl'", "Ast.__proj__Mkwith_meta_t__item__v", "Ast.__proj__Mkdecl__item__d_decl" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *) let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases let desugar_enum_cases (ityp:integer_type) (cases:list enum_case) (export:bool) : ML (list enum_case & list decl) = let find_definition (i:ident) (d:decl) = match d.d_decl.v with | Define j _ (Int _ _) -> i.v = j.v | _ -> false in let _, cases_rev, ds_rev = List.fold_left (fun (next, cases_rev, ds_rev) (i, jopt) -> let next = match jopt with | Some (Inl j) -> j | Some (Inr j) -> begin match List.Tot.find (find_definition j) ds_rev with | Some ({d_decl={v=Define _ _ (Int _ k)}}) -> k | _ -> error (Printf.sprintf "Enum identifier %s not found" (print_ident j)) j.range end | None -> next in let case = (i, None) in let d = mk_decl (Define i None (Int ityp next)) i.range ["Enum constant"] export in (next + 1, case :: cases_rev, d :: ds_rev)) (0, [], []) cases in List.rev cases_rev, List.rev ds_rev let desugar_one_enum (d:decl) : ML (list decl) = match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] //no enum value assignments; no desugaring to do else //if we have any assignments at all, then we treat all the //tags as fresh constants and assign them values in sequence //with respect to the assigned values of preceding tags let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds@[enum] | _ -> [d] (* This code is currently not used It desugars an Enum to a record with a single refined field *) // let eliminate_enum (d:decl) : ML decl = // match d.v with // | Enum t i cases -> // let names = { // typedef_name = { i with v = { i.v with name=Ast.reserved_prefix ^ Ast.reserved_prefix ^ i.v.name }}; // typedef_abbrev = i; // typedef_ptr_abbrev = { i with v = {i.v with // name = Ast.reserved_prefix ^ Ast.reserved_prefix ^ "P" ^ i.v.name }}; // typedef_attributes = []; // } in // let params = [] in // let where = None in // let field_ident = with_dummy_range (to_ident' (Ast.reserved_prefix ^ "enum_field")) in // let field_ident_expr = with_dummy_range (Identifier field_ident) in // let field_constraint = // List.fold_right // (fun (case, _) out -> // let eq = with_range (App Eq [field_ident_expr; with_range (Identifier case) case.range]) case.range in // with_dummy_range (App Or [eq; out])) // cases // (with_dummy_range (Constant (Bool false))) // in // let field = { // field_dependence = false; // field_ident = field_ident; // field_type = t; // field_array_opt = FieldScalar; // field_constraint = Some field_constraint; // field_number = None; // field_bitwidth = None; // field_action = None // } in // let d' = Record names params where [with_dummy_range field] in // {d with v = d'} // | _ -> d (* * output_types and extern_types tables to set the kind in the Typ_app nodes *) noeq type qenv = { mname : string; module_abbrevs : H.t string string; output_types : H.t ident' unit; extern_types : H.t ident' unit; local_names : list string; global_env: GlobalEnv.global_env; } let push_module_abbrev (env:qenv) (i m:string) : ML unit = H.insert env.module_abbrevs i m let push_output_type (env:qenv) (out_t:out_typ) : ML unit = H.insert env.output_types out_t.out_typ_names.typedef_name.v (); H.insert env.output_types out_t.out_typ_names.typedef_abbrev.v () let push_extern_type (env:qenv) (td:typedef_names) : ML unit = H.insert env.extern_types td.typedef_name.v (); H.insert env.extern_types td.typedef_abbrev.v () let push_name (env:qenv) (name:string) : qenv = { env with local_names = name::env.local_names } let prim_consts = [ "unit"; "Bool"; "UINT8"; "UINT16"; "UINT32"; "UINT64"; "UINT8BE"; "UINT16BE"; "UINT32BE"; "UINT64BE"; "field_id"; "PUINT8"; "all_bytes"; "all_zeros"; "is_range_okay"; "void" ] let resolve_ident (env:qenv) (i:ident) : ML ident = let resolve_to_current_module i = { i with v = { i.v with modul_name = Some env.mname } } in let maybe_resolve_as_ifdef i : ML ident = match env.global_env.ge_cfg with | None -> resolve_to_current_module i | Some (cfg, cfg_module_name) -> if List.mem i.v.name cfg.compile_time_flags.flags then { i with v = { i.v with modul_name = Some cfg_module_name } } else resolve_to_current_module i in if List.mem i.v.name prim_consts //it's a primitive constant, e.g. UINT8, leave as is then i else if List.mem i.v.name env.local_names //it's a local name (e.g. a parameter name) then (if Some? i.v.modul_name //must have module name set to None then error (Printf.sprintf "Ident %s is a local name but has a qualifying modul %s" i.v.name (Some?.v i.v.modul_name)) i.range else i) //return the local name as is else (match i.v.modul_name with //it's a top-level name | None -> maybe_resolve_as_ifdef i | Some m -> //if already qualified, check if it is an abbreviation (match H.try_find env.module_abbrevs m with | None -> i | Some m -> { i with v = { i.v with modul_name = Some m } })) let rec collect_ifdef_guards (env:qenv) (e:expr) : ML unit = let check_resolved_to_ifdef i = match env.global_env.ge_cfg with | None -> false | Some (cfg, cfg_module_name) -> List.mem i.v.name cfg.compile_time_flags.flags && i.v.modul_name = Some cfg_module_name in match e.v with | This -> error "'this' is not allowed in the guard of an #if" e.range | Static _ -> failwith "static should have been eliminated already" | Constant _ -> () | Identifier i -> if not (check_resolved_to_ifdef i) then error (Printf.sprintf "Identifier %s is not a compile-time macro but is used in a #if" i.v.name) e.range | App op args -> begin match op with | And | Or | Not -> List.iter (collect_ifdef_guards env) args | _ -> error "Only boolean expressions over identifiers are supported in #if guards" e.range end let rec resolve_expr' (env:qenv) (e:expr') r : ML expr' = match e with | Constant _ -> e | Identifier i -> Identifier (resolve_ident env i) | This -> e | Static e' -> let e' = resolve_expr env e' in collect_ifdef_guards env e';//mark any variables as top-level IfDef symbols e'.v | App op args -> let args = List.map (resolve_expr env) args in App op args and resolve_expr (env:qenv) (e:expr) : ML expr = { e with v = resolve_expr' env e.v e.range } let resolve_typ_param (env:qenv) (p:typ_param) : ML typ_param = match p with | Inl e -> resolve_expr env e |> Inl | _ -> p //Currently not going inside output expressions, should we? let kind_of_ident (env:qenv) (i:ident) : ML t_kind = let _or_ (b0 b1:bool) = b0 || b1 in if Some? (H.try_find env.output_types i.v) `_or_` Some? (H.try_find env.global_env.ge_out_t i.v) then KindOutput else if Some? (H.try_find env.extern_types i.v) `_or_` Some? (H.try_find env.global_env.ge_extern_t i.v) then KindExtern else KindSpec let rec resolve_typ' (env:qenv) (t:typ') : ML typ' = match t with | Type_app hd _ args -> let hd = resolve_ident env hd in //Set is_out argument to the Type_app appropriately let k = kind_of_ident env hd in Type_app hd k (List.map (resolve_typ_param env) args) | Pointer t -> Pointer (resolve_typ env t) and resolve_typ (env:qenv) (t:typ) : ML typ = { t with v = resolve_typ' env t.v } let resolve_atomic_action (env:qenv) (ac:atomic_action) : ML atomic_action = match ac with | Action_return e -> Action_return (resolve_expr env e) | Action_abort | Action_field_pos_64 | Action_field_pos_32 | Action_field_ptr -> ac | Action_field_ptr_after e write_to -> Action_field_ptr_after (resolve_expr env e) write_to | Action_deref i -> Action_deref i //most certainly a type parameter | Action_assignment lhs rhs -> Action_assignment lhs (resolve_expr env rhs) //lhs is an action-local variable | Action_call f args -> Action_call (resolve_ident env f) (List.map (resolve_expr env) args) let rec resolve_action' (env:qenv) (act:action') : ML action' = match act with | Atomic_action ac -> Atomic_action (resolve_atomic_action env ac) | Action_seq hd tl -> Action_seq (resolve_atomic_action env hd) (resolve_action env tl) | Action_ite hd then_ else_ -> Action_ite (resolve_expr env hd) (resolve_action env then_) (map_opt (resolve_action env) else_) | Action_let i a k -> Action_let i (resolve_atomic_action env a) (resolve_action (push_name env i.v.name) k) | Action_act a -> Action_act (resolve_action env a) and resolve_action (env:qenv) (act:action) : ML action = { act with v = resolve_action' env act.v } let resolve_param (env:qenv) (p:param) : ML (param & qenv) = let t, i, q = p in (resolve_typ env t, i, q), push_name env i.v.name let resolve_params (env:qenv) (params:list param) : ML (list param & qenv) = List.fold_left (fun (params, env) p -> let p, env = resolve_param env p in params@[p], env) ([], env) params let resolve_field_bitwidth_t (env:qenv) (fb:field_bitwidth_t) : ML field_bitwidth_t = let resolve_bitfield_attr' (env:qenv) (b:bitfield_attr') : ML bitfield_attr' = { b with bitfield_type = resolve_typ env b.bitfield_type } in let resolve_bitfield_attr (env:qenv) (b:bitfield_attr) : ML bitfield_attr = { b with v = resolve_bitfield_attr' env b.v } in match fb with | Inl _ -> fb | Inr b -> Inr (resolve_bitfield_attr env b) let resolve_field_array_t (env:qenv) (farr:field_array_t) : ML field_array_t = match farr with | FieldScalar -> farr | FieldArrayQualified (e, aq) -> FieldArrayQualified (resolve_expr env e, aq) | FieldString None -> farr | FieldString (Some e) -> FieldString (Some (resolve_expr env e)) let rec resolve_field (env:qenv) (ff:field) : ML (field & qenv) = match ff.v with | AtomicField f -> let f, e = resolve_atomic_field env f in {ff with v = AtomicField f}, e | RecordField f i -> let fs, _ = resolve_fields env f in {ff with v = RecordField fs i}, env //record fields are not in scope outside the record | SwitchCaseField f i -> let f = resolve_switch_case env f in {ff with v = SwitchCaseField f i}, env and resolve_atomic_field (env:qenv) (f:atomic_field) : ML (atomic_field & qenv) = let resolve_atomic_field' (env:qenv) (sf:atomic_field') : ML atomic_field' = { sf with field_type = resolve_typ env sf.field_type; field_array_opt = resolve_field_array_t env sf.field_array_opt; field_constraint = map_opt (resolve_expr env) sf.field_constraint; field_bitwidth = map_opt (resolve_field_bitwidth_t env) sf.field_bitwidth; field_action = map_opt (fun (a, b) -> resolve_action env a, b) sf.field_action } in let env = push_name env f.v.field_ident.v.name in { f with v = resolve_atomic_field' env f.v }, env and resolve_fields (env:qenv) (flds:list field) : ML (list field & qenv) = List.fold_left (fun (flds, env) f -> let f, env = resolve_field env f in flds@[f], env) ([], env) flds and resolve_switch_case (env:qenv) (sc:switch_case) : ML switch_case = //case fields do not escape their scope let resolve_case (env:qenv) (c:case) : ML case = match c with | Case e f -> Case (resolve_expr env e) (fst (resolve_field env f)) | DefaultCase f -> DefaultCase (fst (resolve_field env f)) in let e, l = sc in resolve_expr env e, List.map (resolve_case env) l let resolve_typedef_names (env:qenv) (td_names:typedef_names) : ML typedef_names = { td_names with typedef_name = resolve_ident env td_names.typedef_name; typedef_abbrev = resolve_ident env td_names.typedef_abbrev; typedef_ptr_abbrev = resolve_ident env td_names.typedef_ptr_abbrev } let resolve_enum_case (env:qenv) (ec:enum_case) : ML enum_case = match ec with | i, None -> resolve_ident env i, None | _ -> error "Unexpected enum_case in resolve_enum_case" (fst ec).range let rec resolve_out_field (env:qenv) (fld:out_field) : ML out_field = match fld with | Out_field_named i t n -> Out_field_named i (resolve_typ env t) n | Out_field_anon l u -> Out_field_anon (resolve_out_fields env l) u and resolve_out_fields (env:qenv) (flds:list out_field) : ML (list out_field) = List.map (resolve_out_field env) flds let resolve_out_type (env:qenv) (out_t:out_typ) : ML out_typ = { out_t with out_typ_names = resolve_typedef_names env out_t.out_typ_names; out_typ_fields = List.map (resolve_out_field env) out_t.out_typ_fields } let resolve_decl' (env:qenv) (d:decl') : ML decl' = match d with | ModuleAbbrev i m -> push_module_abbrev env i.v.name m.v.name; d | Define i topt c -> Define (resolve_ident env i) (map_opt (resolve_typ env) topt) c | TypeAbbrev t i -> TypeAbbrev (resolve_typ env t) (resolve_ident env i) | Enum t i ecs -> Enum (resolve_typ env t) (resolve_ident env i) (List.map (resolve_enum_case env) ecs) | Record td_names params where flds -> let td_names = resolve_typedef_names env td_names in let params, env = resolve_params env params in let where = map_opt (resolve_expr env) where in let flds, _ = resolve_fields env flds in Record td_names params where flds | CaseType td_names params sc -> let td_names = resolve_typedef_names env td_names in let params, env = resolve_params env params in let sc = resolve_switch_case env sc in CaseType td_names params sc | OutputType out_t -> let out_t = resolve_out_type env out_t in push_output_type env out_t; OutputType out_t | ExternType td_names -> let td_names = resolve_typedef_names env td_names in push_extern_type env td_names; ExternType td_names | ExternFn id ret params -> let id = resolve_ident env id in let ret = resolve_typ env ret in let params, _ = resolve_params env params in ExternFn id ret params
false
false
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val resolve_decl (env: qenv) (d: decl) : ML decl
[]
Desugar.resolve_decl
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: Desugar.qenv -> d: Ast.decl -> FStar.All.ML Ast.decl
{ "end_col": 93, "end_line": 423, "start_col": 49, "start_line": 423 }
FStar.All.ML
val resolve_out_type (env: qenv) (out_t: out_typ) : ML out_typ
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let resolve_out_type (env:qenv) (out_t:out_typ) : ML out_typ = { out_t with out_typ_names = resolve_typedef_names env out_t.out_typ_names; out_typ_fields = List.map (resolve_out_field env) out_t.out_typ_fields }
val resolve_out_type (env: qenv) (out_t: out_typ) : ML out_typ let resolve_out_type (env: qenv) (out_t: out_typ) : ML out_typ =
true
null
false
{ out_t with out_typ_names = resolve_typedef_names env out_t.out_typ_names; out_typ_fields = List.map (resolve_out_field env) out_t.out_typ_fields }
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "ml" ]
[ "Desugar.qenv", "Ast.out_typ", "Ast.Mkout_typ", "Ast.__proj__Mkout_typ__item__out_typ_is_union", "Prims.list", "Ast.out_field", "FStar.List.map", "Desugar.resolve_out_field", "Ast.__proj__Mkout_typ__item__out_typ_fields", "Ast.typedef_names", "Desugar.resolve_typedef_names", "Ast.__proj__Mkout_typ__item__out_typ_names" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *) let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases let desugar_enum_cases (ityp:integer_type) (cases:list enum_case) (export:bool) : ML (list enum_case & list decl) = let find_definition (i:ident) (d:decl) = match d.d_decl.v with | Define j _ (Int _ _) -> i.v = j.v | _ -> false in let _, cases_rev, ds_rev = List.fold_left (fun (next, cases_rev, ds_rev) (i, jopt) -> let next = match jopt with | Some (Inl j) -> j | Some (Inr j) -> begin match List.Tot.find (find_definition j) ds_rev with | Some ({d_decl={v=Define _ _ (Int _ k)}}) -> k | _ -> error (Printf.sprintf "Enum identifier %s not found" (print_ident j)) j.range end | None -> next in let case = (i, None) in let d = mk_decl (Define i None (Int ityp next)) i.range ["Enum constant"] export in (next + 1, case :: cases_rev, d :: ds_rev)) (0, [], []) cases in List.rev cases_rev, List.rev ds_rev let desugar_one_enum (d:decl) : ML (list decl) = match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] //no enum value assignments; no desugaring to do else //if we have any assignments at all, then we treat all the //tags as fresh constants and assign them values in sequence //with respect to the assigned values of preceding tags let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds@[enum] | _ -> [d] (* This code is currently not used It desugars an Enum to a record with a single refined field *) // let eliminate_enum (d:decl) : ML decl = // match d.v with // | Enum t i cases -> // let names = { // typedef_name = { i with v = { i.v with name=Ast.reserved_prefix ^ Ast.reserved_prefix ^ i.v.name }}; // typedef_abbrev = i; // typedef_ptr_abbrev = { i with v = {i.v with // name = Ast.reserved_prefix ^ Ast.reserved_prefix ^ "P" ^ i.v.name }}; // typedef_attributes = []; // } in // let params = [] in // let where = None in // let field_ident = with_dummy_range (to_ident' (Ast.reserved_prefix ^ "enum_field")) in // let field_ident_expr = with_dummy_range (Identifier field_ident) in // let field_constraint = // List.fold_right // (fun (case, _) out -> // let eq = with_range (App Eq [field_ident_expr; with_range (Identifier case) case.range]) case.range in // with_dummy_range (App Or [eq; out])) // cases // (with_dummy_range (Constant (Bool false))) // in // let field = { // field_dependence = false; // field_ident = field_ident; // field_type = t; // field_array_opt = FieldScalar; // field_constraint = Some field_constraint; // field_number = None; // field_bitwidth = None; // field_action = None // } in // let d' = Record names params where [with_dummy_range field] in // {d with v = d'} // | _ -> d (* * output_types and extern_types tables to set the kind in the Typ_app nodes *) noeq type qenv = { mname : string; module_abbrevs : H.t string string; output_types : H.t ident' unit; extern_types : H.t ident' unit; local_names : list string; global_env: GlobalEnv.global_env; } let push_module_abbrev (env:qenv) (i m:string) : ML unit = H.insert env.module_abbrevs i m let push_output_type (env:qenv) (out_t:out_typ) : ML unit = H.insert env.output_types out_t.out_typ_names.typedef_name.v (); H.insert env.output_types out_t.out_typ_names.typedef_abbrev.v () let push_extern_type (env:qenv) (td:typedef_names) : ML unit = H.insert env.extern_types td.typedef_name.v (); H.insert env.extern_types td.typedef_abbrev.v () let push_name (env:qenv) (name:string) : qenv = { env with local_names = name::env.local_names } let prim_consts = [ "unit"; "Bool"; "UINT8"; "UINT16"; "UINT32"; "UINT64"; "UINT8BE"; "UINT16BE"; "UINT32BE"; "UINT64BE"; "field_id"; "PUINT8"; "all_bytes"; "all_zeros"; "is_range_okay"; "void" ] let resolve_ident (env:qenv) (i:ident) : ML ident = let resolve_to_current_module i = { i with v = { i.v with modul_name = Some env.mname } } in let maybe_resolve_as_ifdef i : ML ident = match env.global_env.ge_cfg with | None -> resolve_to_current_module i | Some (cfg, cfg_module_name) -> if List.mem i.v.name cfg.compile_time_flags.flags then { i with v = { i.v with modul_name = Some cfg_module_name } } else resolve_to_current_module i in if List.mem i.v.name prim_consts //it's a primitive constant, e.g. UINT8, leave as is then i else if List.mem i.v.name env.local_names //it's a local name (e.g. a parameter name) then (if Some? i.v.modul_name //must have module name set to None then error (Printf.sprintf "Ident %s is a local name but has a qualifying modul %s" i.v.name (Some?.v i.v.modul_name)) i.range else i) //return the local name as is else (match i.v.modul_name with //it's a top-level name | None -> maybe_resolve_as_ifdef i | Some m -> //if already qualified, check if it is an abbreviation (match H.try_find env.module_abbrevs m with | None -> i | Some m -> { i with v = { i.v with modul_name = Some m } })) let rec collect_ifdef_guards (env:qenv) (e:expr) : ML unit = let check_resolved_to_ifdef i = match env.global_env.ge_cfg with | None -> false | Some (cfg, cfg_module_name) -> List.mem i.v.name cfg.compile_time_flags.flags && i.v.modul_name = Some cfg_module_name in match e.v with | This -> error "'this' is not allowed in the guard of an #if" e.range | Static _ -> failwith "static should have been eliminated already" | Constant _ -> () | Identifier i -> if not (check_resolved_to_ifdef i) then error (Printf.sprintf "Identifier %s is not a compile-time macro but is used in a #if" i.v.name) e.range | App op args -> begin match op with | And | Or | Not -> List.iter (collect_ifdef_guards env) args | _ -> error "Only boolean expressions over identifiers are supported in #if guards" e.range end let rec resolve_expr' (env:qenv) (e:expr') r : ML expr' = match e with | Constant _ -> e | Identifier i -> Identifier (resolve_ident env i) | This -> e | Static e' -> let e' = resolve_expr env e' in collect_ifdef_guards env e';//mark any variables as top-level IfDef symbols e'.v | App op args -> let args = List.map (resolve_expr env) args in App op args and resolve_expr (env:qenv) (e:expr) : ML expr = { e with v = resolve_expr' env e.v e.range } let resolve_typ_param (env:qenv) (p:typ_param) : ML typ_param = match p with | Inl e -> resolve_expr env e |> Inl | _ -> p //Currently not going inside output expressions, should we? let kind_of_ident (env:qenv) (i:ident) : ML t_kind = let _or_ (b0 b1:bool) = b0 || b1 in if Some? (H.try_find env.output_types i.v) `_or_` Some? (H.try_find env.global_env.ge_out_t i.v) then KindOutput else if Some? (H.try_find env.extern_types i.v) `_or_` Some? (H.try_find env.global_env.ge_extern_t i.v) then KindExtern else KindSpec let rec resolve_typ' (env:qenv) (t:typ') : ML typ' = match t with | Type_app hd _ args -> let hd = resolve_ident env hd in //Set is_out argument to the Type_app appropriately let k = kind_of_ident env hd in Type_app hd k (List.map (resolve_typ_param env) args) | Pointer t -> Pointer (resolve_typ env t) and resolve_typ (env:qenv) (t:typ) : ML typ = { t with v = resolve_typ' env t.v } let resolve_atomic_action (env:qenv) (ac:atomic_action) : ML atomic_action = match ac with | Action_return e -> Action_return (resolve_expr env e) | Action_abort | Action_field_pos_64 | Action_field_pos_32 | Action_field_ptr -> ac | Action_field_ptr_after e write_to -> Action_field_ptr_after (resolve_expr env e) write_to | Action_deref i -> Action_deref i //most certainly a type parameter | Action_assignment lhs rhs -> Action_assignment lhs (resolve_expr env rhs) //lhs is an action-local variable | Action_call f args -> Action_call (resolve_ident env f) (List.map (resolve_expr env) args) let rec resolve_action' (env:qenv) (act:action') : ML action' = match act with | Atomic_action ac -> Atomic_action (resolve_atomic_action env ac) | Action_seq hd tl -> Action_seq (resolve_atomic_action env hd) (resolve_action env tl) | Action_ite hd then_ else_ -> Action_ite (resolve_expr env hd) (resolve_action env then_) (map_opt (resolve_action env) else_) | Action_let i a k -> Action_let i (resolve_atomic_action env a) (resolve_action (push_name env i.v.name) k) | Action_act a -> Action_act (resolve_action env a) and resolve_action (env:qenv) (act:action) : ML action = { act with v = resolve_action' env act.v } let resolve_param (env:qenv) (p:param) : ML (param & qenv) = let t, i, q = p in (resolve_typ env t, i, q), push_name env i.v.name let resolve_params (env:qenv) (params:list param) : ML (list param & qenv) = List.fold_left (fun (params, env) p -> let p, env = resolve_param env p in params@[p], env) ([], env) params let resolve_field_bitwidth_t (env:qenv) (fb:field_bitwidth_t) : ML field_bitwidth_t = let resolve_bitfield_attr' (env:qenv) (b:bitfield_attr') : ML bitfield_attr' = { b with bitfield_type = resolve_typ env b.bitfield_type } in let resolve_bitfield_attr (env:qenv) (b:bitfield_attr) : ML bitfield_attr = { b with v = resolve_bitfield_attr' env b.v } in match fb with | Inl _ -> fb | Inr b -> Inr (resolve_bitfield_attr env b) let resolve_field_array_t (env:qenv) (farr:field_array_t) : ML field_array_t = match farr with | FieldScalar -> farr | FieldArrayQualified (e, aq) -> FieldArrayQualified (resolve_expr env e, aq) | FieldString None -> farr | FieldString (Some e) -> FieldString (Some (resolve_expr env e)) let rec resolve_field (env:qenv) (ff:field) : ML (field & qenv) = match ff.v with | AtomicField f -> let f, e = resolve_atomic_field env f in {ff with v = AtomicField f}, e | RecordField f i -> let fs, _ = resolve_fields env f in {ff with v = RecordField fs i}, env //record fields are not in scope outside the record | SwitchCaseField f i -> let f = resolve_switch_case env f in {ff with v = SwitchCaseField f i}, env and resolve_atomic_field (env:qenv) (f:atomic_field) : ML (atomic_field & qenv) = let resolve_atomic_field' (env:qenv) (sf:atomic_field') : ML atomic_field' = { sf with field_type = resolve_typ env sf.field_type; field_array_opt = resolve_field_array_t env sf.field_array_opt; field_constraint = map_opt (resolve_expr env) sf.field_constraint; field_bitwidth = map_opt (resolve_field_bitwidth_t env) sf.field_bitwidth; field_action = map_opt (fun (a, b) -> resolve_action env a, b) sf.field_action } in let env = push_name env f.v.field_ident.v.name in { f with v = resolve_atomic_field' env f.v }, env and resolve_fields (env:qenv) (flds:list field) : ML (list field & qenv) = List.fold_left (fun (flds, env) f -> let f, env = resolve_field env f in flds@[f], env) ([], env) flds and resolve_switch_case (env:qenv) (sc:switch_case) : ML switch_case = //case fields do not escape their scope let resolve_case (env:qenv) (c:case) : ML case = match c with | Case e f -> Case (resolve_expr env e) (fst (resolve_field env f)) | DefaultCase f -> DefaultCase (fst (resolve_field env f)) in let e, l = sc in resolve_expr env e, List.map (resolve_case env) l let resolve_typedef_names (env:qenv) (td_names:typedef_names) : ML typedef_names = { td_names with typedef_name = resolve_ident env td_names.typedef_name; typedef_abbrev = resolve_ident env td_names.typedef_abbrev; typedef_ptr_abbrev = resolve_ident env td_names.typedef_ptr_abbrev } let resolve_enum_case (env:qenv) (ec:enum_case) : ML enum_case = match ec with | i, None -> resolve_ident env i, None | _ -> error "Unexpected enum_case in resolve_enum_case" (fst ec).range let rec resolve_out_field (env:qenv) (fld:out_field) : ML out_field = match fld with | Out_field_named i t n -> Out_field_named i (resolve_typ env t) n | Out_field_anon l u -> Out_field_anon (resolve_out_fields env l) u and resolve_out_fields (env:qenv) (flds:list out_field) : ML (list out_field) = List.map (resolve_out_field env) flds
false
false
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val resolve_out_type (env: qenv) (out_t: out_typ) : ML out_typ
[]
Desugar.resolve_out_type
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: Desugar.qenv -> out_t: Ast.out_typ -> FStar.All.ML Ast.out_typ
{ "end_col": 74, "end_line": 387, "start_col": 4, "start_line": 385 }
FStar.All.ML
val resolve_enum_case (env: qenv) (ec: enum_case) : ML enum_case
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let resolve_enum_case (env:qenv) (ec:enum_case) : ML enum_case = match ec with | i, None -> resolve_ident env i, None | _ -> error "Unexpected enum_case in resolve_enum_case" (fst ec).range
val resolve_enum_case (env: qenv) (ec: enum_case) : ML enum_case let resolve_enum_case (env: qenv) (ec: enum_case) : ML enum_case =
true
null
false
match ec with | i, None -> resolve_ident env i, None | _ -> error "Unexpected enum_case in resolve_enum_case" (fst ec).range
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "ml" ]
[ "Desugar.qenv", "Ast.enum_case", "Ast.ident", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.option", "Ast.either", "Prims.int", "FStar.Pervasives.Native.None", "Desugar.resolve_ident", "FStar.Pervasives.Native.tuple2", "Ast.error", "Ast.__proj__Mkwith_meta_t__item__range", "Ast.ident'", "FStar.Pervasives.Native.fst" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *) let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases let desugar_enum_cases (ityp:integer_type) (cases:list enum_case) (export:bool) : ML (list enum_case & list decl) = let find_definition (i:ident) (d:decl) = match d.d_decl.v with | Define j _ (Int _ _) -> i.v = j.v | _ -> false in let _, cases_rev, ds_rev = List.fold_left (fun (next, cases_rev, ds_rev) (i, jopt) -> let next = match jopt with | Some (Inl j) -> j | Some (Inr j) -> begin match List.Tot.find (find_definition j) ds_rev with | Some ({d_decl={v=Define _ _ (Int _ k)}}) -> k | _ -> error (Printf.sprintf "Enum identifier %s not found" (print_ident j)) j.range end | None -> next in let case = (i, None) in let d = mk_decl (Define i None (Int ityp next)) i.range ["Enum constant"] export in (next + 1, case :: cases_rev, d :: ds_rev)) (0, [], []) cases in List.rev cases_rev, List.rev ds_rev let desugar_one_enum (d:decl) : ML (list decl) = match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] //no enum value assignments; no desugaring to do else //if we have any assignments at all, then we treat all the //tags as fresh constants and assign them values in sequence //with respect to the assigned values of preceding tags let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds@[enum] | _ -> [d] (* This code is currently not used It desugars an Enum to a record with a single refined field *) // let eliminate_enum (d:decl) : ML decl = // match d.v with // | Enum t i cases -> // let names = { // typedef_name = { i with v = { i.v with name=Ast.reserved_prefix ^ Ast.reserved_prefix ^ i.v.name }}; // typedef_abbrev = i; // typedef_ptr_abbrev = { i with v = {i.v with // name = Ast.reserved_prefix ^ Ast.reserved_prefix ^ "P" ^ i.v.name }}; // typedef_attributes = []; // } in // let params = [] in // let where = None in // let field_ident = with_dummy_range (to_ident' (Ast.reserved_prefix ^ "enum_field")) in // let field_ident_expr = with_dummy_range (Identifier field_ident) in // let field_constraint = // List.fold_right // (fun (case, _) out -> // let eq = with_range (App Eq [field_ident_expr; with_range (Identifier case) case.range]) case.range in // with_dummy_range (App Or [eq; out])) // cases // (with_dummy_range (Constant (Bool false))) // in // let field = { // field_dependence = false; // field_ident = field_ident; // field_type = t; // field_array_opt = FieldScalar; // field_constraint = Some field_constraint; // field_number = None; // field_bitwidth = None; // field_action = None // } in // let d' = Record names params where [with_dummy_range field] in // {d with v = d'} // | _ -> d (* * output_types and extern_types tables to set the kind in the Typ_app nodes *) noeq type qenv = { mname : string; module_abbrevs : H.t string string; output_types : H.t ident' unit; extern_types : H.t ident' unit; local_names : list string; global_env: GlobalEnv.global_env; } let push_module_abbrev (env:qenv) (i m:string) : ML unit = H.insert env.module_abbrevs i m let push_output_type (env:qenv) (out_t:out_typ) : ML unit = H.insert env.output_types out_t.out_typ_names.typedef_name.v (); H.insert env.output_types out_t.out_typ_names.typedef_abbrev.v () let push_extern_type (env:qenv) (td:typedef_names) : ML unit = H.insert env.extern_types td.typedef_name.v (); H.insert env.extern_types td.typedef_abbrev.v () let push_name (env:qenv) (name:string) : qenv = { env with local_names = name::env.local_names } let prim_consts = [ "unit"; "Bool"; "UINT8"; "UINT16"; "UINT32"; "UINT64"; "UINT8BE"; "UINT16BE"; "UINT32BE"; "UINT64BE"; "field_id"; "PUINT8"; "all_bytes"; "all_zeros"; "is_range_okay"; "void" ] let resolve_ident (env:qenv) (i:ident) : ML ident = let resolve_to_current_module i = { i with v = { i.v with modul_name = Some env.mname } } in let maybe_resolve_as_ifdef i : ML ident = match env.global_env.ge_cfg with | None -> resolve_to_current_module i | Some (cfg, cfg_module_name) -> if List.mem i.v.name cfg.compile_time_flags.flags then { i with v = { i.v with modul_name = Some cfg_module_name } } else resolve_to_current_module i in if List.mem i.v.name prim_consts //it's a primitive constant, e.g. UINT8, leave as is then i else if List.mem i.v.name env.local_names //it's a local name (e.g. a parameter name) then (if Some? i.v.modul_name //must have module name set to None then error (Printf.sprintf "Ident %s is a local name but has a qualifying modul %s" i.v.name (Some?.v i.v.modul_name)) i.range else i) //return the local name as is else (match i.v.modul_name with //it's a top-level name | None -> maybe_resolve_as_ifdef i | Some m -> //if already qualified, check if it is an abbreviation (match H.try_find env.module_abbrevs m with | None -> i | Some m -> { i with v = { i.v with modul_name = Some m } })) let rec collect_ifdef_guards (env:qenv) (e:expr) : ML unit = let check_resolved_to_ifdef i = match env.global_env.ge_cfg with | None -> false | Some (cfg, cfg_module_name) -> List.mem i.v.name cfg.compile_time_flags.flags && i.v.modul_name = Some cfg_module_name in match e.v with | This -> error "'this' is not allowed in the guard of an #if" e.range | Static _ -> failwith "static should have been eliminated already" | Constant _ -> () | Identifier i -> if not (check_resolved_to_ifdef i) then error (Printf.sprintf "Identifier %s is not a compile-time macro but is used in a #if" i.v.name) e.range | App op args -> begin match op with | And | Or | Not -> List.iter (collect_ifdef_guards env) args | _ -> error "Only boolean expressions over identifiers are supported in #if guards" e.range end let rec resolve_expr' (env:qenv) (e:expr') r : ML expr' = match e with | Constant _ -> e | Identifier i -> Identifier (resolve_ident env i) | This -> e | Static e' -> let e' = resolve_expr env e' in collect_ifdef_guards env e';//mark any variables as top-level IfDef symbols e'.v | App op args -> let args = List.map (resolve_expr env) args in App op args and resolve_expr (env:qenv) (e:expr) : ML expr = { e with v = resolve_expr' env e.v e.range } let resolve_typ_param (env:qenv) (p:typ_param) : ML typ_param = match p with | Inl e -> resolve_expr env e |> Inl | _ -> p //Currently not going inside output expressions, should we? let kind_of_ident (env:qenv) (i:ident) : ML t_kind = let _or_ (b0 b1:bool) = b0 || b1 in if Some? (H.try_find env.output_types i.v) `_or_` Some? (H.try_find env.global_env.ge_out_t i.v) then KindOutput else if Some? (H.try_find env.extern_types i.v) `_or_` Some? (H.try_find env.global_env.ge_extern_t i.v) then KindExtern else KindSpec let rec resolve_typ' (env:qenv) (t:typ') : ML typ' = match t with | Type_app hd _ args -> let hd = resolve_ident env hd in //Set is_out argument to the Type_app appropriately let k = kind_of_ident env hd in Type_app hd k (List.map (resolve_typ_param env) args) | Pointer t -> Pointer (resolve_typ env t) and resolve_typ (env:qenv) (t:typ) : ML typ = { t with v = resolve_typ' env t.v } let resolve_atomic_action (env:qenv) (ac:atomic_action) : ML atomic_action = match ac with | Action_return e -> Action_return (resolve_expr env e) | Action_abort | Action_field_pos_64 | Action_field_pos_32 | Action_field_ptr -> ac | Action_field_ptr_after e write_to -> Action_field_ptr_after (resolve_expr env e) write_to | Action_deref i -> Action_deref i //most certainly a type parameter | Action_assignment lhs rhs -> Action_assignment lhs (resolve_expr env rhs) //lhs is an action-local variable | Action_call f args -> Action_call (resolve_ident env f) (List.map (resolve_expr env) args) let rec resolve_action' (env:qenv) (act:action') : ML action' = match act with | Atomic_action ac -> Atomic_action (resolve_atomic_action env ac) | Action_seq hd tl -> Action_seq (resolve_atomic_action env hd) (resolve_action env tl) | Action_ite hd then_ else_ -> Action_ite (resolve_expr env hd) (resolve_action env then_) (map_opt (resolve_action env) else_) | Action_let i a k -> Action_let i (resolve_atomic_action env a) (resolve_action (push_name env i.v.name) k) | Action_act a -> Action_act (resolve_action env a) and resolve_action (env:qenv) (act:action) : ML action = { act with v = resolve_action' env act.v } let resolve_param (env:qenv) (p:param) : ML (param & qenv) = let t, i, q = p in (resolve_typ env t, i, q), push_name env i.v.name let resolve_params (env:qenv) (params:list param) : ML (list param & qenv) = List.fold_left (fun (params, env) p -> let p, env = resolve_param env p in params@[p], env) ([], env) params let resolve_field_bitwidth_t (env:qenv) (fb:field_bitwidth_t) : ML field_bitwidth_t = let resolve_bitfield_attr' (env:qenv) (b:bitfield_attr') : ML bitfield_attr' = { b with bitfield_type = resolve_typ env b.bitfield_type } in let resolve_bitfield_attr (env:qenv) (b:bitfield_attr) : ML bitfield_attr = { b with v = resolve_bitfield_attr' env b.v } in match fb with | Inl _ -> fb | Inr b -> Inr (resolve_bitfield_attr env b) let resolve_field_array_t (env:qenv) (farr:field_array_t) : ML field_array_t = match farr with | FieldScalar -> farr | FieldArrayQualified (e, aq) -> FieldArrayQualified (resolve_expr env e, aq) | FieldString None -> farr | FieldString (Some e) -> FieldString (Some (resolve_expr env e)) let rec resolve_field (env:qenv) (ff:field) : ML (field & qenv) = match ff.v with | AtomicField f -> let f, e = resolve_atomic_field env f in {ff with v = AtomicField f}, e | RecordField f i -> let fs, _ = resolve_fields env f in {ff with v = RecordField fs i}, env //record fields are not in scope outside the record | SwitchCaseField f i -> let f = resolve_switch_case env f in {ff with v = SwitchCaseField f i}, env and resolve_atomic_field (env:qenv) (f:atomic_field) : ML (atomic_field & qenv) = let resolve_atomic_field' (env:qenv) (sf:atomic_field') : ML atomic_field' = { sf with field_type = resolve_typ env sf.field_type; field_array_opt = resolve_field_array_t env sf.field_array_opt; field_constraint = map_opt (resolve_expr env) sf.field_constraint; field_bitwidth = map_opt (resolve_field_bitwidth_t env) sf.field_bitwidth; field_action = map_opt (fun (a, b) -> resolve_action env a, b) sf.field_action } in let env = push_name env f.v.field_ident.v.name in { f with v = resolve_atomic_field' env f.v }, env and resolve_fields (env:qenv) (flds:list field) : ML (list field & qenv) = List.fold_left (fun (flds, env) f -> let f, env = resolve_field env f in flds@[f], env) ([], env) flds and resolve_switch_case (env:qenv) (sc:switch_case) : ML switch_case = //case fields do not escape their scope let resolve_case (env:qenv) (c:case) : ML case = match c with | Case e f -> Case (resolve_expr env e) (fst (resolve_field env f)) | DefaultCase f -> DefaultCase (fst (resolve_field env f)) in let e, l = sc in resolve_expr env e, List.map (resolve_case env) l let resolve_typedef_names (env:qenv) (td_names:typedef_names) : ML typedef_names = { td_names with typedef_name = resolve_ident env td_names.typedef_name; typedef_abbrev = resolve_ident env td_names.typedef_abbrev; typedef_ptr_abbrev = resolve_ident env td_names.typedef_ptr_abbrev }
false
false
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val resolve_enum_case (env: qenv) (ec: enum_case) : ML enum_case
[]
Desugar.resolve_enum_case
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: Desugar.qenv -> ec: Ast.enum_case -> FStar.All.ML Ast.enum_case
{ "end_col": 73, "end_line": 374, "start_col": 2, "start_line": 372 }
FStar.All.ML
val push_output_type (env: qenv) (out_t: out_typ) : ML unit
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let push_output_type (env:qenv) (out_t:out_typ) : ML unit = H.insert env.output_types out_t.out_typ_names.typedef_name.v (); H.insert env.output_types out_t.out_typ_names.typedef_abbrev.v ()
val push_output_type (env: qenv) (out_t: out_typ) : ML unit let push_output_type (env: qenv) (out_t: out_typ) : ML unit =
true
null
false
H.insert env.output_types out_t.out_typ_names.typedef_name.v (); H.insert env.output_types out_t.out_typ_names.typedef_abbrev.v ()
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "ml" ]
[ "Desugar.qenv", "Ast.out_typ", "Hashtable.insert", "Ast.ident'", "Prims.unit", "Desugar.__proj__Mkqenv__item__output_types", "Ast.__proj__Mkwith_meta_t__item__v", "Ast.__proj__Mktypedef_names__item__typedef_abbrev", "Ast.__proj__Mkout_typ__item__out_typ_names", "Ast.__proj__Mktypedef_names__item__typedef_name" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *) let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases let desugar_enum_cases (ityp:integer_type) (cases:list enum_case) (export:bool) : ML (list enum_case & list decl) = let find_definition (i:ident) (d:decl) = match d.d_decl.v with | Define j _ (Int _ _) -> i.v = j.v | _ -> false in let _, cases_rev, ds_rev = List.fold_left (fun (next, cases_rev, ds_rev) (i, jopt) -> let next = match jopt with | Some (Inl j) -> j | Some (Inr j) -> begin match List.Tot.find (find_definition j) ds_rev with | Some ({d_decl={v=Define _ _ (Int _ k)}}) -> k | _ -> error (Printf.sprintf "Enum identifier %s not found" (print_ident j)) j.range end | None -> next in let case = (i, None) in let d = mk_decl (Define i None (Int ityp next)) i.range ["Enum constant"] export in (next + 1, case :: cases_rev, d :: ds_rev)) (0, [], []) cases in List.rev cases_rev, List.rev ds_rev let desugar_one_enum (d:decl) : ML (list decl) = match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] //no enum value assignments; no desugaring to do else //if we have any assignments at all, then we treat all the //tags as fresh constants and assign them values in sequence //with respect to the assigned values of preceding tags let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds@[enum] | _ -> [d] (* This code is currently not used It desugars an Enum to a record with a single refined field *) // let eliminate_enum (d:decl) : ML decl = // match d.v with // | Enum t i cases -> // let names = { // typedef_name = { i with v = { i.v with name=Ast.reserved_prefix ^ Ast.reserved_prefix ^ i.v.name }}; // typedef_abbrev = i; // typedef_ptr_abbrev = { i with v = {i.v with // name = Ast.reserved_prefix ^ Ast.reserved_prefix ^ "P" ^ i.v.name }}; // typedef_attributes = []; // } in // let params = [] in // let where = None in // let field_ident = with_dummy_range (to_ident' (Ast.reserved_prefix ^ "enum_field")) in // let field_ident_expr = with_dummy_range (Identifier field_ident) in // let field_constraint = // List.fold_right // (fun (case, _) out -> // let eq = with_range (App Eq [field_ident_expr; with_range (Identifier case) case.range]) case.range in // with_dummy_range (App Or [eq; out])) // cases // (with_dummy_range (Constant (Bool false))) // in // let field = { // field_dependence = false; // field_ident = field_ident; // field_type = t; // field_array_opt = FieldScalar; // field_constraint = Some field_constraint; // field_number = None; // field_bitwidth = None; // field_action = None // } in // let d' = Record names params where [with_dummy_range field] in // {d with v = d'} // | _ -> d (* * output_types and extern_types tables to set the kind in the Typ_app nodes *) noeq type qenv = { mname : string; module_abbrevs : H.t string string; output_types : H.t ident' unit; extern_types : H.t ident' unit; local_names : list string; global_env: GlobalEnv.global_env; } let push_module_abbrev (env:qenv) (i m:string) : ML unit = H.insert env.module_abbrevs i m
false
false
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val push_output_type (env: qenv) (out_t: out_typ) : ML unit
[]
Desugar.push_output_type
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: Desugar.qenv -> out_t: Ast.out_typ -> FStar.All.ML Prims.unit
{ "end_col": 67, "end_line": 157, "start_col": 2, "start_line": 156 }
FStar.All.ML
val push_extern_type (env: qenv) (td: typedef_names) : ML unit
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let push_extern_type (env:qenv) (td:typedef_names) : ML unit = H.insert env.extern_types td.typedef_name.v (); H.insert env.extern_types td.typedef_abbrev.v ()
val push_extern_type (env: qenv) (td: typedef_names) : ML unit let push_extern_type (env: qenv) (td: typedef_names) : ML unit =
true
null
false
H.insert env.extern_types td.typedef_name.v (); H.insert env.extern_types td.typedef_abbrev.v ()
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "ml" ]
[ "Desugar.qenv", "Ast.typedef_names", "Hashtable.insert", "Ast.ident'", "Prims.unit", "Desugar.__proj__Mkqenv__item__extern_types", "Ast.__proj__Mkwith_meta_t__item__v", "Ast.__proj__Mktypedef_names__item__typedef_abbrev", "Ast.__proj__Mktypedef_names__item__typedef_name" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *) let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases let desugar_enum_cases (ityp:integer_type) (cases:list enum_case) (export:bool) : ML (list enum_case & list decl) = let find_definition (i:ident) (d:decl) = match d.d_decl.v with | Define j _ (Int _ _) -> i.v = j.v | _ -> false in let _, cases_rev, ds_rev = List.fold_left (fun (next, cases_rev, ds_rev) (i, jopt) -> let next = match jopt with | Some (Inl j) -> j | Some (Inr j) -> begin match List.Tot.find (find_definition j) ds_rev with | Some ({d_decl={v=Define _ _ (Int _ k)}}) -> k | _ -> error (Printf.sprintf "Enum identifier %s not found" (print_ident j)) j.range end | None -> next in let case = (i, None) in let d = mk_decl (Define i None (Int ityp next)) i.range ["Enum constant"] export in (next + 1, case :: cases_rev, d :: ds_rev)) (0, [], []) cases in List.rev cases_rev, List.rev ds_rev let desugar_one_enum (d:decl) : ML (list decl) = match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] //no enum value assignments; no desugaring to do else //if we have any assignments at all, then we treat all the //tags as fresh constants and assign them values in sequence //with respect to the assigned values of preceding tags let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds@[enum] | _ -> [d] (* This code is currently not used It desugars an Enum to a record with a single refined field *) // let eliminate_enum (d:decl) : ML decl = // match d.v with // | Enum t i cases -> // let names = { // typedef_name = { i with v = { i.v with name=Ast.reserved_prefix ^ Ast.reserved_prefix ^ i.v.name }}; // typedef_abbrev = i; // typedef_ptr_abbrev = { i with v = {i.v with // name = Ast.reserved_prefix ^ Ast.reserved_prefix ^ "P" ^ i.v.name }}; // typedef_attributes = []; // } in // let params = [] in // let where = None in // let field_ident = with_dummy_range (to_ident' (Ast.reserved_prefix ^ "enum_field")) in // let field_ident_expr = with_dummy_range (Identifier field_ident) in // let field_constraint = // List.fold_right // (fun (case, _) out -> // let eq = with_range (App Eq [field_ident_expr; with_range (Identifier case) case.range]) case.range in // with_dummy_range (App Or [eq; out])) // cases // (with_dummy_range (Constant (Bool false))) // in // let field = { // field_dependence = false; // field_ident = field_ident; // field_type = t; // field_array_opt = FieldScalar; // field_constraint = Some field_constraint; // field_number = None; // field_bitwidth = None; // field_action = None // } in // let d' = Record names params where [with_dummy_range field] in // {d with v = d'} // | _ -> d (* * output_types and extern_types tables to set the kind in the Typ_app nodes *) noeq type qenv = { mname : string; module_abbrevs : H.t string string; output_types : H.t ident' unit; extern_types : H.t ident' unit; local_names : list string; global_env: GlobalEnv.global_env; } let push_module_abbrev (env:qenv) (i m:string) : ML unit = H.insert env.module_abbrevs i m let push_output_type (env:qenv) (out_t:out_typ) : ML unit = H.insert env.output_types out_t.out_typ_names.typedef_name.v (); H.insert env.output_types out_t.out_typ_names.typedef_abbrev.v ()
false
false
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val push_extern_type (env: qenv) (td: typedef_names) : ML unit
[]
Desugar.push_extern_type
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: Desugar.qenv -> td: Ast.typedef_names -> FStar.All.ML Prims.unit
{ "end_col": 50, "end_line": 161, "start_col": 2, "start_line": 160 }
FStar.All.ML
val resolve_field_bitwidth_t (env: qenv) (fb: field_bitwidth_t) : ML field_bitwidth_t
[ { "abbrev": true, "full_module": "Hashtable", "short_module": "H" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let resolve_field_bitwidth_t (env:qenv) (fb:field_bitwidth_t) : ML field_bitwidth_t = let resolve_bitfield_attr' (env:qenv) (b:bitfield_attr') : ML bitfield_attr' = { b with bitfield_type = resolve_typ env b.bitfield_type } in let resolve_bitfield_attr (env:qenv) (b:bitfield_attr) : ML bitfield_attr = { b with v = resolve_bitfield_attr' env b.v } in match fb with | Inl _ -> fb | Inr b -> Inr (resolve_bitfield_attr env b)
val resolve_field_bitwidth_t (env: qenv) (fb: field_bitwidth_t) : ML field_bitwidth_t let resolve_field_bitwidth_t (env: qenv) (fb: field_bitwidth_t) : ML field_bitwidth_t =
true
null
false
let resolve_bitfield_attr' (env: qenv) (b: bitfield_attr') : ML bitfield_attr' = { b with bitfield_type = resolve_typ env b.bitfield_type } in let resolve_bitfield_attr (env: qenv) (b: bitfield_attr) : ML bitfield_attr = { b with v = resolve_bitfield_attr' env b.v } in match fb with | Inl _ -> fb | Inr b -> Inr (resolve_bitfield_attr env b)
{ "checked_file": "Desugar.fst.checked", "dependencies": [ "prims.fst.checked", "Hashtable.fsti.checked", "GlobalEnv.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Ast.fst.checked" ], "interface_file": false, "source_file": "Desugar.fst" }
[ "ml" ]
[ "Desugar.qenv", "Ast.field_bitwidth_t", "Ast.with_meta_t", "Prims.int", "Ast.bitfield_attr", "Ast.Inr", "Ast.Mkwith_meta_t", "Ast.bitfield_attr'", "Ast.__proj__Mkwith_meta_t__item__range", "Ast.__proj__Mkwith_meta_t__item__comments", "Ast.__proj__Mkwith_meta_t__item__v", "Ast.Mkbitfield_attr'", "Ast.__proj__Mkbitfield_attr'__item__bitfield_width", "Ast.__proj__Mkbitfield_attr'__item__bitfield_identifier", "Ast.__proj__Mkbitfield_attr'__item__bitfield_from", "Ast.__proj__Mkbitfield_attr'__item__bitfield_to", "Ast.typ", "Desugar.resolve_typ", "Ast.__proj__Mkbitfield_attr'__item__bitfield_type" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Desugar open FStar.List.Tot open FStar.Mul open Ast open FStar.All module H = Hashtable (* This module implements a pass over the source AST, implementing various simple desugarings * Desugar enums with newly defined idents and explicit constant assignments to enums where all the tags are previously defined constants. * Resolve module-qualified names, including the use of module abbreviations * Set the kind (Spec/Output/Extern) in the type nodes * Finds variables in Static expressions and hoists them as assumptions and removes the Static *) let check_desugared_enum_cases (cases:list enum_case) : ML (list ident) = List.map (function | (i, None) -> i | (i, _) -> failwith "Enum should already have been desugared") cases let desugar_enum_cases (ityp:integer_type) (cases:list enum_case) (export:bool) : ML (list enum_case & list decl) = let find_definition (i:ident) (d:decl) = match d.d_decl.v with | Define j _ (Int _ _) -> i.v = j.v | _ -> false in let _, cases_rev, ds_rev = List.fold_left (fun (next, cases_rev, ds_rev) (i, jopt) -> let next = match jopt with | Some (Inl j) -> j | Some (Inr j) -> begin match List.Tot.find (find_definition j) ds_rev with | Some ({d_decl={v=Define _ _ (Int _ k)}}) -> k | _ -> error (Printf.sprintf "Enum identifier %s not found" (print_ident j)) j.range end | None -> next in let case = (i, None) in let d = mk_decl (Define i None (Int ityp next)) i.range ["Enum constant"] export in (next + 1, case :: cases_rev, d :: ds_rev)) (0, [], []) cases in List.rev cases_rev, List.rev ds_rev let desugar_one_enum (d:decl) : ML (list decl) = match d.d_decl.v with | Enum t i cases -> if List.for_all (fun (_, jopt) -> None? jopt) cases then [d] //no enum value assignments; no desugaring to do else //if we have any assignments at all, then we treat all the //tags as fresh constants and assign them values in sequence //with respect to the assigned values of preceding tags let cases, ds = desugar_enum_cases (typ_as_integer_type t) cases d.d_exported in let enum = decl_with_v d (Enum t i cases) in ds@[enum] | _ -> [d] (* This code is currently not used It desugars an Enum to a record with a single refined field *) // let eliminate_enum (d:decl) : ML decl = // match d.v with // | Enum t i cases -> // let names = { // typedef_name = { i with v = { i.v with name=Ast.reserved_prefix ^ Ast.reserved_prefix ^ i.v.name }}; // typedef_abbrev = i; // typedef_ptr_abbrev = { i with v = {i.v with // name = Ast.reserved_prefix ^ Ast.reserved_prefix ^ "P" ^ i.v.name }}; // typedef_attributes = []; // } in // let params = [] in // let where = None in // let field_ident = with_dummy_range (to_ident' (Ast.reserved_prefix ^ "enum_field")) in // let field_ident_expr = with_dummy_range (Identifier field_ident) in // let field_constraint = // List.fold_right // (fun (case, _) out -> // let eq = with_range (App Eq [field_ident_expr; with_range (Identifier case) case.range]) case.range in // with_dummy_range (App Or [eq; out])) // cases // (with_dummy_range (Constant (Bool false))) // in // let field = { // field_dependence = false; // field_ident = field_ident; // field_type = t; // field_array_opt = FieldScalar; // field_constraint = Some field_constraint; // field_number = None; // field_bitwidth = None; // field_action = None // } in // let d' = Record names params where [with_dummy_range field] in // {d with v = d'} // | _ -> d (* * output_types and extern_types tables to set the kind in the Typ_app nodes *) noeq type qenv = { mname : string; module_abbrevs : H.t string string; output_types : H.t ident' unit; extern_types : H.t ident' unit; local_names : list string; global_env: GlobalEnv.global_env; } let push_module_abbrev (env:qenv) (i m:string) : ML unit = H.insert env.module_abbrevs i m let push_output_type (env:qenv) (out_t:out_typ) : ML unit = H.insert env.output_types out_t.out_typ_names.typedef_name.v (); H.insert env.output_types out_t.out_typ_names.typedef_abbrev.v () let push_extern_type (env:qenv) (td:typedef_names) : ML unit = H.insert env.extern_types td.typedef_name.v (); H.insert env.extern_types td.typedef_abbrev.v () let push_name (env:qenv) (name:string) : qenv = { env with local_names = name::env.local_names } let prim_consts = [ "unit"; "Bool"; "UINT8"; "UINT16"; "UINT32"; "UINT64"; "UINT8BE"; "UINT16BE"; "UINT32BE"; "UINT64BE"; "field_id"; "PUINT8"; "all_bytes"; "all_zeros"; "is_range_okay"; "void" ] let resolve_ident (env:qenv) (i:ident) : ML ident = let resolve_to_current_module i = { i with v = { i.v with modul_name = Some env.mname } } in let maybe_resolve_as_ifdef i : ML ident = match env.global_env.ge_cfg with | None -> resolve_to_current_module i | Some (cfg, cfg_module_name) -> if List.mem i.v.name cfg.compile_time_flags.flags then { i with v = { i.v with modul_name = Some cfg_module_name } } else resolve_to_current_module i in if List.mem i.v.name prim_consts //it's a primitive constant, e.g. UINT8, leave as is then i else if List.mem i.v.name env.local_names //it's a local name (e.g. a parameter name) then (if Some? i.v.modul_name //must have module name set to None then error (Printf.sprintf "Ident %s is a local name but has a qualifying modul %s" i.v.name (Some?.v i.v.modul_name)) i.range else i) //return the local name as is else (match i.v.modul_name with //it's a top-level name | None -> maybe_resolve_as_ifdef i | Some m -> //if already qualified, check if it is an abbreviation (match H.try_find env.module_abbrevs m with | None -> i | Some m -> { i with v = { i.v with modul_name = Some m } })) let rec collect_ifdef_guards (env:qenv) (e:expr) : ML unit = let check_resolved_to_ifdef i = match env.global_env.ge_cfg with | None -> false | Some (cfg, cfg_module_name) -> List.mem i.v.name cfg.compile_time_flags.flags && i.v.modul_name = Some cfg_module_name in match e.v with | This -> error "'this' is not allowed in the guard of an #if" e.range | Static _ -> failwith "static should have been eliminated already" | Constant _ -> () | Identifier i -> if not (check_resolved_to_ifdef i) then error (Printf.sprintf "Identifier %s is not a compile-time macro but is used in a #if" i.v.name) e.range | App op args -> begin match op with | And | Or | Not -> List.iter (collect_ifdef_guards env) args | _ -> error "Only boolean expressions over identifiers are supported in #if guards" e.range end let rec resolve_expr' (env:qenv) (e:expr') r : ML expr' = match e with | Constant _ -> e | Identifier i -> Identifier (resolve_ident env i) | This -> e | Static e' -> let e' = resolve_expr env e' in collect_ifdef_guards env e';//mark any variables as top-level IfDef symbols e'.v | App op args -> let args = List.map (resolve_expr env) args in App op args and resolve_expr (env:qenv) (e:expr) : ML expr = { e with v = resolve_expr' env e.v e.range } let resolve_typ_param (env:qenv) (p:typ_param) : ML typ_param = match p with | Inl e -> resolve_expr env e |> Inl | _ -> p //Currently not going inside output expressions, should we? let kind_of_ident (env:qenv) (i:ident) : ML t_kind = let _or_ (b0 b1:bool) = b0 || b1 in if Some? (H.try_find env.output_types i.v) `_or_` Some? (H.try_find env.global_env.ge_out_t i.v) then KindOutput else if Some? (H.try_find env.extern_types i.v) `_or_` Some? (H.try_find env.global_env.ge_extern_t i.v) then KindExtern else KindSpec let rec resolve_typ' (env:qenv) (t:typ') : ML typ' = match t with | Type_app hd _ args -> let hd = resolve_ident env hd in //Set is_out argument to the Type_app appropriately let k = kind_of_ident env hd in Type_app hd k (List.map (resolve_typ_param env) args) | Pointer t -> Pointer (resolve_typ env t) and resolve_typ (env:qenv) (t:typ) : ML typ = { t with v = resolve_typ' env t.v } let resolve_atomic_action (env:qenv) (ac:atomic_action) : ML atomic_action = match ac with | Action_return e -> Action_return (resolve_expr env e) | Action_abort | Action_field_pos_64 | Action_field_pos_32 | Action_field_ptr -> ac | Action_field_ptr_after e write_to -> Action_field_ptr_after (resolve_expr env e) write_to | Action_deref i -> Action_deref i //most certainly a type parameter | Action_assignment lhs rhs -> Action_assignment lhs (resolve_expr env rhs) //lhs is an action-local variable | Action_call f args -> Action_call (resolve_ident env f) (List.map (resolve_expr env) args) let rec resolve_action' (env:qenv) (act:action') : ML action' = match act with | Atomic_action ac -> Atomic_action (resolve_atomic_action env ac) | Action_seq hd tl -> Action_seq (resolve_atomic_action env hd) (resolve_action env tl) | Action_ite hd then_ else_ -> Action_ite (resolve_expr env hd) (resolve_action env then_) (map_opt (resolve_action env) else_) | Action_let i a k -> Action_let i (resolve_atomic_action env a) (resolve_action (push_name env i.v.name) k) | Action_act a -> Action_act (resolve_action env a) and resolve_action (env:qenv) (act:action) : ML action = { act with v = resolve_action' env act.v } let resolve_param (env:qenv) (p:param) : ML (param & qenv) = let t, i, q = p in (resolve_typ env t, i, q), push_name env i.v.name let resolve_params (env:qenv) (params:list param) : ML (list param & qenv) = List.fold_left (fun (params, env) p -> let p, env = resolve_param env p in params@[p], env) ([], env) params
false
false
Desugar.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val resolve_field_bitwidth_t (env: qenv) (fb: field_bitwidth_t) : ML field_bitwidth_t
[]
Desugar.resolve_field_bitwidth_t
{ "file_name": "src/3d/Desugar.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: Desugar.qenv -> fb: Ast.field_bitwidth_t -> FStar.All.ML Ast.field_bitwidth_t
{ "end_col": 46, "end_line": 323, "start_col": 85, "start_line": 314 }