file_name
stringlengths 5
52
| name
stringlengths 4
95
| original_source_type
stringlengths 0
23k
| source_type
stringlengths 9
23k
| source_definition
stringlengths 9
57.9k
| source
dict | source_range
dict | file_context
stringlengths 0
721k
| dependencies
dict | opens_and_abbrevs
listlengths 2
94
| vconfig
dict | interleaved
bool 1
class | verbose_type
stringlengths 1
7.42k
| effect
stringclasses 118
values | effect_flags
sequencelengths 0
2
| mutual_with
sequencelengths 0
11
| ideal_premises
sequencelengths 0
236
| proof_features
sequencelengths 0
1
| is_simple_lemma
bool 2
classes | is_div
bool 2
classes | is_proof
bool 2
classes | is_simply_typed
bool 2
classes | is_type
bool 2
classes | partial_definition
stringlengths 5
3.99k
| completed_definiton
stringlengths 1
1.63M
| isa_cross_project_example
bool 1
class |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
CQueue.fst | CQueue.vbind_sel | val vbind_sel (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot (selector t (vbind_hp a t b)) | val vbind_sel (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot (selector t (vbind_hp a t b)) | let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b) | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 23,
"end_line": 197,
"start_col": 0,
"start_line": 192
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Steel.Effect.Common.vprop ->
t: Type0 ->
b: (_: Steel.Effect.Common.t_of a -> Steel.Effect.Common.vprop)
-> Prims.GTot (Steel.Effect.Common.selector t (CQueue.vbind_hp a t b)) | Prims.GTot | [
"sometrivial"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.t_of",
"Steel.Effect.Common.sel_of",
"CQueue.vbind0",
"Steel.Effect.Common.selector",
"CQueue.vbind_hp"
] | [] | false | false | false | false | false | let vbind_sel (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot (selector t (vbind_hp a t b)) =
| sel_of (vbind0 a t b) | false |
CQueue.fst | CQueue.vbind0_payload | val vbind0_payload (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: t_of a) : Tot vprop | val vbind0_payload (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: t_of a) : Tot vprop | let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 36,
"end_line": 167,
"start_col": 0,
"start_line": 161
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Steel.Effect.Common.vprop ->
t: Type0 ->
b: (_: Steel.Effect.Common.t_of a -> Steel.Effect.Common.vprop) ->
x: Steel.Effect.Common.t_of a
-> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.t_of",
"Steel.Effect.Common.star",
"CQueue.vpure",
"Prims.eq2"
] | [] | false | false | false | false | false | let vbind0_payload (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: t_of a) : Tot vprop =
| (vpure (t == t_of (b x))) `star` (b x) | false |
Vale.X64.InsSha.fst | Vale.X64.InsSha.va_code_SHA256_rnds2 | val va_code_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code | val va_code_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code | let va_code_SHA256_rnds2 dst src =
(mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src))) | {
"file_name": "obj/Vale.X64.InsSha.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 66,
"end_line": 24,
"start_col": 0,
"start_line": 23
} | module Vale.X64.InsSha
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.Decls
open Vale.X64.CryptoInstructions_s
open Spec.Hash.Definitions
open Spec.SHA2
open Vale.X64.CPU_Features_s
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
module P = Vale.X64.Print_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 2 --z3rlimit 20"
//-- SHA256_rnds2 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsSha.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Print_s",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 4,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.X64.Decls.va_operand_xmm -> src: Vale.X64.Decls.va_operand_xmm -> Vale.X64.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.opXmm",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.oneXmm",
"Vale.X64.Machine_s.OReg",
"Vale.X64.Machine_s.quad32",
"Vale.X64.Machine_s.reg_xmm",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_SHA256_rnds2",
"Vale.X64.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_SHA256_rnds2 dst src =
| (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src))) | false |
CQueue.fst | CQueue.vbind' | val vbind' (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot vprop' | val vbind' (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot vprop' | let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
} | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 1,
"end_line": 209,
"start_col": 0,
"start_line": 200
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Steel.Effect.Common.vprop ->
t: Type0 ->
b: (_: Steel.Effect.Common.t_of a -> Steel.Effect.Common.vprop)
-> Prims.GTot Steel.Effect.Common.vprop' | Prims.GTot | [
"sometrivial"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.t_of",
"Steel.Effect.Common.Mkvprop'",
"CQueue.vbind_hp",
"CQueue.vbind_sel",
"Steel.Effect.Common.vprop'"
] | [] | false | false | false | false | false | let vbind' (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot vprop' =
| { hp = vbind_hp a t b; t = t; sel = vbind_sel a t b } | false |
CQueue.fst | CQueue.vbind | val vbind (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop | val vbind (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop | let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b) | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 22,
"end_line": 217,
"start_col": 0,
"start_line": 212
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
} | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Steel.Effect.Common.vprop ->
t: Type0 ->
b: (_: Steel.Effect.Common.t_of a -> Steel.Effect.Common.vprop)
-> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.t_of",
"Steel.Effect.Common.VUnit",
"CQueue.vbind'"
] | [] | false | false | false | false | false | let vbind (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop =
| VUnit (vbind' a t b) | false |
Vale.X64.InsSha.fst | Vale.X64.InsSha.va_code_SHA256_msg2 | val va_code_SHA256_msg2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code | val va_code_SHA256_msg2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code | let va_code_SHA256_msg2 dst src =
(mk_ins (make_instr (I.ins_SHA256_msg2) (OReg dst) (OReg src))) | {
"file_name": "obj/Vale.X64.InsSha.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 65,
"end_line": 88,
"start_col": 0,
"start_line": 87
} | module Vale.X64.InsSha
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.Decls
open Vale.X64.CryptoInstructions_s
open Spec.Hash.Definitions
open Spec.SHA2
open Vale.X64.CPU_Features_s
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
module P = Vale.X64.Print_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 2 --z3rlimit 20"
//-- SHA256_rnds2
[@ "opaque_to_smt"]
let va_code_SHA256_rnds2 dst src =
(mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src)))
[@ "opaque_to_smt"]
let va_codegen_success_SHA256_rnds2 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SHA256_rnds2 va_b0 va_s0 dst src t block hash_orig =
va_reveal_opaque (`%va_code_SHA256_rnds2) (va_code_SHA256_rnds2 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src)))
va_s0 in
lemma_sha256_rnds2 (va_eval_xmm va_old_s src) (va_eval_xmm va_old_s dst) (va_get_xmm 0 va_old_s)
t block hash_orig;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SHA256_rnds2 dst src t block hash_orig va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SHA256_rnds2 (va_code_SHA256_rnds2 dst src) va_s0 dst src t block
hash_orig in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_xmm dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- SHA256_msg1
[@ "opaque_to_smt"]
let va_code_SHA256_msg1 dst src =
(mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src)))
[@ "opaque_to_smt"]
let va_codegen_success_SHA256_msg1 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SHA256_msg1 va_b0 va_s0 dst src t block =
va_reveal_opaque (`%va_code_SHA256_msg1) (va_code_SHA256_msg1 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src)))
va_s0 in
lemma_sha256_msg1 (va_eval_xmm va_old_s dst) (va_eval_xmm va_old_s src) t block;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SHA256_msg1 dst src t block va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SHA256_msg1 (va_code_SHA256_msg1 dst src) va_s0 dst src t block in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_xmm dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- SHA256_msg2 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsSha.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Print_s",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 4,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.X64.Decls.va_operand_xmm -> src: Vale.X64.Decls.va_operand_xmm -> Vale.X64.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.opXmm",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_SHA256_msg2",
"Vale.X64.Machine_s.OReg",
"Vale.X64.Machine_s.quad32",
"Vale.X64.Machine_s.reg_xmm",
"Vale.X64.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_SHA256_msg2 dst src =
| (mk_ins (make_instr (I.ins_SHA256_msg2) (OReg dst) (OReg src))) | false |
Vale.X64.InsSha.fst | Vale.X64.InsSha.va_wpProof_SHA256_msg1 | val va_wpProof_SHA256_msg1 : dst:va_operand_xmm -> src:va_operand_xmm -> t:counter -> block:block_w
-> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_SHA256_msg1 dst src t block va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_SHA256_msg1 dst src) ([va_mod_xmm
dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) | val va_wpProof_SHA256_msg1 : dst:va_operand_xmm -> src:va_operand_xmm -> t:counter -> block:block_w
-> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_SHA256_msg1 dst src t block va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_SHA256_msg1 dst src) ([va_mod_xmm
dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) | let va_wpProof_SHA256_msg1 dst src t block va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SHA256_msg1 (va_code_SHA256_msg1 dst src) va_s0 dst src t block in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_xmm dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"file_name": "obj/Vale.X64.InsSha.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 81,
"start_col": 0,
"start_line": 75
} | module Vale.X64.InsSha
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.Decls
open Vale.X64.CryptoInstructions_s
open Spec.Hash.Definitions
open Spec.SHA2
open Vale.X64.CPU_Features_s
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
module P = Vale.X64.Print_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 2 --z3rlimit 20"
//-- SHA256_rnds2
[@ "opaque_to_smt"]
let va_code_SHA256_rnds2 dst src =
(mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src)))
[@ "opaque_to_smt"]
let va_codegen_success_SHA256_rnds2 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SHA256_rnds2 va_b0 va_s0 dst src t block hash_orig =
va_reveal_opaque (`%va_code_SHA256_rnds2) (va_code_SHA256_rnds2 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src)))
va_s0 in
lemma_sha256_rnds2 (va_eval_xmm va_old_s src) (va_eval_xmm va_old_s dst) (va_get_xmm 0 va_old_s)
t block hash_orig;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SHA256_rnds2 dst src t block hash_orig va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SHA256_rnds2 (va_code_SHA256_rnds2 dst src) va_s0 dst src t block
hash_orig in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_xmm dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- SHA256_msg1
[@ "opaque_to_smt"]
let va_code_SHA256_msg1 dst src =
(mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src)))
[@ "opaque_to_smt"]
let va_codegen_success_SHA256_msg1 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SHA256_msg1 va_b0 va_s0 dst src t block =
va_reveal_opaque (`%va_code_SHA256_msg1) (va_code_SHA256_msg1 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src)))
va_s0 in
lemma_sha256_msg1 (va_eval_xmm va_old_s dst) (va_eval_xmm va_old_s src) t block;
(va_sM, va_fM) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsSha.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Print_s",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 4,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | Prims.Ghost | [] | [] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_mod_xmm",
"Prims.Nil",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_update_operand_xmm",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.X64.InsSha.va_lemma_SHA256_msg1",
"Vale.X64.InsSha.va_code_SHA256_msg1"
] | [] | false | false | false | false | false | let va_wpProof_SHA256_msg1 dst src t block va_s0 va_k =
| let va_sM, va_f0 = va_lemma_SHA256_msg1 (va_code_SHA256_msg1 dst src) va_s0 dst src t block in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_xmm dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | false |
SelectorsLList3Example.fst | SelectorsLList3Example.is_nil | val is_nil (ptr: t)
: Steel bool
(LL.llist ptr)
(fun _ -> LL.llist ptr)
(requires fun _ -> True)
(ensures
fun h0 res h1 ->
(res == true <==> ptr == null_llist ()) /\ LL.v_llist ptr h0 == LL.v_llist ptr h1 /\
res == Nil? (LL.v_llist ptr h1)) | val is_nil (ptr: t)
: Steel bool
(LL.llist ptr)
(fun _ -> LL.llist ptr)
(requires fun _ -> True)
(ensures
fun h0 res h1 ->
(res == true <==> ptr == null_llist ()) /\ LL.v_llist ptr h0 == LL.v_llist ptr h1 /\
res == Nil? (LL.v_llist ptr h1)) | let is_nil (ptr:t)
: Steel bool (LL.llist ptr) (fun _ -> LL.llist ptr)
(requires fun _ -> True)
(ensures fun h0 res h1 ->
(res == true <==> ptr == null_llist ()) /\
LL.v_llist ptr h0 == LL.v_llist ptr h1 /\
res == Nil? (LL.v_llist ptr h1))
= LL.is_nil ptr | {
"file_name": "share/steel/examples/steel/llist3/SelectorsLList3Example.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 15,
"end_line": 43,
"start_col": 0,
"start_line": 36
} | module SelectorsLList3Example
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.ArrayRef
module L = FStar.List.Tot
module LL = Selectors.LList3
module U32 = FStar.UInt32
module MB = LowStar.Monotonic.Buffer // for is_null
inline_for_extraction noextract let a = U32.t
let cell = LL.cell a
/// The type of a list: A reference to a cell
let t = LL.t a
let next (c:cell) : t = LL.next c
let data (c:cell) : a = LL.data c
let mk_cell (n: t) (d:a)
: Pure cell
(requires True)
(ensures fun c ->
next c == n /\
data c == d)
= LL.mk_cell n d
/// The null list pointer
let null_llist () : t = LL.null_llist
/// Lifting the null pointer check to empty lists
let is_null (ptr:t) : (b:bool{b <==> ptr == null_llist ()})
= LL.is_null ptr | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"Steel.ArrayRef.fsti.checked",
"Selectors.LList3.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "SelectorsLList3Example.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer // for is_null",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "Selectors.LList3",
"short_module": "LL"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.ArrayRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ptr: SelectorsLList3Example.t -> Steel.Effect.Steel Prims.bool | Steel.Effect.Steel | [] | [] | [
"SelectorsLList3Example.t",
"Selectors.LList3.is_nil",
"SelectorsLList3Example.a",
"Prims.bool",
"Selectors.LList3.llist",
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.rmem",
"Prims.l_True",
"Prims.l_and",
"Prims.l_iff",
"Prims.eq2",
"SelectorsLList3Example.null_llist",
"Prims.list",
"Selectors.LList3.v_llist",
"Prims.uu___is_Nil"
] | [] | false | true | false | false | false | let is_nil (ptr: t)
: Steel bool
(LL.llist ptr)
(fun _ -> LL.llist ptr)
(requires fun _ -> True)
(ensures
fun h0 res h1 ->
(res == true <==> ptr == null_llist ()) /\ LL.v_llist ptr h0 == LL.v_llist ptr h1 /\
res == Nil? (LL.v_llist ptr h1)) =
| LL.is_nil ptr | false |
Vale.X64.InsSha.fst | Vale.X64.InsSha.va_wpProof_SHA256_rnds2 | val va_wpProof_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> t:counter ->
block:block_w -> hash_orig:hash256 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_SHA256_rnds2 dst src t block hash_orig va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_SHA256_rnds2 dst src) ([va_mod_xmm
dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) | val va_wpProof_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> t:counter ->
block:block_w -> hash_orig:hash256 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_SHA256_rnds2 dst src t block hash_orig va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_SHA256_rnds2 dst src) ([va_mod_xmm
dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) | let va_wpProof_SHA256_rnds2 dst src t block hash_orig va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SHA256_rnds2 (va_code_SHA256_rnds2 dst src) va_s0 dst src t block
hash_orig in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_xmm dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"file_name": "obj/Vale.X64.InsSha.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 50,
"start_col": 0,
"start_line": 43
} | module Vale.X64.InsSha
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.Decls
open Vale.X64.CryptoInstructions_s
open Spec.Hash.Definitions
open Spec.SHA2
open Vale.X64.CPU_Features_s
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
module P = Vale.X64.Print_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 2 --z3rlimit 20"
//-- SHA256_rnds2
[@ "opaque_to_smt"]
let va_code_SHA256_rnds2 dst src =
(mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src)))
[@ "opaque_to_smt"]
let va_codegen_success_SHA256_rnds2 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SHA256_rnds2 va_b0 va_s0 dst src t block hash_orig =
va_reveal_opaque (`%va_code_SHA256_rnds2) (va_code_SHA256_rnds2 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src)))
va_s0 in
lemma_sha256_rnds2 (va_eval_xmm va_old_s src) (va_eval_xmm va_old_s dst) (va_get_xmm 0 va_old_s)
t block hash_orig;
(va_sM, va_fM) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsSha.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Print_s",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 4,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w ->
hash_orig: Vale.SHA.SHA_helpers.hash256 ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | Prims.Ghost | [] | [] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.hash256",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_mod_xmm",
"Prims.Nil",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_update_operand_xmm",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.X64.InsSha.va_lemma_SHA256_rnds2",
"Vale.X64.InsSha.va_code_SHA256_rnds2"
] | [] | false | false | false | false | false | let va_wpProof_SHA256_rnds2 dst src t block hash_orig va_s0 va_k =
| let va_sM, va_f0 =
va_lemma_SHA256_rnds2 (va_code_SHA256_rnds2 dst src) va_s0 dst src t block hash_orig
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_xmm dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | false |
Vale.X64.InsSha.fst | Vale.X64.InsSha.va_wpProof_SHA256_msg2 | val va_wpProof_SHA256_msg2 : dst:va_operand_xmm -> src:va_operand_xmm -> t:counter -> block:block_w
-> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_SHA256_msg2 dst src t block va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_SHA256_msg2 dst src) ([va_mod_xmm
dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) | val va_wpProof_SHA256_msg2 : dst:va_operand_xmm -> src:va_operand_xmm -> t:counter -> block:block_w
-> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_SHA256_msg2 dst src t block va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_SHA256_msg2 dst src) ([va_mod_xmm
dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) | let va_wpProof_SHA256_msg2 dst src t block va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SHA256_msg2 (va_code_SHA256_msg2 dst src) va_s0 dst src t block in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_xmm dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"file_name": "obj/Vale.X64.InsSha.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 112,
"start_col": 0,
"start_line": 106
} | module Vale.X64.InsSha
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.Decls
open Vale.X64.CryptoInstructions_s
open Spec.Hash.Definitions
open Spec.SHA2
open Vale.X64.CPU_Features_s
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
module P = Vale.X64.Print_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 2 --z3rlimit 20"
//-- SHA256_rnds2
[@ "opaque_to_smt"]
let va_code_SHA256_rnds2 dst src =
(mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src)))
[@ "opaque_to_smt"]
let va_codegen_success_SHA256_rnds2 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SHA256_rnds2 va_b0 va_s0 dst src t block hash_orig =
va_reveal_opaque (`%va_code_SHA256_rnds2) (va_code_SHA256_rnds2 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src)))
va_s0 in
lemma_sha256_rnds2 (va_eval_xmm va_old_s src) (va_eval_xmm va_old_s dst) (va_get_xmm 0 va_old_s)
t block hash_orig;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SHA256_rnds2 dst src t block hash_orig va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SHA256_rnds2 (va_code_SHA256_rnds2 dst src) va_s0 dst src t block
hash_orig in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_xmm dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- SHA256_msg1
[@ "opaque_to_smt"]
let va_code_SHA256_msg1 dst src =
(mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src)))
[@ "opaque_to_smt"]
let va_codegen_success_SHA256_msg1 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SHA256_msg1 va_b0 va_s0 dst src t block =
va_reveal_opaque (`%va_code_SHA256_msg1) (va_code_SHA256_msg1 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src)))
va_s0 in
lemma_sha256_msg1 (va_eval_xmm va_old_s dst) (va_eval_xmm va_old_s src) t block;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SHA256_msg1 dst src t block va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SHA256_msg1 (va_code_SHA256_msg1 dst src) va_s0 dst src t block in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_xmm dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- SHA256_msg2
[@ "opaque_to_smt"]
let va_code_SHA256_msg2 dst src =
(mk_ins (make_instr (I.ins_SHA256_msg2) (OReg dst) (OReg src)))
[@ "opaque_to_smt"]
let va_codegen_success_SHA256_msg2 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SHA256_msg2 va_b0 va_s0 dst src t block =
va_reveal_opaque (`%va_code_SHA256_msg2) (va_code_SHA256_msg2 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_msg2) (OReg dst) (OReg src))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_SHA256_msg2) (OReg dst) (OReg src)))
va_s0 in
lemma_sha256_msg2 (va_eval_xmm va_old_s dst) (va_eval_xmm va_old_s src) t block;
(va_sM, va_fM) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsSha.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Print_s",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 4,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | Prims.Ghost | [] | [] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_mod_xmm",
"Prims.Nil",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_update_operand_xmm",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.X64.InsSha.va_lemma_SHA256_msg2",
"Vale.X64.InsSha.va_code_SHA256_msg2"
] | [] | false | false | false | false | false | let va_wpProof_SHA256_msg2 dst src t block va_s0 va_k =
| let va_sM, va_f0 = va_lemma_SHA256_msg2 (va_code_SHA256_msg2 dst src) va_s0 dst src t block in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_xmm dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | false |
Lib.IntVector.Transpose.fst | Lib.IntVector.Transpose.transpose8x8_lemma_uint32_ij | val transpose8x8_lemma_uint32_ij: vs:lseq (vec_t U32 8) 8 -> i:nat{i < 8} -> j:nat{j < 8} ->
Lemma ((vec_v (transpose8x8_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i]) | val transpose8x8_lemma_uint32_ij: vs:lseq (vec_t U32 8) 8 -> i:nat{i < 8} -> j:nat{j < 8} ->
Lemma ((vec_v (transpose8x8_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i]) | let transpose8x8_lemma_uint32_ij vs0 i j =
transpose8x8_lseq_is_transposewxw vs0;
let n = 3 in
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 2;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #8 n) vs0;
let res0 = transposewxw_f n 0 vs0 in
let res1 = transposewxw_f n 1 res0 in
let res2 = transposewxw_f n 2 res1 in
vec_interleave_low_n_lemma_uint32_8_4 res1.[0] res1.[4];
vec_interleave_low_n_lemma_uint32_8_4 res1.[1] res1.[5];
vec_interleave_low_n_lemma_uint32_8_4 res1.[2] res1.[6];
vec_interleave_low_n_lemma_uint32_8_4 res1.[3] res1.[7];
vec_interleave_high_n_lemma_uint32_8_4 res1.[0] res1.[4];
vec_interleave_high_n_lemma_uint32_8_4 res1.[1] res1.[5];
vec_interleave_high_n_lemma_uint32_8_4 res1.[2] res1.[6];
vec_interleave_high_n_lemma_uint32_8_4 res1.[3] res1.[7];
vec_interleave_low_n_lemma_uint32_8_2 res0.[0] res0.[2];
vec_interleave_low_n_lemma_uint32_8_2 res0.[1] res0.[3];
vec_interleave_low_n_lemma_uint32_8_2 res0.[4] res0.[6];
vec_interleave_low_n_lemma_uint32_8_2 res0.[5] res0.[7];
vec_interleave_high_n_lemma_uint32_8_2 res0.[0] res0.[2];
vec_interleave_high_n_lemma_uint32_8_2 res0.[1] res0.[3];
vec_interleave_high_n_lemma_uint32_8_2 res0.[4] res0.[6];
vec_interleave_high_n_lemma_uint32_8_2 res0.[5] res0.[7];
vec_interleave_low_lemma_uint32_8 vs0.[0] vs0.[1];
vec_interleave_low_lemma_uint32_8 vs0.[2] vs0.[3];
vec_interleave_low_lemma_uint32_8 vs0.[4] vs0.[5];
vec_interleave_low_lemma_uint32_8 vs0.[6] vs0.[7];
vec_interleave_high_lemma_uint32_8 vs0.[0] vs0.[1];
vec_interleave_high_lemma_uint32_8 vs0.[2] vs0.[3];
vec_interleave_high_lemma_uint32_8 vs0.[4] vs0.[5];
vec_interleave_high_lemma_uint32_8 vs0.[6] vs0.[7] | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 307,
"start_col": 0,
"start_line": 270
} | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
}
inline_for_extraction
val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w
let transposewxw_f_l #w #t n i vs l =
Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then begin
lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[l] vs.[l + pow2 i] end
else
vec_interleave_high_n (pow2 i) vs.[l - pow2 i] vs.[l]
inline_for_extraction
val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_f #w #t n i vs =
createi w (transposewxw_f_l #w n i vs)
val transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_lseq #w #t n vs =
Loops.repeati n (transposewxw_f #w n) vs
///
/// transposewxw_lseq lemmas
///
inline_for_extraction
let f_lseq4 (#t:v_inttype) (vs:lseq (vec_t t 4) 4) (f:vec_t4 t -> vec_t4 t) : lseq (vec_t t 4) 4 =
let (v0,v1,v2,v3) = (vs.[0],vs.[1],vs.[2],vs.[3]) in
let (r0,r1,r2,r3) = f (v0,v1,v2,v3) in
create4 r0 r1 r2 r3
val transpose4x4_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 4) 4 ->
Lemma (transposewxw_lseq 2 vs `Seq.equal` f_lseq4 vs transpose4x4_0)
let transpose4x4_lseq_is_transposewxw #t vs0 =
let n = 2 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
eq_intro (transposewxw_lseq 2 vs0) (f_lseq4 vs0 transpose4x4_0)
inline_for_extraction
let f_lseq8 (#t:v_inttype) (vs:lseq (vec_t t 8) 8) (f:vec_t8 t -> vec_t8 t) : lseq (vec_t t 8) 8 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = (vs.[0],vs.[1],vs.[2],vs.[3],vs.[4],vs.[5],vs.[6],vs.[7]) in
let (r0,r1,r2,r3,r4,r5,r6,r7) = f (v0,v1,v2,v3,v4,v5,v6,v7) in
create8 r0 r1 r2 r3 r4 r5 r6 r7
val transpose8x8_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 8) 8 ->
Lemma (transposewxw_lseq 3 vs `Seq.equal` f_lseq8 vs transpose8x8_012)
let transpose8x8_lseq_is_transposewxw #t vs0 =
let n = 3 in
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 2;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #8 n) vs0;
let res0 = transposewxw_f n 0 vs0 in
eq_intro res0 (f_lseq8 vs0 transpose8x8_0);
let res1 = transposewxw_f n 1 res0 in
eq_intro res1 (f_lseq8 res0 transpose8x8_1);
let res2 = transposewxw_f n 2 res1 in
eq_intro res2 (f_lseq8 res1 transpose8x8_2);
eq_intro (transposewxw_lseq 3 vs0) (f_lseq8 vs0 transpose8x8_012)
val transpose4x4_lemma_uint32_ij: vs:lseq (vec_t U32 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose4x4_lemma_uint32_ij vs0 i j =
transpose4x4_lseq_is_transposewxw vs0;
let n = 2 in
let r = transposewxw_lseq 2 vs0 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
let res0 = transposewxw_f 2 0 vs0 in
let res1 = transposewxw_f 2 1 res0 in
vec_interleave_low_n_lemma_uint32_4_2 res0.[0] res0.[2];
vec_interleave_high_n_lemma_uint32_4_2 res0.[0] res0.[2];
vec_interleave_low_n_lemma_uint32_4_2 res0.[1] res0.[3];
vec_interleave_high_n_lemma_uint32_4_2 res0.[1] res0.[3];
vec_interleave_low_lemma_uint32_4 vs0.[0] vs0.[1];
vec_interleave_high_lemma_uint32_4 vs0.[0] vs0.[1];
vec_interleave_low_lemma_uint32_4 vs0.[2] vs0.[3];
vec_interleave_high_lemma_uint32_4 vs0.[2] vs0.[3]
val transpose4x4_lemma_uint64_ij: vs:lseq (vec_t U64 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U64 vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose4x4_lemma_uint64_ij vs0 i j =
transpose4x4_lseq_is_transposewxw vs0;
let n = 2 in
let r = transposewxw_lseq 2 vs0 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
let res0 = transposewxw_f 2 0 vs0 in
let res1 = transposewxw_f 2 1 res0 in
vec_interleave_low_n_lemma_uint64_4_2 res0.[0] res0.[2];
vec_interleave_high_n_lemma_uint64_4_2 res0.[0] res0.[2];
vec_interleave_low_n_lemma_uint64_4_2 res0.[1] res0.[3];
vec_interleave_high_n_lemma_uint64_4_2 res0.[1] res0.[3];
vec_interleave_low_lemma_uint64_4 vs0.[0] vs0.[1];
vec_interleave_high_lemma_uint64_4 vs0.[0] vs0.[1];
vec_interleave_low_lemma_uint64_4 vs0.[2] vs0.[3];
vec_interleave_high_lemma_uint64_4 vs0.[2] vs0.[3]
val transpose8x8_lemma_uint32_ij: vs:lseq (vec_t U32 8) 8 -> i:nat{i < 8} -> j:nat{j < 8} ->
Lemma ((vec_v (transpose8x8_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i]) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
vs: Lib.Sequence.lseq (Lib.IntVector.vec_t Lib.IntTypes.U32 8) 8 ->
i: Prims.nat{i < 8} ->
j: Prims.nat{j < 8}
-> FStar.Pervasives.Lemma
(ensures
(Lib.IntVector.vec_v (Lib.IntVector.Transpose.transpose8x8_lseq vs).[ i ]).[ j ] ==
(Lib.IntVector.vec_v vs.[ j ]).[ i ]) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.IntTypes.U32",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntVector.vec_interleave_high_lemma_uint32_8",
"Lib.Sequence.op_String_Access",
"Prims.unit",
"Lib.IntVector.vec_interleave_low_lemma_uint32_8",
"Lib.IntVector.vec_interleave_high_n_lemma_uint32_8_2",
"Lib.IntVector.vec_interleave_low_n_lemma_uint32_8_2",
"Lib.IntVector.vec_interleave_high_n_lemma_uint32_8_4",
"Lib.IntVector.vec_interleave_low_n_lemma_uint32_8_4",
"Lib.IntVector.Transpose.transposewxw_f",
"Lib.LoopCombinators.eq_repeati0",
"Lib.LoopCombinators.unfold_repeati",
"Prims.int",
"Lib.IntVector.Transpose.transpose8x8_lseq_is_transposewxw"
] | [] | true | false | true | false | false | let transpose8x8_lemma_uint32_ij vs0 i j =
| transpose8x8_lseq_is_transposewxw vs0;
let n = 3 in
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 2;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #8 n) vs0;
let res0 = transposewxw_f n 0 vs0 in
let res1 = transposewxw_f n 1 res0 in
let res2 = transposewxw_f n 2 res1 in
vec_interleave_low_n_lemma_uint32_8_4 res1.[ 0 ] res1.[ 4 ];
vec_interleave_low_n_lemma_uint32_8_4 res1.[ 1 ] res1.[ 5 ];
vec_interleave_low_n_lemma_uint32_8_4 res1.[ 2 ] res1.[ 6 ];
vec_interleave_low_n_lemma_uint32_8_4 res1.[ 3 ] res1.[ 7 ];
vec_interleave_high_n_lemma_uint32_8_4 res1.[ 0 ] res1.[ 4 ];
vec_interleave_high_n_lemma_uint32_8_4 res1.[ 1 ] res1.[ 5 ];
vec_interleave_high_n_lemma_uint32_8_4 res1.[ 2 ] res1.[ 6 ];
vec_interleave_high_n_lemma_uint32_8_4 res1.[ 3 ] res1.[ 7 ];
vec_interleave_low_n_lemma_uint32_8_2 res0.[ 0 ] res0.[ 2 ];
vec_interleave_low_n_lemma_uint32_8_2 res0.[ 1 ] res0.[ 3 ];
vec_interleave_low_n_lemma_uint32_8_2 res0.[ 4 ] res0.[ 6 ];
vec_interleave_low_n_lemma_uint32_8_2 res0.[ 5 ] res0.[ 7 ];
vec_interleave_high_n_lemma_uint32_8_2 res0.[ 0 ] res0.[ 2 ];
vec_interleave_high_n_lemma_uint32_8_2 res0.[ 1 ] res0.[ 3 ];
vec_interleave_high_n_lemma_uint32_8_2 res0.[ 4 ] res0.[ 6 ];
vec_interleave_high_n_lemma_uint32_8_2 res0.[ 5 ] res0.[ 7 ];
vec_interleave_low_lemma_uint32_8 vs0.[ 0 ] vs0.[ 1 ];
vec_interleave_low_lemma_uint32_8 vs0.[ 2 ] vs0.[ 3 ];
vec_interleave_low_lemma_uint32_8 vs0.[ 4 ] vs0.[ 5 ];
vec_interleave_low_lemma_uint32_8 vs0.[ 6 ] vs0.[ 7 ];
vec_interleave_high_lemma_uint32_8 vs0.[ 0 ] vs0.[ 1 ];
vec_interleave_high_lemma_uint32_8 vs0.[ 2 ] vs0.[ 3 ];
vec_interleave_high_lemma_uint32_8 vs0.[ 4 ] vs0.[ 5 ];
vec_interleave_high_lemma_uint32_8 vs0.[ 6 ] vs0.[ 7 ] | false |
CQueue.fst | CQueue.t | val t (a: Type0) : Tot Type0 | val t (a: Type0) : Tot Type0 | let t a = cllist_lvalue a | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 25,
"end_line": 335,
"start_col": 0,
"start_line": 335
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type0 -> Type0 | Prims.Tot | [
"total"
] | [] | [
"CQueue.LList.cllist_lvalue"
] | [] | false | false | false | true | true | let t a =
| cllist_lvalue a | false |
CQueue.fst | CQueue.v | val v (a: Type0) : Tot Type0 | val v (a: Type0) : Tot Type0 | let v (a: Type0) = list a | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 25,
"end_line": 337,
"start_col": 0,
"start_line": 337
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type0 -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.list"
] | [] | false | false | false | true | true | let v (a: Type0) =
| list a | false |
CQueue.fst | CQueue.datas | val datas (#a: Type0) (l: v a) : Tot (list a) | val datas (#a: Type0) (l: v a) : Tot (list a) | let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 3,
"end_line": 343,
"start_col": 0,
"start_line": 339
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: CQueue.v a -> Prims.list a | Prims.Tot | [
"total"
] | [] | [
"CQueue.v",
"Prims.list"
] | [] | false | false | false | true | false | let datas (#a: Type0) (l: v a) : Tot (list a) =
| l | false |
CQueue.fst | CQueue.ccell_is_lvalue_refine | val ccell_is_lvalue_refine (a: Type) (c: ccell_ptrvalue a) : Tot prop | val ccell_is_lvalue_refine (a: Type) (c: ccell_ptrvalue a) : Tot prop | let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 35,
"end_line": 366,
"start_col": 0,
"start_line": 362
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type0 -> c: CQueue.Cell.ccell_ptrvalue a -> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"CQueue.Cell.ccell_ptrvalue",
"CQueue.op_Equals_Equals",
"Prims.bool",
"CQueue.Cell.ccell_ptrvalue_is_null",
"Prims.prop"
] | [] | false | false | false | true | true | let ccell_is_lvalue_refine (a: Type) (c: ccell_ptrvalue a) : Tot prop =
| ccell_ptrvalue_is_null c == false | false |
CQueue.fst | CQueue.vpure_sel | val vpure_sel (p: prop) : Tot (selector (squash p) (Steel.Memory.pure p)) | val vpure_sel (p: prop) : Tot (selector (squash p) (Steel.Memory.pure p)) | let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 14,
"end_line": 92,
"start_col": 0,
"start_line": 89
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Prims.prop -> Steel.Effect.Common.selector (CQueue.squash p) (Steel.Memory.pure p) | Prims.Tot | [
"total"
] | [] | [
"Prims.prop",
"CQueue.vpure_sel'",
"Steel.Effect.Common.selector",
"CQueue.squash",
"Steel.Memory.pure"
] | [] | false | false | false | false | false | let vpure_sel (p: prop) : Tot (selector (squash p) (Steel.Memory.pure p)) =
| vpure_sel' p | false |
CQueue.fst | CQueue.vbind0_rewrite | val vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t | val vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t | let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x) | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 14,
"end_line": 175,
"start_col": 0,
"start_line": 169
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Steel.Effect.Common.vprop ->
t: Type0 ->
b: (_: Steel.Effect.Common.t_of a -> Steel.Effect.Common.vprop) ->
x:
Steel.Effect.Common.normal (Steel.Effect.Common.t_of (Steel.Effect.Common.vdep a
(CQueue.vbind0_payload a t b)))
-> t | Prims.Tot | [
"total"
] | [] | [
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.t_of",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.vdep",
"CQueue.vbind0_payload",
"FStar.Pervasives.Native.snd",
"CQueue.vpure",
"Prims.eq2",
"Prims.__proj__Mkdtuple2__item___1",
"Steel.Effect.Common.vdep_payload",
"FStar.Pervasives.dsnd"
] | [] | false | false | false | false | false | let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t =
| snd (dsnd x) | false |
CQueue.fst | CQueue.vpure_sel' | val vpure_sel' (p: prop) : Tot (selector' (squash p) (Steel.Memory.pure p)) | val vpure_sel' (p: prop) : Tot (selector' (squash p) (Steel.Memory.pure p)) | let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 69,
"end_line": 87,
"start_col": 0,
"start_line": 84
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ()) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Prims.prop -> Steel.Effect.Common.selector' (CQueue.squash p) (Steel.Memory.pure p) | Prims.Tot | [
"total"
] | [] | [
"Prims.prop",
"Steel.Memory.hmem",
"Steel.Memory.pure",
"Steel.Memory.pure_interp",
"CQueue.squash",
"Steel.Effect.Common.selector'"
] | [] | false | false | false | false | false | let vpure_sel' (p: prop) : Tot (selector' (squash p) (Steel.Memory.pure p)) =
| fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m | false |
Vale.Test.X64.Args.fst | Vale.Test.X64.Args.va_wpProof_Test | val va_wpProof_Test : win:bool -> arg0:buffer64 -> arg1:buffer64 -> arg2:buffer64 -> arg3:buffer64
-> arg4:buffer64 -> arg5:buffer64 -> arg6:buffer64 -> arg7:buffer64 -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Test win arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 va_s0
va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Test win) ([va_Mod_mem_layout;
va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12;
va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11;
va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp; va_Mod_reg64 rRbp;
va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | val va_wpProof_Test : win:bool -> arg0:buffer64 -> arg1:buffer64 -> arg2:buffer64 -> arg3:buffer64
-> arg4:buffer64 -> arg5:buffer64 -> arg6:buffer64 -> arg7:buffer64 -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Test win arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 va_s0
va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Test win) ([va_Mod_mem_layout;
va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12;
va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11;
va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp; va_Mod_reg64 rRbp;
va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | let va_wpProof_Test win arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Test (va_code_Test win) va_s0 win arg0 arg1 arg2 arg3 arg4 arg5
arg6 arg7 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 0 va_sM
(va_update_flags va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM
(va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM
(va_update_xmm 8 va_sM (va_update_xmm 7 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_xmm 1 va_sM
(va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64
rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRsp va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRsi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_xmm 15;
va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13;
va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8;
va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx;
va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"file_name": "obj/Vale.Test.X64.Args.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 135,
"start_col": 0,
"start_line": 111
} | module Vale.Test.X64.Args
open Vale.Arch.HeapImpl
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
#set-options "--z3rlimit 20"
//-- Test
[@ "opaque_to_smt" va_qattr]
let va_code_Test win =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64
rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_DestroyHeaplets ()) (va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Test win =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Test (va_mods:va_mods_t) (win:bool) (arg0:buffer64) (arg1:buffer64) (arg2:buffer64)
(arg3:buffer64) (arg4:buffer64) (arg5:buffer64) (arg6:buffer64) (arg7:buffer64) : (va_quickCode
unit (va_code_Test win)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer64 arg0 0 Secret Immutable; declare_buffer64 arg1 0
Secret Immutable; declare_buffer64 arg2 0 Secret Immutable; declare_buffer64 arg3 0 Secret
Immutable; declare_buffer64 arg4 0 Secret Immutable; declare_buffer64 arg5 0 Secret Immutable;
declare_buffer64 arg6 0 Secret Immutable; declare_buffer64 arg7 0 Secret Immutable])) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 89 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 91 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))
[@"opaque_to_smt"]
let va_lemma_Test va_b0 va_s0 win arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 =
let (va_mods:va_mods_t) = [va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_xmm 15;
va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13;
va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8;
va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx;
va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Test va_mods win arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Test win) va_qc va_s0 (fun va_s0 va_sM
va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 21 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 58 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 59 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 60 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 61 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 63 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 64 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 65 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 66 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 67 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 69 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 71 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 10 va_sM == va_get_xmm 10 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 72 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 73 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 74 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 13 va_sM == va_get_xmm 13 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 75 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 76 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 15 va_sM == va_get_xmm 15 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(Vale.X64.Decls.modifies_mem loc_none (va_get_mem va_s0) (va_get_mem va_sM))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_xmm 15;
va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13;
va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8;
va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx;
va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.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.Decls.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Test.X64.Args.fst"
} | [
{
"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.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.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Test.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Test.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
win: Prims.bool ->
arg0: Vale.X64.Memory.buffer64 ->
arg1: Vale.X64.Memory.buffer64 ->
arg2: Vale.X64.Memory.buffer64 ->
arg3: Vale.X64.Memory.buffer64 ->
arg4: Vale.X64.Memory.buffer64 ->
arg5: Vale.X64.Memory.buffer64 ->
arg6: Vale.X64.Memory.buffer64 ->
arg7: Vale.X64.Memory.buffer64 ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | Prims.Ghost | [] | [] | [
"Prims.bool",
"Vale.X64.Memory.buffer64",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_mem_layout",
"Vale.X64.QuickCode.va_Mod_mem_heaplet",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_Mod_xmm",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rR15",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rR10",
"Vale.X64.Machine_s.rR9",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Machine_s.rRsp",
"Vale.X64.Machine_s.rRbp",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRax",
"Vale.X64.QuickCode.va_Mod_mem",
"Prims.Nil",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_mem_layout",
"Vale.X64.Decls.va_update_mem_heaplet",
"Vale.X64.Decls.va_update_flags",
"Vale.X64.Decls.va_update_xmm",
"Vale.X64.Decls.va_update_reg64",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_update_mem",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.Test.X64.Args.va_lemma_Test",
"Vale.Test.X64.Args.va_code_Test"
] | [] | false | false | false | false | false | let va_wpProof_Test win arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 va_s0 va_k =
| let va_sM, va_f0 =
va_lemma_Test (va_code_Test win) va_s0 win arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM
(va_update_mem_layout va_sM
(va_update_mem_heaplet 0
va_sM
(va_update_flags va_sM
(va_update_xmm 15
va_sM
(va_update_xmm 14
va_sM
(va_update_xmm 13
va_sM
(va_update_xmm 12
va_sM
(va_update_xmm 11
va_sM
(va_update_xmm 10
va_sM
(va_update_xmm 9
va_sM
(va_update_xmm 8
va_sM
(va_update_xmm 7
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_xmm 1
va_sM
(va_update_xmm 0
va_sM
(va_update_reg64 rR15
va_sM
(va_update_reg64
rR14
va_sM
(va_update_reg64
rR13
va_sM
(va_update_reg64
rR12
va_sM
(va_update_reg64
rR11
va_sM
(
va_update_reg64
rR10
va_sM
(
va_update_reg64
rR9
va_sM
(
va_update_reg64
rR8
va_sM
(
va_update_reg64
rRsp
va_sM
(
va_update_reg64
rRbp
va_sM
(
va_update_reg64
rRdi
va_sM
(
va_update_reg64
rRsi
va_sM
(
va_update_reg64
rRdx
va_sM
(
va_update_reg64
rRcx
va_sM
(
va_update_reg64
rRbx
va_sM
(
va_update_reg64
rRax
va_sM
(
va_update_ok
va_sM
(
va_update_mem
va_sM
va_s0
)
)
)
)
)
)
)
)
)
)
)
)
)
))
))))))))))
)))))))))))));
va_lemma_norm_mods ([
va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13;
va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8;
va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx;
va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem
])
va_sM
va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | false |
CQueue.fst | CQueue.queue_tail_refine | val queue_tail_refine
(#a: Type)
(tail1 tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop | val queue_tail_refine
(#a: Type)
(tail1 tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop | let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2 | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 53,
"end_line": 637,
"start_col": 0,
"start_line": 631
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
tail1: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) ->
tail2: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) ->
tl: Steel.Effect.Common.normal (Steel.Effect.Common.t_of (Steel.Reference.vptr tail2))
-> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"Steel.Reference.ref",
"CQueue.Cell.ccell_ptrvalue",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.t_of",
"Steel.Reference.vptr",
"Prims.l_and",
"CQueue.op_Equals_Equals",
"Prims.bool",
"CQueue.Cell.ccell_ptrvalue_is_null",
"Prims.prop"
] | [] | false | false | false | false | true | let queue_tail_refine
(#a: Type)
(tail1 tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop =
| ccell_ptrvalue_is_null tl == true /\ tail1 == tail2 | false |
CQueue.fst | CQueue.vconst_sel | val vconst_sel (#a: Type) (x: a) : Tot (selector a (hp_of emp)) | val vconst_sel (#a: Type) (x: a) : Tot (selector a (hp_of emp)) | let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 12,
"end_line": 36,
"start_col": 0,
"start_line": 32
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: a -> Steel.Effect.Common.selector a (Steel.Effect.Common.hp_of Steel.Effect.Common.emp) | Prims.Tot | [
"total"
] | [] | [
"Steel.Memory.hmem",
"Steel.Effect.Common.hp_of",
"Steel.Effect.Common.emp",
"Steel.Effect.Common.selector"
] | [] | false | false | false | true | false | let vconst_sel (#a: Type) (x: a) : Tot (selector a (hp_of emp)) =
| fun _ -> x | false |
Vale.X64.InsSha.fst | Vale.X64.InsSha.va_lemma_SHA256_msg1 | val va_lemma_SHA256_msg1 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_msg1 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <= t && t < size_k_w_256))
/\ va_eval_xmm va_s0 dst == ws_quad32 (t - 16) block /\ (va_eval_xmm va_s0 src).lo0 ==
ws_opaque block (t - 12)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == ws_partial t block /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))) | val va_lemma_SHA256_msg1 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_msg1 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <= t && t < size_k_w_256))
/\ va_eval_xmm va_s0 dst == ws_quad32 (t - 16) block /\ (va_eval_xmm va_s0 src).lo0 ==
ws_opaque block (t - 12)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == ws_partial t block /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))) | let va_lemma_SHA256_msg1 va_b0 va_s0 dst src t block =
va_reveal_opaque (`%va_code_SHA256_msg1) (va_code_SHA256_msg1 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src)))
va_s0 in
lemma_sha256_msg1 (va_eval_xmm va_old_s dst) (va_eval_xmm va_old_s src) t block;
(va_sM, va_fM) | {
"file_name": "obj/Vale.X64.InsSha.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 71,
"start_col": 0,
"start_line": 64
} | module Vale.X64.InsSha
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.Decls
open Vale.X64.CryptoInstructions_s
open Spec.Hash.Definitions
open Spec.SHA2
open Vale.X64.CPU_Features_s
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
module P = Vale.X64.Print_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 2 --z3rlimit 20"
//-- SHA256_rnds2
[@ "opaque_to_smt"]
let va_code_SHA256_rnds2 dst src =
(mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src)))
[@ "opaque_to_smt"]
let va_codegen_success_SHA256_rnds2 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SHA256_rnds2 va_b0 va_s0 dst src t block hash_orig =
va_reveal_opaque (`%va_code_SHA256_rnds2) (va_code_SHA256_rnds2 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src)))
va_s0 in
lemma_sha256_rnds2 (va_eval_xmm va_old_s src) (va_eval_xmm va_old_s dst) (va_get_xmm 0 va_old_s)
t block hash_orig;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SHA256_rnds2 dst src t block hash_orig va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SHA256_rnds2 (va_code_SHA256_rnds2 dst src) va_s0 dst src t block
hash_orig in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_xmm dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- SHA256_msg1
[@ "opaque_to_smt"]
let va_code_SHA256_msg1 dst src =
(mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src)))
[@ "opaque_to_smt"]
let va_codegen_success_SHA256_msg1 dst src =
(va_ttrue ()) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsSha.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Print_s",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 4,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_b0: Vale.X64.Decls.va_code ->
va_s0: Vale.X64.Decls.va_state ->
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_operand_xmm",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Prims.unit",
"Vale.SHA.SHA_helpers.lemma_sha256_msg1",
"Vale.X64.Decls.va_eval_xmm",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.opXmm",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_SHA256_msg1",
"Vale.X64.Machine_s.OReg",
"Vale.X64.Machine_s.quad32",
"Vale.X64.Machine_s.reg_xmm",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsSha.va_code_SHA256_msg1"
] | [] | false | false | false | false | false | let va_lemma_SHA256_msg1 va_b0 va_s0 dst src t block =
| va_reveal_opaque (`%va_code_SHA256_msg1) (va_code_SHA256_msg1 dst src);
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src))) va_s0;
let va_sM, va_fM =
va_eval_ins (mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src))) va_s0
in
lemma_sha256_msg1 (va_eval_xmm va_old_s dst) (va_eval_xmm va_old_s src) t block;
(va_sM, va_fM) | false |
CQueue.fst | CQueue.queue_tail | val queue_tail (#a: Type) (x: t a) (l: Ghost.erased (list a)) : Tot vprop | val queue_tail (#a: Type) (x: t a) (l: Ghost.erased (list a)) : Tot vprop | let queue_tail
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
=
llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 66,
"end_line": 665,
"start_col": 0,
"start_line": 659
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end
let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2
[@@__steel_reduce__]
let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop
= vptr tail2 `vrefine` queue_tail_refine tail1 tail2
[@@__steel_reduce__]
let queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop
= vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1 | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: CQueue.t a -> l: FStar.Ghost.erased (Prims.list a) -> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"CQueue.t",
"FStar.Ghost.erased",
"Prims.list",
"Steel.Effect.Common.vdep",
"CQueue.llist_fragment_tail",
"CQueue.LList.cllist_head",
"CQueue.queue_tail_dep1",
"Steel.Effect.Common.vprop"
] | [] | false | false | false | true | false | let queue_tail (#a: Type) (x: t a) (l: Ghost.erased (list a)) : Tot vprop =
| (llist_fragment_tail l (cllist_head x)) `vdep` (queue_tail_dep1 x l) | false |
CQueue.fst | CQueue.queue_tail_dep1 | val queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop | val queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop | let queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop
= vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1 | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 55,
"end_line": 656,
"start_col": 0,
"start_line": 650
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end
let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2
[@@__steel_reduce__]
let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop
= vptr tail2 `vrefine` queue_tail_refine tail1 tail2 | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
x: CQueue.t a ->
l: FStar.Ghost.erased (Prims.list a) ->
tail1: Steel.Effect.Common.t_of (CQueue.llist_fragment_tail l (CQueue.LList.cllist_head x))
-> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"CQueue.t",
"FStar.Ghost.erased",
"Prims.list",
"Steel.Effect.Common.t_of",
"CQueue.llist_fragment_tail",
"CQueue.LList.cllist_head",
"Steel.Effect.Common.vdep",
"Steel.Reference.vptr",
"Steel.Reference.ref",
"CQueue.Cell.ccell_ptrvalue",
"CQueue.LList.cllist_tail",
"CQueue.queue_tail_dep2",
"Steel.Effect.Common.vprop"
] | [] | false | false | false | false | false | let queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop =
| (vptr (cllist_tail x)) `vdep` (queue_tail_dep2 x l tail1) | false |
Vale.X64.InsSha.fst | Vale.X64.InsSha.va_lemma_SHA256_msg2 | val va_lemma_SHA256_msg2 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_msg2 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <= t && t < size_k_w_256 -
3)) /\ (let step1 = ws_partial t block in let t_minus_7 = ws_quad32 (t - 7) block in
va_eval_xmm va_s0 dst == add_wrap_quad32 step1 t_minus_7) /\ (va_eval_xmm va_s0 src).hi2 ==
ws_opaque block (t - 2) /\ (va_eval_xmm va_s0 src).hi3 == ws_opaque block (t - 1)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == ws_quad32 t block /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))) | val va_lemma_SHA256_msg2 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_msg2 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <= t && t < size_k_w_256 -
3)) /\ (let step1 = ws_partial t block in let t_minus_7 = ws_quad32 (t - 7) block in
va_eval_xmm va_s0 dst == add_wrap_quad32 step1 t_minus_7) /\ (va_eval_xmm va_s0 src).hi2 ==
ws_opaque block (t - 2) /\ (va_eval_xmm va_s0 src).hi3 == ws_opaque block (t - 1)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == ws_quad32 t block /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))) | let va_lemma_SHA256_msg2 va_b0 va_s0 dst src t block =
va_reveal_opaque (`%va_code_SHA256_msg2) (va_code_SHA256_msg2 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_msg2) (OReg dst) (OReg src))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_SHA256_msg2) (OReg dst) (OReg src)))
va_s0 in
lemma_sha256_msg2 (va_eval_xmm va_old_s dst) (va_eval_xmm va_old_s src) t block;
(va_sM, va_fM) | {
"file_name": "obj/Vale.X64.InsSha.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 102,
"start_col": 0,
"start_line": 95
} | module Vale.X64.InsSha
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.Decls
open Vale.X64.CryptoInstructions_s
open Spec.Hash.Definitions
open Spec.SHA2
open Vale.X64.CPU_Features_s
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
module P = Vale.X64.Print_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 2 --z3rlimit 20"
//-- SHA256_rnds2
[@ "opaque_to_smt"]
let va_code_SHA256_rnds2 dst src =
(mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src)))
[@ "opaque_to_smt"]
let va_codegen_success_SHA256_rnds2 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SHA256_rnds2 va_b0 va_s0 dst src t block hash_orig =
va_reveal_opaque (`%va_code_SHA256_rnds2) (va_code_SHA256_rnds2 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src)))
va_s0 in
lemma_sha256_rnds2 (va_eval_xmm va_old_s src) (va_eval_xmm va_old_s dst) (va_get_xmm 0 va_old_s)
t block hash_orig;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SHA256_rnds2 dst src t block hash_orig va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SHA256_rnds2 (va_code_SHA256_rnds2 dst src) va_s0 dst src t block
hash_orig in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_xmm dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- SHA256_msg1
[@ "opaque_to_smt"]
let va_code_SHA256_msg1 dst src =
(mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src)))
[@ "opaque_to_smt"]
let va_codegen_success_SHA256_msg1 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SHA256_msg1 va_b0 va_s0 dst src t block =
va_reveal_opaque (`%va_code_SHA256_msg1) (va_code_SHA256_msg1 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_SHA256_msg1) (OReg dst) (OReg src)))
va_s0 in
lemma_sha256_msg1 (va_eval_xmm va_old_s dst) (va_eval_xmm va_old_s src) t block;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SHA256_msg1 dst src t block va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SHA256_msg1 (va_code_SHA256_msg1 dst src) va_s0 dst src t block in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_xmm dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- SHA256_msg2
[@ "opaque_to_smt"]
let va_code_SHA256_msg2 dst src =
(mk_ins (make_instr (I.ins_SHA256_msg2) (OReg dst) (OReg src)))
[@ "opaque_to_smt"]
let va_codegen_success_SHA256_msg2 dst src =
(va_ttrue ()) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsSha.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Print_s",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 4,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_b0: Vale.X64.Decls.va_code ->
va_s0: Vale.X64.Decls.va_state ->
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_operand_xmm",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Prims.unit",
"Vale.SHA.SHA_helpers.lemma_sha256_msg2",
"Vale.X64.Decls.va_eval_xmm",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.opXmm",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_SHA256_msg2",
"Vale.X64.Machine_s.OReg",
"Vale.X64.Machine_s.quad32",
"Vale.X64.Machine_s.reg_xmm",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsSha.va_code_SHA256_msg2"
] | [] | false | false | false | false | false | let va_lemma_SHA256_msg2 va_b0 va_s0 dst src t block =
| va_reveal_opaque (`%va_code_SHA256_msg2) (va_code_SHA256_msg2 dst src);
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_msg2) (OReg dst) (OReg src))) va_s0;
let va_sM, va_fM =
va_eval_ins (mk_ins (make_instr (I.ins_SHA256_msg2) (OReg dst) (OReg src))) va_s0
in
lemma_sha256_msg2 (va_eval_xmm va_old_s dst) (va_eval_xmm va_old_s src) t block;
(va_sM, va_fM) | false |
CQueue.fst | CQueue.llist_fragment_head_data_refine | val llist_fragment_head_data_refine (#a: Type) (d: a) (c: vcell a) : Tot prop | val llist_fragment_head_data_refine (#a: Type) (d: a) (c: vcell a) : Tot prop | let llist_fragment_head_data_refine
(#a: Type)
(d: a)
(c: vcell a)
: Tot prop
= c.vcell_data == d | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 19,
"end_line": 746,
"start_col": 0,
"start_line": 741
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end
let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2
[@@__steel_reduce__]
let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop
= vptr tail2 `vrefine` queue_tail_refine tail1 tail2
[@@__steel_reduce__]
let queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop
= vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1
[@@__steel_reduce__; __reduce__]
let queue_tail
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
=
llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l
val intro_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun _ -> queue_tail x l)
(fun h ->
sel_llist_fragment_tail l (cllist_head x) h == tail /\
sel (cllist_tail x) h == tail /\
ccell_ptrvalue_is_null (sel tail h)
)
(fun _ _ _ -> True)
let intro_queue_tail
x l tail
=
intro_vrefine (vptr tail) (queue_tail_refine tail tail);
intro_vdep2
(vptr (cllist_tail x))
(vptr tail `vrefine` queue_tail_refine tail tail)
tail
(queue_tail_dep2 x l tail);
intro_vdep2
(llist_fragment_tail l (cllist_head x))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail)
tail
(queue_tail_dep1 x l)
val elim_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(queue_tail x l)
(fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun h -> True)
(fun _ tail h ->
sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\
sel (cllist_tail x) h == Ghost.reveal tail /\
ccell_ptrvalue_is_null (h (vptr tail))
)
let elim_queue_tail
#_ #a x l
=
let tail0 = elim_vdep
(llist_fragment_tail l (cllist_head x))
(queue_tail_dep1 x l)
in
let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in
change_equal_slprop
(queue_tail_dep1 x l (Ghost.reveal tail0))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0);
let tail2 = elim_vdep
(vptr (cllist_tail x))
(queue_tail_dep2 x l tail0)
in
let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in
change_equal_slprop
(queue_tail_dep2 x l tail0 (Ghost.reveal tail2))
(vptr tail3 `vrefine` queue_tail_refine tail0 tail3);
elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3);
change_equal_slprop
(vptr tail3)
(vptr tail);
tail
(* view from the head *) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | d: a -> c: CQueue.Cell.vcell a -> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"CQueue.Cell.vcell",
"CQueue.op_Equals_Equals",
"CQueue.Cell.__proj__Mkvcell__item__vcell_data",
"Prims.prop"
] | [] | false | false | false | true | true | let llist_fragment_head_data_refine (#a: Type) (d: a) (c: vcell a) : Tot prop =
| c.vcell_data == d | false |
Vale.X64.InsSha.fst | Vale.X64.InsSha.va_lemma_SHA256_rnds2 | val va_lemma_SHA256_rnds2 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w -> hash_orig:hash256
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_rnds2 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ t + 1 < size_k_w_256 /\
(va_get_xmm 0 va_s0).lo0 == add_wrap (word_to_nat32 (index k t)) (ws_opaque block t) /\
(va_get_xmm 0 va_s0).lo1 == add_wrap (word_to_nat32 (index k (t + 1))) (ws_opaque block (t +
1)) /\ make_hash (va_eval_xmm va_s0 src) (va_eval_xmm va_s0 dst) == repeat_range 0 t
(shuffle_core_opaque block) hash_orig))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
make_hash (va_eval_xmm va_sM dst) (va_eval_xmm va_s0 src) == repeat_range 0 (t + 2)
(shuffle_core_opaque block) hash_orig /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))) | val va_lemma_SHA256_rnds2 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w -> hash_orig:hash256
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_rnds2 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ t + 1 < size_k_w_256 /\
(va_get_xmm 0 va_s0).lo0 == add_wrap (word_to_nat32 (index k t)) (ws_opaque block t) /\
(va_get_xmm 0 va_s0).lo1 == add_wrap (word_to_nat32 (index k (t + 1))) (ws_opaque block (t +
1)) /\ make_hash (va_eval_xmm va_s0 src) (va_eval_xmm va_s0 dst) == repeat_range 0 t
(shuffle_core_opaque block) hash_orig))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
make_hash (va_eval_xmm va_sM dst) (va_eval_xmm va_s0 src) == repeat_range 0 (t + 2)
(shuffle_core_opaque block) hash_orig /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))) | let va_lemma_SHA256_rnds2 va_b0 va_s0 dst src t block hash_orig =
va_reveal_opaque (`%va_code_SHA256_rnds2) (va_code_SHA256_rnds2 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src)))
va_s0 in
lemma_sha256_rnds2 (va_eval_xmm va_old_s src) (va_eval_xmm va_old_s dst) (va_get_xmm 0 va_old_s)
t block hash_orig;
(va_sM, va_fM) | {
"file_name": "obj/Vale.X64.InsSha.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 39,
"start_col": 0,
"start_line": 31
} | module Vale.X64.InsSha
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.Decls
open Vale.X64.CryptoInstructions_s
open Spec.Hash.Definitions
open Spec.SHA2
open Vale.X64.CPU_Features_s
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
module P = Vale.X64.Print_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 2 --z3rlimit 20"
//-- SHA256_rnds2
[@ "opaque_to_smt"]
let va_code_SHA256_rnds2 dst src =
(mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src)))
[@ "opaque_to_smt"]
let va_codegen_success_SHA256_rnds2 dst src =
(va_ttrue ()) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Spec.SHA2.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsSha.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Print_s",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 4,
"initial_ifuel": 0,
"max_fuel": 4,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_b0: Vale.X64.Decls.va_code ->
va_s0: Vale.X64.Decls.va_state ->
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w ->
hash_orig: Vale.SHA.SHA_helpers.hash256
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_operand_xmm",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.hash256",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Prims.unit",
"Vale.SHA.SHA_helpers.lemma_sha256_rnds2",
"Vale.X64.Decls.va_eval_xmm",
"Vale.X64.Decls.va_get_xmm",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.opXmm",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.oneXmm",
"Vale.X64.Machine_s.OReg",
"Vale.X64.Machine_s.quad32",
"Vale.X64.Machine_s.reg_xmm",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_SHA256_rnds2",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsSha.va_code_SHA256_rnds2"
] | [] | false | false | false | false | false | let va_lemma_SHA256_rnds2 va_b0 va_s0 dst src t block hash_orig =
| va_reveal_opaque (`%va_code_SHA256_rnds2) (va_code_SHA256_rnds2 dst src);
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src))) va_s0;
let va_sM, va_fM =
va_eval_ins (mk_ins (make_instr (I.ins_SHA256_rnds2) (OReg dst) (OReg src))) va_s0
in
lemma_sha256_rnds2 (va_eval_xmm va_old_s src)
(va_eval_xmm va_old_s dst)
(va_get_xmm 0 va_old_s)
t
block
hash_orig;
(va_sM, va_fM) | false |
CQueue.fst | CQueue.unsnoc_tl | val unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) | val unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) | let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l) | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 111,
"end_line": 299,
"start_col": 0,
"start_line": 299
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' < | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: Prims.list a -> Prims.Pure a | Prims.Pure | [] | [] | [
"Prims.list",
"FStar.Pervasives.Native.snd",
"CQueue.unsnoc",
"Prims.b2t",
"Prims.uu___is_Cons",
"Prims.l_True"
] | [] | false | false | false | false | false | let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) =
| snd (unsnoc l) | false |
Vale.Test.X64.Args.fst | Vale.Test.X64.Args.va_lemma_Test | val va_lemma_Test : va_b0:va_code -> va_s0:va_state -> win:bool -> arg0:buffer64 -> arg1:buffer64
-> arg2:buffer64 -> arg3:buffer64 -> arg4:buffer64 -> arg5:buffer64 -> arg6:buffer64 ->
arg7:buffer64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Test win) va_s0 /\ va_get_ok va_s0 /\ va_get_reg64
rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Memory.is_initial_heap
(va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (win ==> Vale.X64.Stack_i.valid_src_stack64
(va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0)) /\ (win ==>
Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0))
/\ (win ==> Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 16)
(va_get_stack va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 24) (va_get_stack va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_src_stack64
(va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) /\ (~win ==>
Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) /\
Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win then va_get_reg64 rRcx va_s0 else
va_get_reg64 rRdi va_s0) arg0 0 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win then va_get_reg64 rRdx va_s0 else
va_get_reg64 rRsi va_s0) arg1 0 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) arg2 0 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win then va_get_reg64 rR9 va_s0 else
va_get_reg64 rRcx va_s0) arg3 0 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) arg4 0
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0)
else va_get_reg64 rR9 va_s0) arg5 0 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 32 + 8 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) arg6 0 (va_get_mem_layout va_s0) Secret
/\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 32 + 8 + 24) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) arg7 0 (va_get_mem_layout va_s0)
Secret))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\ va_get_reg64 rRbx va_sM == va_get_reg64
rRbx va_s0 /\ va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0 /\ va_get_reg64 rR12 va_sM ==
va_get_reg64 rR12 va_s0 /\ va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0 /\ va_get_reg64
rR14 va_sM == va_get_reg64 rR14 va_s0 /\ va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0 /\
(win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ (win ==> va_get_reg64 rRsi
va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\ (win
==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm 8
va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM ==
va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==>
va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13
va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM
== va_get_xmm 15 va_s0) /\ Vale.X64.Decls.modifies_mem loc_none (va_get_mem va_s0) (va_get_mem
va_sM) /\ va_state_eq va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 0 va_sM
(va_update_flags va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM
(va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM
(va_update_xmm 8 va_sM (va_update_xmm 7 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_xmm 1 va_sM
(va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64
rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRsp va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRsi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))) | val va_lemma_Test : va_b0:va_code -> va_s0:va_state -> win:bool -> arg0:buffer64 -> arg1:buffer64
-> arg2:buffer64 -> arg3:buffer64 -> arg4:buffer64 -> arg5:buffer64 -> arg6:buffer64 ->
arg7:buffer64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Test win) va_s0 /\ va_get_ok va_s0 /\ va_get_reg64
rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Memory.is_initial_heap
(va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (win ==> Vale.X64.Stack_i.valid_src_stack64
(va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0)) /\ (win ==>
Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0))
/\ (win ==> Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 16)
(va_get_stack va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 24) (va_get_stack va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_src_stack64
(va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) /\ (~win ==>
Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) /\
Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win then va_get_reg64 rRcx va_s0 else
va_get_reg64 rRdi va_s0) arg0 0 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win then va_get_reg64 rRdx va_s0 else
va_get_reg64 rRsi va_s0) arg1 0 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) arg2 0 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win then va_get_reg64 rR9 va_s0 else
va_get_reg64 rRcx va_s0) arg3 0 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) arg4 0
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0)
else va_get_reg64 rR9 va_s0) arg5 0 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 32 + 8 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) arg6 0 (va_get_mem_layout va_s0) Secret
/\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem va_s0) (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 32 + 8 + 24) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) arg7 0 (va_get_mem_layout va_s0)
Secret))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\ va_get_reg64 rRbx va_sM == va_get_reg64
rRbx va_s0 /\ va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0 /\ va_get_reg64 rR12 va_sM ==
va_get_reg64 rR12 va_s0 /\ va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0 /\ va_get_reg64
rR14 va_sM == va_get_reg64 rR14 va_s0 /\ va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0 /\
(win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ (win ==> va_get_reg64 rRsi
va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\ (win
==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm 8
va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM ==
va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==>
va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13
va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM
== va_get_xmm 15 va_s0) /\ Vale.X64.Decls.modifies_mem loc_none (va_get_mem va_s0) (va_get_mem
va_sM) /\ va_state_eq va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 0 va_sM
(va_update_flags va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM
(va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM
(va_update_xmm 8 va_sM (va_update_xmm 7 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_xmm 1 va_sM
(va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64
rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRsp va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRsi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))) | let va_lemma_Test va_b0 va_s0 win arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 =
let (va_mods:va_mods_t) = [va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_xmm 15;
va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13;
va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8;
va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx;
va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Test va_mods win arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Test win) va_qc va_s0 (fun va_s0 va_sM
va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 21 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 58 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 59 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 60 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 61 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 63 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 64 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 65 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 66 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 67 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 69 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 71 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 10 va_sM == va_get_xmm 10 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 72 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 73 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 74 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 13 va_sM == va_get_xmm 13 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 75 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 76 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 15 va_sM == va_get_xmm 15 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(Vale.X64.Decls.modifies_mem loc_none (va_get_mem va_s0) (va_get_mem va_sM))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_xmm 15;
va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13;
va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8;
va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx;
va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM) | {
"file_name": "obj/Vale.Test.X64.Args.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 107,
"start_col": 0,
"start_line": 46
} | module Vale.Test.X64.Args
open Vale.Arch.HeapImpl
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
#set-options "--z3rlimit 20"
//-- Test
[@ "opaque_to_smt" va_qattr]
let va_code_Test win =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64
rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_DestroyHeaplets ()) (va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Test win =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Test (va_mods:va_mods_t) (win:bool) (arg0:buffer64) (arg1:buffer64) (arg2:buffer64)
(arg3:buffer64) (arg4:buffer64) (arg5:buffer64) (arg6:buffer64) (arg7:buffer64) : (va_quickCode
unit (va_code_Test win)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer64 arg0 0 Secret Immutable; declare_buffer64 arg1 0
Secret Immutable; declare_buffer64 arg2 0 Secret Immutable; declare_buffer64 arg3 0 Secret
Immutable; declare_buffer64 arg4 0 Secret Immutable; declare_buffer64 arg5 0 Secret Immutable;
declare_buffer64 arg6 0 Secret Immutable; declare_buffer64 arg7 0 Secret Immutable])) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 89 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 91 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (())))))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.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.Decls.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Test.X64.Args.fst"
} | [
{
"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.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.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Test.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Test.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_b0: Vale.X64.Decls.va_code ->
va_s0: Vale.X64.Decls.va_state ->
win: Prims.bool ->
arg0: Vale.X64.Memory.buffer64 ->
arg1: Vale.X64.Memory.buffer64 ->
arg2: Vale.X64.Memory.buffer64 ->
arg3: Vale.X64.Memory.buffer64 ->
arg4: Vale.X64.Memory.buffer64 ->
arg5: Vale.X64.Memory.buffer64 ->
arg6: Vale.X64.Memory.buffer64 ->
arg7: Vale.X64.Memory.buffer64
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Prims.bool",
"Vale.X64.Memory.buffer64",
"Vale.X64.QuickCodes.fuel",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_mem_layout",
"Vale.X64.QuickCode.va_Mod_mem_heaplet",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_Mod_xmm",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rR15",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rR10",
"Vale.X64.Machine_s.rR9",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Machine_s.rRsp",
"Vale.X64.Machine_s.rRbp",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRax",
"Vale.X64.QuickCode.va_Mod_ok",
"Vale.X64.QuickCode.va_Mod_mem",
"Prims.Nil",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.list",
"Vale.X64.QuickCode.__proj__QProc__item__mods",
"Vale.Test.X64.Args.va_code_Test",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple3",
"Vale.X64.State.vale_state",
"Vale.X64.QuickCodes.va_wp_sound_code_norm",
"Prims.l_and",
"Vale.X64.QuickCodes.label",
"Vale.X64.QuickCodes.va_range1",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.Def.Types_s.nat64",
"Vale.X64.Decls.va_get_reg64",
"Prims.l_imp",
"Vale.X64.Decls.quad32",
"Vale.X64.Decls.va_get_xmm",
"Vale.X64.Decls.modifies_mem",
"Vale.X64.Memory.loc_none",
"Vale.X64.Decls.va_get_mem",
"Vale.X64.QuickCode.quickCode",
"Vale.Test.X64.Args.va_qcode_Test"
] | [] | false | false | false | false | false | let va_lemma_Test va_b0 va_s0 win arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 =
| let va_mods:va_mods_t =
[
va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp;
va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx;
va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem
]
in
let va_qc = va_qcode_Test va_mods win arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 in
let va_sM, va_fM, va_g =
va_wp_sound_code_norm (va_code_Test win)
va_qc
va_s0
(fun va_s0 va_sM va_g ->
let () = va_g in
label va_range1
"***** POSTCONDITION NOT MET AT line 21 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_ok va_sM) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 58 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 59 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 60 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 61 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 63 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 64 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 65 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 66 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 67 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 69 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 71 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 10 va_sM == va_get_xmm 10 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 72 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 73 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 74 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 13 va_sM == va_get_xmm 13 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 75 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 76 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(win ==> va_get_xmm 15 va_sM == va_get_xmm 15 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 77 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Args.vaf *****"
(Vale.X64.Decls.modifies_mem loc_none (va_get_mem va_s0) (va_get_mem va_sM)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([
va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13;
va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8;
va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx;
va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem
])
va_sM
va_s0;
(va_sM, va_fM) | false |
CQueue.fst | CQueue.unsnoc_hd | val unsnoc_hd (#a: Type) (l: list a)
: Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' < L.length l)) | val unsnoc_hd (#a: Type) (l: list a)
: Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' < L.length l)) | let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l) | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 29,
"end_line": 298,
"start_col": 0,
"start_line": 297
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: Prims.list a -> Prims.Pure (Prims.list a) | Prims.Pure | [] | [] | [
"Prims.list",
"FStar.Pervasives.Native.fst",
"CQueue.unsnoc",
"Prims.b2t",
"Prims.uu___is_Cons",
"Prims.op_LessThan",
"FStar.List.Tot.Base.length"
] | [] | false | false | false | false | false | let unsnoc_hd (#a: Type) (l: list a)
: Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' < L.length l)) =
| fst (unsnoc l) | false |
CQueue.fst | CQueue.coerce | val coerce (#a: Type) (x: a) (b: Type)
: Pure b (requires (a == b)) (ensures (fun y -> a == b /\ x == y)) | val coerce (#a: Type) (x: a) (b: Type)
: Pure b (requires (a == b)) (ensures (fun y -> a == b /\ x == y)) | let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 3,
"end_line": 331,
"start_col": 0,
"start_line": 324
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= () | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: a -> b: Type -> Prims.Pure b | Prims.Pure | [] | [] | [
"CQueue.op_Equals_Equals",
"Prims.l_and"
] | [] | false | false | false | false | false | let coerce (#a: Type) (x: a) (b: Type)
: Pure b (requires (a == b)) (ensures (fun y -> a == b /\ x == y)) =
| x | false |
CQueue.fst | CQueue.snoc_inj | val snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a)
: Lemma (requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])] | val snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a)
: Lemma (requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])] | let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2) | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 32,
"end_line": 286,
"start_col": 0,
"start_line": 281
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | hd1: Prims.list a -> hd2: Prims.list a -> tl1: a -> tl2: a
-> FStar.Pervasives.Lemma (requires hd1 @ [tl1] == hd2 @ [tl2])
(ensures hd1 == hd2 /\ tl1 == tl2)
[SMTPat (hd1 @ [tl1]); SMTPat (hd2 @ [tl2])] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.list",
"FStar.List.Tot.Properties.lemma_snoc_unsnoc",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"CQueue.op_Equals_Equals",
"FStar.List.Tot.Base.append",
"Prims.Cons",
"Prims.Nil",
"Prims.squash",
"Prims.l_and",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat"
] | [] | true | false | true | false | false | let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a)
: Lemma (requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])] =
| L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2) | false |
CQueue.fst | CQueue.unsnoc | val unsnoc (#a: Type) (l: list a)
: Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l)) | val unsnoc (#a: Type) (l: list a)
: Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l)) | let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 12,
"end_line": 295,
"start_col": 0,
"start_line": 289
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: Prims.list a -> Prims.Pure (Prims.list a * a) | Prims.Pure | [] | [] | [
"Prims.list",
"FStar.List.Tot.Base.unsnoc",
"Prims.unit",
"FStar.List.Tot.Properties.append_length",
"FStar.Pervasives.Native.fst",
"Prims.Cons",
"FStar.Pervasives.Native.snd",
"Prims.Nil",
"FStar.List.Tot.Properties.lemma_unsnoc_snoc",
"FStar.Pervasives.Native.tuple2",
"Prims.b2t",
"Prims.uu___is_Cons",
"Prims.l_and",
"CQueue.op_Equals_Equals",
"FStar.List.Tot.Base.append",
"Prims.op_LessThan",
"FStar.List.Tot.Base.length"
] | [] | false | false | false | false | false | let unsnoc (#a: Type) (l: list a)
: Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l)) =
| L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l | false |
CQueue.fst | CQueue.llist_fragment_tail_cons_lvalue_payload | val llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) {Cons? (Ghost.reveal l)})
(c: ccell_lvalue a)
: Tot vprop | val llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) {Cons? (Ghost.reveal l)})
(c: ccell_lvalue a)
: Tot vprop | let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 70,
"end_line": 360,
"start_col": 0,
"start_line": 355
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: FStar.Ghost.erased (Prims.list a) {Cons? (FStar.Ghost.reveal l)} -> c: CQueue.Cell.ccell_lvalue a
-> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"FStar.Ghost.erased",
"Prims.list",
"Prims.b2t",
"Prims.uu___is_Cons",
"FStar.Ghost.reveal",
"CQueue.Cell.ccell_lvalue",
"Steel.Effect.Common.vrefine",
"Steel.Reference.vptr",
"CQueue.Cell.ccell_data",
"CQueue.llist_fragment_tail_cons_data_refine",
"Steel.Effect.Common.vprop"
] | [] | false | false | false | false | false | let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) {Cons? (Ghost.reveal l)})
(c: ccell_lvalue a)
: Tot vprop =
| (vptr (ccell_data c)) `vrefine` (llist_fragment_tail_cons_data_refine l) | false |
CQueue.fst | CQueue.snoc | val snoc (#a: Type) (l: list a) (x: a)
: Pure (list a)
(requires True)
(ensures (fun l' -> Cons? l' /\ unsnoc_hd l' == l /\ unsnoc_tl l' == x)) | val snoc (#a: Type) (l: list a) (x: a)
: Pure (list a)
(requires True)
(ensures (fun l' -> Cons? l' /\ unsnoc_hd l' == l /\ unsnoc_tl l' == x)) | let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l' | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 4,
"end_line": 313,
"start_col": 0,
"start_line": 302
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: Prims.list a -> x: a -> Prims.Pure (Prims.list a) | Prims.Pure | [] | [] | [
"Prims.list",
"Prims.unit",
"CQueue.snoc_inj",
"CQueue.unsnoc_hd",
"CQueue.unsnoc_tl",
"FStar.List.Tot.Properties.append_length",
"Prims.Cons",
"Prims.Nil",
"FStar.List.Tot.Base.snoc",
"FStar.Pervasives.Native.Mktuple2",
"Prims.l_True",
"Prims.l_and",
"Prims.b2t",
"Prims.uu___is_Cons",
"CQueue.op_Equals_Equals"
] | [] | false | false | false | false | false | let snoc (#a: Type) (l: list a) (x: a)
: Pure (list a)
(requires True)
(ensures (fun l' -> Cons? l' /\ unsnoc_hd l' == l /\ unsnoc_tl l' == x)) =
| let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l' | false |
CQueue.fst | CQueue.llist_fragment_tail | val llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l))) | val llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l))) | let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 237,
"end_line": 392,
"start_col": 0,
"start_line": 386
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: FStar.Ghost.erased (Prims.list a) -> phead: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a)
-> Prims.Pure Steel.Effect.Common.vprop | Prims.Pure | [
""
] | [] | [
"FStar.Ghost.erased",
"Prims.list",
"Steel.Reference.ref",
"CQueue.Cell.ccell_ptrvalue",
"Prims.uu___is_Nil",
"FStar.Ghost.reveal",
"CQueue.vconst",
"Prims.bool",
"Steel.Effect.Common.vrewrite",
"Steel.Effect.Common.vdep",
"CQueue.llist_fragment_tail",
"FStar.Ghost.hide",
"CQueue.unsnoc_hd",
"CQueue.llist_fragment_tail_cons_next_payload",
"CQueue.llist_fragment_tail_cons_rewrite",
"Steel.Effect.Common.vprop",
"Prims.l_True",
"CQueue.op_Equals_Equals",
"Steel.Effect.Common.t_of"
] | [
"recursion"
] | false | false | false | false | false | let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l))) =
| if Nil? l
then vconst phead
else
((llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
`vdep`
(llist_fragment_tail_cons_next_payload l))
`vrewrite`
(llist_fragment_tail_cons_rewrite l
(llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)) | false |
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.machine_heap | val machine_heap : Type0 | let machine_heap = Map.t int nat8 | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 14,
"start_col": 0,
"start_line": 14
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.Map.t",
"Prims.int",
"Vale.Def.Types_s.nat8"
] | [] | false | false | false | true | true | let machine_heap =
| Map.t int nat8 | false |
|
CQueue.fst | CQueue.queue_tail_dep2 | val queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop | val queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop | let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop
= vptr tail2 `vrefine` queue_tail_refine tail1 tail2 | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 52,
"end_line": 647,
"start_col": 0,
"start_line": 640
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end
let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2 | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
x: CQueue.t a ->
l: FStar.Ghost.erased (Prims.list a) ->
tail1: Steel.Effect.Common.t_of (CQueue.llist_fragment_tail l (CQueue.LList.cllist_head x)) ->
tail2: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a)
-> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"CQueue.t",
"FStar.Ghost.erased",
"Prims.list",
"Steel.Effect.Common.t_of",
"CQueue.llist_fragment_tail",
"CQueue.LList.cllist_head",
"Steel.Reference.ref",
"CQueue.Cell.ccell_ptrvalue",
"Steel.Effect.Common.vrefine",
"Steel.Reference.vptr",
"CQueue.queue_tail_refine",
"Steel.Effect.Common.vprop"
] | [] | false | false | false | false | false | let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop =
| (vptr tail2) `vrefine` (queue_tail_refine tail1 tail2) | false |
CQueue.fst | CQueue.llist_fragment_head | val llist_fragment_head
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: Tot vprop (decreases (Ghost.reveal l)) | val llist_fragment_head
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: Tot vprop (decreases (Ghost.reveal l)) | let rec llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Tot vprop
(decreases (Ghost.reveal l))
=
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l)))) | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 110,
"end_line": 767,
"start_col": 0,
"start_line": 758
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end
let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2
[@@__steel_reduce__]
let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop
= vptr tail2 `vrefine` queue_tail_refine tail1 tail2
[@@__steel_reduce__]
let queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop
= vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1
[@@__steel_reduce__; __reduce__]
let queue_tail
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
=
llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l
val intro_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun _ -> queue_tail x l)
(fun h ->
sel_llist_fragment_tail l (cllist_head x) h == tail /\
sel (cllist_tail x) h == tail /\
ccell_ptrvalue_is_null (sel tail h)
)
(fun _ _ _ -> True)
let intro_queue_tail
x l tail
=
intro_vrefine (vptr tail) (queue_tail_refine tail tail);
intro_vdep2
(vptr (cllist_tail x))
(vptr tail `vrefine` queue_tail_refine tail tail)
tail
(queue_tail_dep2 x l tail);
intro_vdep2
(llist_fragment_tail l (cllist_head x))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail)
tail
(queue_tail_dep1 x l)
val elim_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(queue_tail x l)
(fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun h -> True)
(fun _ tail h ->
sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\
sel (cllist_tail x) h == Ghost.reveal tail /\
ccell_ptrvalue_is_null (h (vptr tail))
)
let elim_queue_tail
#_ #a x l
=
let tail0 = elim_vdep
(llist_fragment_tail l (cllist_head x))
(queue_tail_dep1 x l)
in
let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in
change_equal_slprop
(queue_tail_dep1 x l (Ghost.reveal tail0))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0);
let tail2 = elim_vdep
(vptr (cllist_tail x))
(queue_tail_dep2 x l tail0)
in
let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in
change_equal_slprop
(queue_tail_dep2 x l tail0 (Ghost.reveal tail2))
(vptr tail3 `vrefine` queue_tail_refine tail0 tail3);
elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3);
change_equal_slprop
(vptr tail3)
(vptr tail);
tail
(* view from the head *)
let llist_fragment_head_data_refine
(#a: Type)
(d: a)
(c: vcell a)
: Tot prop
= c.vcell_data == d
let llist_fragment_head_payload
(#a: Type)
(head: ccell_ptrvalue a)
(d: a)
(llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop))
(x: t_of (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine d)))
: Tot vprop
=
llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
l: FStar.Ghost.erased (Prims.list a) ->
phead: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) ->
head: CQueue.Cell.ccell_ptrvalue a
-> Prims.Tot Steel.Effect.Common.vprop | Prims.Tot | [
"total",
""
] | [] | [
"FStar.Ghost.erased",
"Prims.list",
"Steel.Reference.ref",
"CQueue.Cell.ccell_ptrvalue",
"Prims.uu___is_Nil",
"FStar.Ghost.reveal",
"CQueue.vconst",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"CQueue.vbind",
"Steel.Effect.Common.star",
"CQueue.Cell.ccell_is_lvalue",
"Steel.Effect.Common.vrefine",
"CQueue.Cell.ccell",
"CQueue.llist_fragment_head_data_refine",
"FStar.List.Tot.Base.hd",
"CQueue.llist_fragment_head_payload",
"CQueue.llist_fragment_head",
"FStar.Ghost.hide",
"FStar.List.Tot.Base.tl",
"Steel.Effect.Common.vprop"
] | [
"recursion"
] | false | false | false | true | false | let rec llist_fragment_head
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: Tot vprop (decreases (Ghost.reveal l)) =
| if Nil? l
then vconst (phead, head)
else
vbind ((ccell_is_lvalue head)
`star`
((ccell head) `vrefine` (llist_fragment_head_data_refine (L.hd (Ghost.reveal l)))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head
(L.hd (Ghost.reveal l))
(llist_fragment_head (L.tl (Ghost.reveal l)))) | false |
CQueue.fst | CQueue.llist_fragment_tail_cons_next_payload | val llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) {Cons? (Ghost.reveal l)})
(ptail: ref (ccell_ptrvalue a))
: Tot vprop | val llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) {Cons? (Ghost.reveal l)})
(ptail: ref (ccell_ptrvalue a))
: Tot vprop | let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 96,
"end_line": 374,
"start_col": 0,
"start_line": 369
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
l: FStar.Ghost.erased (Prims.list a) {Cons? (FStar.Ghost.reveal l)} ->
ptail: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a)
-> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"FStar.Ghost.erased",
"Prims.list",
"Prims.b2t",
"Prims.uu___is_Cons",
"FStar.Ghost.reveal",
"Steel.Reference.ref",
"CQueue.Cell.ccell_ptrvalue",
"Steel.Effect.Common.vdep",
"Steel.Effect.Common.vrefine",
"Steel.Reference.vptr",
"CQueue.ccell_is_lvalue_refine",
"CQueue.llist_fragment_tail_cons_lvalue_payload",
"Steel.Effect.Common.vprop"
] | [] | false | false | false | false | false | let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) {Cons? (Ghost.reveal l)})
(ptail: ref (ccell_ptrvalue a))
: Tot vprop =
| ((vptr ptail) `vrefine` (ccell_is_lvalue_refine a))
`vdep`
(llist_fragment_tail_cons_lvalue_payload l) | false |
CQueue.fst | CQueue.llist_fragment_tail_cons_data_refine | val llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) {Cons? (Ghost.reveal l)})
(d: a)
: Tot prop | val llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) {Cons? (Ghost.reveal l)})
(d: a)
: Tot prop | let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l) | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 33,
"end_line": 352,
"start_col": 0,
"start_line": 347
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: FStar.Ghost.erased (Prims.list a) {Cons? (FStar.Ghost.reveal l)} -> d: a -> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"FStar.Ghost.erased",
"Prims.list",
"Prims.b2t",
"Prims.uu___is_Cons",
"FStar.Ghost.reveal",
"CQueue.op_Equals_Equals",
"CQueue.unsnoc_tl",
"Prims.prop"
] | [] | false | false | false | false | true | let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) {Cons? (Ghost.reveal l)})
(d: a)
: Tot prop =
| d == unsnoc_tl (Ghost.reveal l) | false |
LList2.fst | LList2.pllist_put | val pllist_put
(#v: Ghost.erased (scalar_t (ptr cell)))
(#l: Ghost.erased (list U32.t))
(p: ref (scalar (ptr cell)))
(pc: ptr cell)
: ST unit
((pts_to p v) `star` (llist pc l))
(fun _ -> pllist p l)
(full (scalar (ptr cell)) v)
(fun _ -> True) | val pllist_put
(#v: Ghost.erased (scalar_t (ptr cell)))
(#l: Ghost.erased (list U32.t))
(p: ref (scalar (ptr cell)))
(pc: ptr cell)
: ST unit
((pts_to p v) `star` (llist pc l))
(fun _ -> pllist p l)
(full (scalar (ptr cell)) v)
(fun _ -> True) | let pllist_put
(#v: Ghost.erased (scalar_t (ptr cell)))
(#l: Ghost.erased (list U32.t))
(p: ref (scalar (ptr cell)))
(pc: ptr cell)
: ST unit
(pts_to p v `star` llist pc l)
(fun _ -> pllist p l)
(full (scalar (ptr cell)) v)
(fun _ -> True)
= write p pc;
rewrite (pllist0 p l) (pllist p l) | {
"file_name": "share/steel/examples/steelc/LList2.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 36,
"end_line": 129,
"start_col": 0,
"start_line": 118
} | module LList2
open Steel.ST.GenElim
open Steel.ST.C.Types
open Steel.ST.C.Types.Struct.Aux
open Steel.ST.C.Types.UserStruct // hides Struct
module U32 = FStar.UInt32
noeq
type cell_t = {
hd: scalar_t U32.t;
tl: scalar_t (ptr_gen cell_t);
}
noextract
inline_for_extraction
[@@ norm_field_attr]
let cell_struct_def : struct_def cell_t =
let fields = FStar.Set.add "hd" (FStar.Set.singleton "tl") in
let field_desc : field_description_gen_t (field_t fields) = {
fd_nonempty = nonempty_set_nonempty_type "hd" fields;
fd_type = (fun (n: field_t fields) -> match n with "hd" -> scalar_t U32.t | "tl" -> scalar_t (ptr_gen cell_t));
fd_typedef = (fun (n: field_t fields) -> match n with "hd" -> scalar U32.t | "tl" -> scalar (ptr_gen cell_t));
}
in {
fields = fields;
field_desc = field_desc;
mk = (fun f -> Mkcell_t (f "hd") (f "tl"));
get = (fun x (f: field_t fields) -> match f with "hd" -> x.hd | "tl" -> x.tl);
get_mk = (fun _ _ -> ());
extensionality = (fun s1 s2 phi -> phi "hd"; phi "tl");
}
noextract
inline_for_extraction
[@@ norm_field_attr]
let cell = struct_typedef cell_struct_def
[@@__reduce__]
let llist_nil (p: ptr cell) : Tot vprop =
pure (p == null _)
[@@__reduce__]
let llist_cons (p: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) (llist: (ptr cell -> (l: Ghost.erased (list U32.t) { List.Tot.length l < List.Tot.length (a :: q) }) -> Tot vprop)) : Tot vprop =
exists_ (fun (p1: ref cell) -> exists_ (fun (p2: ptr cell) ->
pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar p2 }) `star`
llist p2 q `star`
freeable p1 `star`
pure (p == p1)
))
let rec llist (p: ptr cell) (l: Ghost.erased (list U32.t)) : Tot vprop (decreases (List.Tot.length l)) =
match Ghost.reveal l with
| [] -> llist_nil p
| a :: q -> llist_cons p a q llist
let intro_llist_cons
(#opened: _)
(p1: ref cell) (#v1: Ghost.erased (typeof cell)) (p2: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t))
: STGhost unit opened
(pts_to p1 v1 `star`
llist p2 q `star`
freeable p1
)
(fun _ -> llist p1 (a :: q))
(Ghost.reveal v1 == ({ hd = mk_scalar a; tl = mk_scalar p2 }))
(fun _ -> True)
= noop ();
rewrite_with_tactic (llist_cons p1 a q llist) (llist p1 (a :: q))
let elim_llist_cons
(#opened: _)
(p1: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t))
: STGhostT (p2: Ghost.erased (ptr cell) { ~ (p1 == null _) }) opened
(llist p1 (a :: q))
(fun p2 ->
pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar (Ghost.reveal p2) }) `star`
llist p2 q `star`
freeable p1
)
= rewrite_with_tactic (llist p1 (a :: q)) (llist_cons p1 a q llist);
let _ = gen_elim () in
let p2' = vpattern_erased (fun x -> llist x q) in
let p2 : (p2: Ghost.erased (ptr cell) { ~ (p1 == null _) }) = p2' in
vpattern_rewrite (fun x -> llist x q) p2;
rewrite (pts_to _ _) (pts_to _ _);
rewrite (freeable _) (freeable _);
_
[@@__reduce__]
let pllist0
(p: ref (scalar (ptr cell)))
(l: Ghost.erased (list U32.t))
: Tot vprop
= exists_ (fun (pc: ptr cell) ->
pts_to p (mk_scalar pc) `star`
llist pc l
)
let pllist
(p: ref (scalar (ptr cell)))
(l: Ghost.erased (list U32.t))
: Tot vprop
= pllist0 p l
let pllist_get
(#l: Ghost.erased (list U32.t))
(p: ref (scalar (ptr cell)))
: STT (ptr cell)
(pllist p l)
(fun pc -> pts_to p (mk_scalar (Ghost.reveal pc)) `star` llist pc l)
= rewrite (pllist p l) (pllist0 p l);
let _ = gen_elim () in
let pc = read p in
vpattern_rewrite (fun x -> llist x l) pc;
return pc | {
"checked_file": "/",
"dependencies": [
"Steel.ST.GenElim.fsti.checked",
"Steel.ST.C.Types.UserStruct.fsti.checked",
"Steel.ST.C.Types.Struct.Aux.fsti.checked",
"Steel.ST.C.Types.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LList2.fst"
} | [
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct // hides Struct",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.Struct.Aux",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p:
Steel.ST.C.Types.Base.ref (Steel.ST.C.Types.Scalar.scalar (Steel.ST.C.Types.Base.ptr LList2.cell
)) ->
pc: Steel.ST.C.Types.Base.ptr LList2.cell
-> Steel.ST.Effect.ST Prims.unit | Steel.ST.Effect.ST | [] | [] | [
"FStar.Ghost.erased",
"Steel.ST.C.Types.Scalar.scalar_t",
"Steel.ST.C.Types.Base.ptr",
"LList2.cell_t",
"LList2.cell",
"Prims.list",
"FStar.UInt32.t",
"Steel.ST.C.Types.Base.ref",
"Steel.ST.C.Types.Scalar.scalar",
"Steel.ST.Util.rewrite",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty",
"LList2.pllist0",
"LList2.pllist",
"Prims.unit",
"Steel.ST.C.Types.Scalar.write",
"Steel.Effect.Common.star",
"Steel.ST.C.Types.Base.pts_to",
"LList2.llist",
"Steel.Effect.Common.vprop",
"Steel.ST.C.Types.Base.full",
"FStar.Ghost.reveal",
"Prims.l_True"
] | [] | false | true | false | false | false | let pllist_put
(#v: Ghost.erased (scalar_t (ptr cell)))
(#l: Ghost.erased (list U32.t))
(p: ref (scalar (ptr cell)))
(pc: ptr cell)
: ST unit
((pts_to p v) `star` (llist pc l))
(fun _ -> pllist p l)
(full (scalar (ptr cell)) v)
(fun _ -> True) =
| write p pc;
rewrite (pllist0 p l) (pllist p l) | false |
CQueue.fst | CQueue.llist_fragment_head_payload | val llist_fragment_head_payload
(#a: Type)
(head: ccell_ptrvalue a)
(d: a)
(llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop))
(x:
t_of ((ccell_is_lvalue head)
`star`
((ccell head) `vrefine` (llist_fragment_head_data_refine d))))
: Tot vprop | val llist_fragment_head_payload
(#a: Type)
(head: ccell_ptrvalue a)
(d: a)
(llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop))
(x:
t_of ((ccell_is_lvalue head)
`star`
((ccell head) `vrefine` (llist_fragment_head_data_refine d))))
: Tot vprop | let llist_fragment_head_payload
(#a: Type)
(head: ccell_ptrvalue a)
(d: a)
(llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop))
(x: t_of (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine d)))
: Tot vprop
=
llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 61,
"end_line": 756,
"start_col": 0,
"start_line": 748
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end
let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2
[@@__steel_reduce__]
let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop
= vptr tail2 `vrefine` queue_tail_refine tail1 tail2
[@@__steel_reduce__]
let queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop
= vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1
[@@__steel_reduce__; __reduce__]
let queue_tail
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
=
llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l
val intro_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun _ -> queue_tail x l)
(fun h ->
sel_llist_fragment_tail l (cllist_head x) h == tail /\
sel (cllist_tail x) h == tail /\
ccell_ptrvalue_is_null (sel tail h)
)
(fun _ _ _ -> True)
let intro_queue_tail
x l tail
=
intro_vrefine (vptr tail) (queue_tail_refine tail tail);
intro_vdep2
(vptr (cllist_tail x))
(vptr tail `vrefine` queue_tail_refine tail tail)
tail
(queue_tail_dep2 x l tail);
intro_vdep2
(llist_fragment_tail l (cllist_head x))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail)
tail
(queue_tail_dep1 x l)
val elim_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(queue_tail x l)
(fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun h -> True)
(fun _ tail h ->
sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\
sel (cllist_tail x) h == Ghost.reveal tail /\
ccell_ptrvalue_is_null (h (vptr tail))
)
let elim_queue_tail
#_ #a x l
=
let tail0 = elim_vdep
(llist_fragment_tail l (cllist_head x))
(queue_tail_dep1 x l)
in
let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in
change_equal_slprop
(queue_tail_dep1 x l (Ghost.reveal tail0))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0);
let tail2 = elim_vdep
(vptr (cllist_tail x))
(queue_tail_dep2 x l tail0)
in
let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in
change_equal_slprop
(queue_tail_dep2 x l tail0 (Ghost.reveal tail2))
(vptr tail3 `vrefine` queue_tail_refine tail0 tail3);
elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3);
change_equal_slprop
(vptr tail3)
(vptr tail);
tail
(* view from the head *)
let llist_fragment_head_data_refine
(#a: Type)
(d: a)
(c: vcell a)
: Tot prop
= c.vcell_data == d | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
head: CQueue.Cell.ccell_ptrvalue a ->
d: a ->
llist_fragment_head:
(_: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) -> _: CQueue.Cell.ccell_ptrvalue a
-> Steel.Effect.Common.vprop) ->
x:
Steel.Effect.Common.t_of (Steel.Effect.Common.star (CQueue.Cell.ccell_is_lvalue head)
(Steel.Effect.Common.vrefine (CQueue.Cell.ccell head)
(CQueue.llist_fragment_head_data_refine d)))
-> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"CQueue.Cell.ccell_ptrvalue",
"Steel.Reference.ref",
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.t_of",
"Steel.Effect.Common.star",
"CQueue.Cell.ccell_is_lvalue",
"Steel.Effect.Common.vrefine",
"CQueue.Cell.ccell",
"CQueue.llist_fragment_head_data_refine",
"CQueue.Cell.ccell_next",
"FStar.Pervasives.Native.fst",
"CQueue.Cell.__proj__Mkvcell__item__vcell_next",
"FStar.Pervasives.Native.snd"
] | [] | false | false | false | false | false | let llist_fragment_head_payload
(#a: Type)
(head: ccell_ptrvalue a)
(d: a)
(llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop))
(x:
t_of ((ccell_is_lvalue head)
`star`
((ccell head) `vrefine` (llist_fragment_head_data_refine d))))
: Tot vprop =
| llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next | false |
CQueue.fst | CQueue.queue_head_dep1 | val queue_head_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
: Tot vprop | val queue_head_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
: Tot vprop | let queue_head_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
: Tot vprop
= vptr (cllist_tail x) `vrefine` queue_head_refine x l hd ptl | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 61,
"end_line": 1175,
"start_col": 0,
"start_line": 1168
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end
let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2
[@@__steel_reduce__]
let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop
= vptr tail2 `vrefine` queue_tail_refine tail1 tail2
[@@__steel_reduce__]
let queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop
= vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1
[@@__steel_reduce__; __reduce__]
let queue_tail
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
=
llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l
val intro_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun _ -> queue_tail x l)
(fun h ->
sel_llist_fragment_tail l (cllist_head x) h == tail /\
sel (cllist_tail x) h == tail /\
ccell_ptrvalue_is_null (sel tail h)
)
(fun _ _ _ -> True)
let intro_queue_tail
x l tail
=
intro_vrefine (vptr tail) (queue_tail_refine tail tail);
intro_vdep2
(vptr (cllist_tail x))
(vptr tail `vrefine` queue_tail_refine tail tail)
tail
(queue_tail_dep2 x l tail);
intro_vdep2
(llist_fragment_tail l (cllist_head x))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail)
tail
(queue_tail_dep1 x l)
val elim_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(queue_tail x l)
(fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun h -> True)
(fun _ tail h ->
sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\
sel (cllist_tail x) h == Ghost.reveal tail /\
ccell_ptrvalue_is_null (h (vptr tail))
)
let elim_queue_tail
#_ #a x l
=
let tail0 = elim_vdep
(llist_fragment_tail l (cllist_head x))
(queue_tail_dep1 x l)
in
let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in
change_equal_slprop
(queue_tail_dep1 x l (Ghost.reveal tail0))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0);
let tail2 = elim_vdep
(vptr (cllist_tail x))
(queue_tail_dep2 x l tail0)
in
let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in
change_equal_slprop
(queue_tail_dep2 x l tail0 (Ghost.reveal tail2))
(vptr tail3 `vrefine` queue_tail_refine tail0 tail3);
elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3);
change_equal_slprop
(vptr tail3)
(vptr tail);
tail
(* view from the head *)
let llist_fragment_head_data_refine
(#a: Type)
(d: a)
(c: vcell a)
: Tot prop
= c.vcell_data == d
let llist_fragment_head_payload
(#a: Type)
(head: ccell_ptrvalue a)
(d: a)
(llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop))
(x: t_of (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine d)))
: Tot vprop
=
llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next
let rec llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Tot vprop
(decreases (Ghost.reveal l))
=
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
let t_of_llist_fragment_head
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(t_of (llist_fragment_head l phead head) == ref (ccell_ptrvalue a) & ccell_ptrvalue a)
= ()
unfold
let sel_llist_fragment_head
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_head l phead head) /\ True) })
: GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
=
coerce (h (llist_fragment_head l phead head)) (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
val intro_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_head l phead head)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_head l phead head h' == (phead, head))
let intro_llist_fragment_head_nil
l phead head
=
intro_vconst (phead, head);
change_equal_slprop
(vconst (phead, head))
(llist_fragment_head l phead head)
val elim_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_head l phead head h == (phead, head))
let elim_llist_fragment_head_nil
l phead head
=
change_equal_slprop
(llist_fragment_head l phead head)
(vconst (phead, head));
elim_vconst (phead, head)
let llist_fragment_head_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(requires (Cons? (Ghost.reveal l)))
(ensures (
llist_fragment_head l phead head ==
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
))
= assert_norm
(llist_fragment_head l phead head == (
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
))
val intro_llist_fragment_head_cons
(#opened: _)
(#a: Type) (phead: ref (ccell_ptrvalue a)) (head: ccell_lvalue a) (next: (ccell_ptrvalue a)) (tl: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(ccell head `star` llist_fragment_head tl (ccell_next head) next)
(fun res -> llist_fragment_head res phead head)
(fun h -> (h (ccell head)).vcell_next == next)
(fun h res h' ->
Ghost.reveal res == (h (ccell head)).vcell_data :: Ghost.reveal tl /\
h' (llist_fragment_head res phead head) == h (llist_fragment_head tl (ccell_next head) next)
)
let intro_llist_fragment_head_cons
#_ #a phead head next tl
=
let vc = gget (ccell head) in
let l' : (l' : Ghost.erased (list a) { Cons? l' }) = Ghost.hide (vc.vcell_data :: tl) in
intro_ccell_is_lvalue head;
intro_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l'));
intro_vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l')))
(llist_fragment_head tl (ccell_next head) next)
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l')));
llist_fragment_head_eq_cons l' phead head;
change_equal_slprop
(vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l')))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l'))))
(llist_fragment_head l' phead head);
l'
[@@erasable]
noeq
type ll_uncons_t
(a: Type)
= {
ll_uncons_pnext: Ghost.erased (ref (ccell_ptrvalue a));
ll_uncons_next: Ghost.erased (ccell_ptrvalue a);
ll_uncons_tl: Ghost.erased (list a);
}
val elim_llist_fragment_head_cons
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost (ll_uncons_t a) opened
(llist_fragment_head l phead head)
(fun res -> ccell head `star` llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next)
(fun _ -> Cons? (Ghost.reveal l))
(fun h res h' ->
ccell_ptrvalue_is_null head == false /\
Ghost.reveal l == (h' (ccell head)).vcell_data :: Ghost.reveal res.ll_uncons_tl /\
Ghost.reveal res.ll_uncons_pnext == ccell_next head /\
Ghost.reveal res.ll_uncons_next == (h' (ccell head)).vcell_next /\
h' (llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next) == h (llist_fragment_head l phead head)
)
let elim_llist_fragment_head_cons
#_ #a l0 phead head
=
let l : (l : Ghost.erased (list a) { Cons? l }) = l0 in
change_equal_slprop
(llist_fragment_head l0 phead head)
(llist_fragment_head l phead head);
llist_fragment_head_eq_cons l phead head;
change_equal_slprop
(llist_fragment_head l phead head)
(vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l)))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l))));
let x = elim_vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l)))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)))
in
let head2 = gget (ccell_is_lvalue head) in
elim_ccell_is_lvalue head;
elim_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l));
let vhead2 = gget (ccell head) in
let res = {
ll_uncons_pnext = ccell_next head2;
ll_uncons_next = vhead2.vcell_next;
ll_uncons_tl = L.tl l;
} in
change_equal_slprop
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)) (Ghost.reveal x))
(llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next);
res
let rec llist_fragment_head_append
(#opened: _)
(#a: Type)
(l1: Ghost.erased (list a))
(phead1: ref (ccell_ptrvalue a))
(head1: ccell_ptrvalue a)
(l2: Ghost.erased (list a))
(phead2: ref (ccell_ptrvalue a))
(head2: ccell_ptrvalue a)
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_head l1 phead1 head1 `star` llist_fragment_head l2 phead2 head2)
(fun l -> llist_fragment_head l phead1 head1)
(fun h -> sel_llist_fragment_head l1 phead1 head1 h == (Ghost.reveal phead2, Ghost.reveal head2))
(fun h l h' ->
Ghost.reveal l == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
h' (llist_fragment_head l phead1 head1) == h (llist_fragment_head l2 phead2 head2)
)
(decreases (Ghost.reveal l1))
=
if Nil? l1
then begin
elim_llist_fragment_head_nil l1 phead1 head1;
change_equal_slprop
(llist_fragment_head l2 phead2 head2)
(llist_fragment_head l2 phead1 head1);
l2
end else begin
let u = elim_llist_fragment_head_cons l1 phead1 head1 in
let head1' : Ghost.erased (ccell_lvalue a) = head1 in
let l3 = llist_fragment_head_append u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next l2 phead2 head2 in
change_equal_slprop
(llist_fragment_head l3 u.ll_uncons_pnext u.ll_uncons_next)
(llist_fragment_head l3 (ccell_next head1') u.ll_uncons_next);
change_equal_slprop
(ccell head1)
(ccell head1');
let l4 = intro_llist_fragment_head_cons phead1 head1' u.ll_uncons_next l3 in
change_equal_slprop
(llist_fragment_head l4 phead1 head1')
(llist_fragment_head l4 phead1 head1);
l4
end
let rec llist_fragment_head_to_tail
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(vptr phead `star` llist_fragment_head l phead head)
(fun res -> llist_fragment_tail l phead `star` vptr res)
(fun h -> h (vptr phead) == head)
(fun h res h' ->
let v = sel_llist_fragment_head l phead head h in
fst v == Ghost.reveal res /\
fst v == sel_llist_fragment_tail l phead h' /\
snd v == h' (vptr res)
)
(decreases (L.length (Ghost.reveal l)))
=
if Nil? l
then begin
let ptail = Ghost.hide phead in
let gh = gget (vptr phead) in
assert (Ghost.reveal gh == head);
elim_llist_fragment_head_nil l phead head;
intro_llist_fragment_tail_nil l phead;
change_equal_slprop
(vptr phead)
(vptr ptail);
ptail
end else begin
intro_llist_fragment_tail_nil [] phead;
change_equal_slprop
(vptr phead)
(vptr (Ghost.reveal (Ghost.hide phead)));
let uc = elim_llist_fragment_head_cons l phead head in
let head' = elim_ccell_ghost head in
change_equal_slprop
(vptr (ccell_next head'))
(vptr uc.ll_uncons_pnext);
let lc = intro_llist_fragment_tail_snoc [] phead phead head' in
let ptail = llist_fragment_head_to_tail
uc.ll_uncons_tl
uc.ll_uncons_pnext
uc.ll_uncons_next
in
let l' = llist_fragment_tail_append phead lc uc.ll_uncons_pnext uc.ll_uncons_tl in
change_equal_slprop
(llist_fragment_tail l' phead)
(llist_fragment_tail l phead);
ptail
end
#push-options "--z3rlimit 16"
#restart-solver
let rec llist_fragment_tail_to_head
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: ref (ccell_ptrvalue a))
: SteelGhost (Ghost.erased (ccell_ptrvalue a)) opened
(llist_fragment_tail l phead `star` vptr ptail)
(fun head -> vptr phead `star` llist_fragment_head l phead (Ghost.reveal head))
(fun h -> Ghost.reveal ptail == sel_llist_fragment_tail l phead h)
(fun h head h' ->
let v = sel_llist_fragment_head l phead head h' in
fst v == ptail /\
snd v == h (vptr ptail) /\
h' (vptr phead) == Ghost.reveal head
)
(decreases (L.length (Ghost.reveal l)))
=
if Nil? l
then begin
let g = gget (llist_fragment_tail l phead) in
assert (Ghost.reveal g == ptail);
elim_llist_fragment_tail_nil l phead;
change_equal_slprop
(vptr ptail)
(vptr phead);
let head = gget (vptr phead) in
intro_llist_fragment_head_nil l phead head;
head
end else begin
let us = elim_llist_fragment_tail_snoc l phead in
let tail = gget (vptr ptail) in
assert (ccell_next us.ll_unsnoc_tail == ptail);
intro_llist_fragment_head_nil [] (ccell_next us.ll_unsnoc_tail) tail;
change_equal_slprop
(vptr ptail)
(vptr (ccell_next us.ll_unsnoc_tail));
intro_ccell us.ll_unsnoc_tail;
let lc = intro_llist_fragment_head_cons us.ll_unsnoc_ptail us.ll_unsnoc_tail tail [] in
let head = llist_fragment_tail_to_head us.ll_unsnoc_l phead us.ll_unsnoc_ptail in
let g = gget (llist_fragment_head us.ll_unsnoc_l phead head) in
let g : Ghost.erased (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = Ghost.hide (Ghost.reveal g) in
assert (Ghost.reveal g == (Ghost.reveal us.ll_unsnoc_ptail, Ghost.reveal us.ll_unsnoc_tail));
let l' = llist_fragment_head_append us.ll_unsnoc_l phead head lc us.ll_unsnoc_ptail us.ll_unsnoc_tail in
change_equal_slprop
(llist_fragment_head l' phead head)
(llist_fragment_head l phead head);
head
end
#pop-options
val llist_fragment_head_is_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> llist_fragment_head l phead head)
(fun h -> ccell_ptrvalue_is_null (snd (sel_llist_fragment_head l phead head h)) == true)
(fun h _ h' ->
Nil? l == ccell_ptrvalue_is_null head /\
h' (llist_fragment_head l phead head) == h (llist_fragment_head l phead head)
)
let llist_fragment_head_is_nil
l phead head
=
if Nil? l
then begin
elim_llist_fragment_head_nil l phead head;
assert (ccell_ptrvalue_is_null head == true);
intro_llist_fragment_head_nil l phead head
end else begin
let r = elim_llist_fragment_head_cons l phead head in
let head2 : ccell_lvalue _ = head in
change_equal_slprop
(llist_fragment_head r.ll_uncons_tl r.ll_uncons_pnext r.ll_uncons_next)
(llist_fragment_head r.ll_uncons_tl (ccell_next head2) r.ll_uncons_next);
change_equal_slprop
(ccell head)
(ccell head2);
let l' = intro_llist_fragment_head_cons phead head2 r.ll_uncons_next r.ll_uncons_tl in
change_equal_slprop
(llist_fragment_head l' phead head2)
(llist_fragment_head l phead head)
end
val llist_fragment_head_cons_change_phead
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
(phead' : ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> llist_fragment_head l phead' head)
(fun _ -> Cons? l)
(fun h _ h' -> h' (llist_fragment_head l phead' head) == h (llist_fragment_head l phead head))
let llist_fragment_head_cons_change_phead
l phead head phead'
=
let u = elim_llist_fragment_head_cons l phead head in
let head2 : ccell_lvalue _ = head in
change_equal_slprop
(ccell head)
(ccell head2);
change_equal_slprop
(llist_fragment_head u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next)
(llist_fragment_head u.ll_uncons_tl (ccell_next head2) u.ll_uncons_next);
let l' = intro_llist_fragment_head_cons phead' head2 u.ll_uncons_next u.ll_uncons_tl in
change_equal_slprop
(llist_fragment_head l' phead' head2)
(llist_fragment_head l phead' head)
let queue_head_refine
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
(tl: ref (ccell_ptrvalue a))
: Tot prop
= let ptl : (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = ptl in
tl == fst ptl /\ ccell_ptrvalue_is_null (snd ptl) == true | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
x: CQueue.t a ->
l: FStar.Ghost.erased (Prims.list a) ->
hd: CQueue.Cell.ccell_ptrvalue a ->
ptl: Steel.Effect.Common.t_of (CQueue.llist_fragment_head l (CQueue.LList.cllist_head x) hd)
-> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"CQueue.t",
"FStar.Ghost.erased",
"Prims.list",
"CQueue.Cell.ccell_ptrvalue",
"Steel.Effect.Common.t_of",
"CQueue.llist_fragment_head",
"CQueue.LList.cllist_head",
"Steel.Effect.Common.vrefine",
"Steel.Reference.vptr",
"Steel.Reference.ref",
"CQueue.LList.cllist_tail",
"CQueue.queue_head_refine",
"Steel.Effect.Common.vprop"
] | [] | false | false | false | false | false | let queue_head_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
: Tot vprop =
| (vptr (cllist_tail x)) `vrefine` (queue_head_refine x l hd ptl) | false |
CQueue.fst | CQueue.queue_head_dep2 | val queue_head_dep2 (#a: Type) (x: t a) (l: Ghost.erased (list a)) (hd: ccell_ptrvalue a)
: Tot vprop | val queue_head_dep2 (#a: Type) (x: t a) (l: Ghost.erased (list a)) (hd: ccell_ptrvalue a)
: Tot vprop | let queue_head_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
: Tot vprop
= llist_fragment_head l (cllist_head x) hd `vdep` queue_head_dep1 x l hd | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 72,
"end_line": 1183,
"start_col": 0,
"start_line": 1177
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end
let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2
[@@__steel_reduce__]
let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop
= vptr tail2 `vrefine` queue_tail_refine tail1 tail2
[@@__steel_reduce__]
let queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop
= vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1
[@@__steel_reduce__; __reduce__]
let queue_tail
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
=
llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l
val intro_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun _ -> queue_tail x l)
(fun h ->
sel_llist_fragment_tail l (cllist_head x) h == tail /\
sel (cllist_tail x) h == tail /\
ccell_ptrvalue_is_null (sel tail h)
)
(fun _ _ _ -> True)
let intro_queue_tail
x l tail
=
intro_vrefine (vptr tail) (queue_tail_refine tail tail);
intro_vdep2
(vptr (cllist_tail x))
(vptr tail `vrefine` queue_tail_refine tail tail)
tail
(queue_tail_dep2 x l tail);
intro_vdep2
(llist_fragment_tail l (cllist_head x))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail)
tail
(queue_tail_dep1 x l)
val elim_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(queue_tail x l)
(fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun h -> True)
(fun _ tail h ->
sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\
sel (cllist_tail x) h == Ghost.reveal tail /\
ccell_ptrvalue_is_null (h (vptr tail))
)
let elim_queue_tail
#_ #a x l
=
let tail0 = elim_vdep
(llist_fragment_tail l (cllist_head x))
(queue_tail_dep1 x l)
in
let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in
change_equal_slprop
(queue_tail_dep1 x l (Ghost.reveal tail0))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0);
let tail2 = elim_vdep
(vptr (cllist_tail x))
(queue_tail_dep2 x l tail0)
in
let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in
change_equal_slprop
(queue_tail_dep2 x l tail0 (Ghost.reveal tail2))
(vptr tail3 `vrefine` queue_tail_refine tail0 tail3);
elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3);
change_equal_slprop
(vptr tail3)
(vptr tail);
tail
(* view from the head *)
let llist_fragment_head_data_refine
(#a: Type)
(d: a)
(c: vcell a)
: Tot prop
= c.vcell_data == d
let llist_fragment_head_payload
(#a: Type)
(head: ccell_ptrvalue a)
(d: a)
(llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop))
(x: t_of (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine d)))
: Tot vprop
=
llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next
let rec llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Tot vprop
(decreases (Ghost.reveal l))
=
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
let t_of_llist_fragment_head
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(t_of (llist_fragment_head l phead head) == ref (ccell_ptrvalue a) & ccell_ptrvalue a)
= ()
unfold
let sel_llist_fragment_head
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_head l phead head) /\ True) })
: GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
=
coerce (h (llist_fragment_head l phead head)) (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
val intro_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_head l phead head)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_head l phead head h' == (phead, head))
let intro_llist_fragment_head_nil
l phead head
=
intro_vconst (phead, head);
change_equal_slprop
(vconst (phead, head))
(llist_fragment_head l phead head)
val elim_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_head l phead head h == (phead, head))
let elim_llist_fragment_head_nil
l phead head
=
change_equal_slprop
(llist_fragment_head l phead head)
(vconst (phead, head));
elim_vconst (phead, head)
let llist_fragment_head_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(requires (Cons? (Ghost.reveal l)))
(ensures (
llist_fragment_head l phead head ==
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
))
= assert_norm
(llist_fragment_head l phead head == (
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
))
val intro_llist_fragment_head_cons
(#opened: _)
(#a: Type) (phead: ref (ccell_ptrvalue a)) (head: ccell_lvalue a) (next: (ccell_ptrvalue a)) (tl: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(ccell head `star` llist_fragment_head tl (ccell_next head) next)
(fun res -> llist_fragment_head res phead head)
(fun h -> (h (ccell head)).vcell_next == next)
(fun h res h' ->
Ghost.reveal res == (h (ccell head)).vcell_data :: Ghost.reveal tl /\
h' (llist_fragment_head res phead head) == h (llist_fragment_head tl (ccell_next head) next)
)
let intro_llist_fragment_head_cons
#_ #a phead head next tl
=
let vc = gget (ccell head) in
let l' : (l' : Ghost.erased (list a) { Cons? l' }) = Ghost.hide (vc.vcell_data :: tl) in
intro_ccell_is_lvalue head;
intro_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l'));
intro_vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l')))
(llist_fragment_head tl (ccell_next head) next)
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l')));
llist_fragment_head_eq_cons l' phead head;
change_equal_slprop
(vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l')))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l'))))
(llist_fragment_head l' phead head);
l'
[@@erasable]
noeq
type ll_uncons_t
(a: Type)
= {
ll_uncons_pnext: Ghost.erased (ref (ccell_ptrvalue a));
ll_uncons_next: Ghost.erased (ccell_ptrvalue a);
ll_uncons_tl: Ghost.erased (list a);
}
val elim_llist_fragment_head_cons
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost (ll_uncons_t a) opened
(llist_fragment_head l phead head)
(fun res -> ccell head `star` llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next)
(fun _ -> Cons? (Ghost.reveal l))
(fun h res h' ->
ccell_ptrvalue_is_null head == false /\
Ghost.reveal l == (h' (ccell head)).vcell_data :: Ghost.reveal res.ll_uncons_tl /\
Ghost.reveal res.ll_uncons_pnext == ccell_next head /\
Ghost.reveal res.ll_uncons_next == (h' (ccell head)).vcell_next /\
h' (llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next) == h (llist_fragment_head l phead head)
)
let elim_llist_fragment_head_cons
#_ #a l0 phead head
=
let l : (l : Ghost.erased (list a) { Cons? l }) = l0 in
change_equal_slprop
(llist_fragment_head l0 phead head)
(llist_fragment_head l phead head);
llist_fragment_head_eq_cons l phead head;
change_equal_slprop
(llist_fragment_head l phead head)
(vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l)))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l))));
let x = elim_vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l)))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)))
in
let head2 = gget (ccell_is_lvalue head) in
elim_ccell_is_lvalue head;
elim_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l));
let vhead2 = gget (ccell head) in
let res = {
ll_uncons_pnext = ccell_next head2;
ll_uncons_next = vhead2.vcell_next;
ll_uncons_tl = L.tl l;
} in
change_equal_slprop
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)) (Ghost.reveal x))
(llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next);
res
let rec llist_fragment_head_append
(#opened: _)
(#a: Type)
(l1: Ghost.erased (list a))
(phead1: ref (ccell_ptrvalue a))
(head1: ccell_ptrvalue a)
(l2: Ghost.erased (list a))
(phead2: ref (ccell_ptrvalue a))
(head2: ccell_ptrvalue a)
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_head l1 phead1 head1 `star` llist_fragment_head l2 phead2 head2)
(fun l -> llist_fragment_head l phead1 head1)
(fun h -> sel_llist_fragment_head l1 phead1 head1 h == (Ghost.reveal phead2, Ghost.reveal head2))
(fun h l h' ->
Ghost.reveal l == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
h' (llist_fragment_head l phead1 head1) == h (llist_fragment_head l2 phead2 head2)
)
(decreases (Ghost.reveal l1))
=
if Nil? l1
then begin
elim_llist_fragment_head_nil l1 phead1 head1;
change_equal_slprop
(llist_fragment_head l2 phead2 head2)
(llist_fragment_head l2 phead1 head1);
l2
end else begin
let u = elim_llist_fragment_head_cons l1 phead1 head1 in
let head1' : Ghost.erased (ccell_lvalue a) = head1 in
let l3 = llist_fragment_head_append u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next l2 phead2 head2 in
change_equal_slprop
(llist_fragment_head l3 u.ll_uncons_pnext u.ll_uncons_next)
(llist_fragment_head l3 (ccell_next head1') u.ll_uncons_next);
change_equal_slprop
(ccell head1)
(ccell head1');
let l4 = intro_llist_fragment_head_cons phead1 head1' u.ll_uncons_next l3 in
change_equal_slprop
(llist_fragment_head l4 phead1 head1')
(llist_fragment_head l4 phead1 head1);
l4
end
let rec llist_fragment_head_to_tail
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(vptr phead `star` llist_fragment_head l phead head)
(fun res -> llist_fragment_tail l phead `star` vptr res)
(fun h -> h (vptr phead) == head)
(fun h res h' ->
let v = sel_llist_fragment_head l phead head h in
fst v == Ghost.reveal res /\
fst v == sel_llist_fragment_tail l phead h' /\
snd v == h' (vptr res)
)
(decreases (L.length (Ghost.reveal l)))
=
if Nil? l
then begin
let ptail = Ghost.hide phead in
let gh = gget (vptr phead) in
assert (Ghost.reveal gh == head);
elim_llist_fragment_head_nil l phead head;
intro_llist_fragment_tail_nil l phead;
change_equal_slprop
(vptr phead)
(vptr ptail);
ptail
end else begin
intro_llist_fragment_tail_nil [] phead;
change_equal_slprop
(vptr phead)
(vptr (Ghost.reveal (Ghost.hide phead)));
let uc = elim_llist_fragment_head_cons l phead head in
let head' = elim_ccell_ghost head in
change_equal_slprop
(vptr (ccell_next head'))
(vptr uc.ll_uncons_pnext);
let lc = intro_llist_fragment_tail_snoc [] phead phead head' in
let ptail = llist_fragment_head_to_tail
uc.ll_uncons_tl
uc.ll_uncons_pnext
uc.ll_uncons_next
in
let l' = llist_fragment_tail_append phead lc uc.ll_uncons_pnext uc.ll_uncons_tl in
change_equal_slprop
(llist_fragment_tail l' phead)
(llist_fragment_tail l phead);
ptail
end
#push-options "--z3rlimit 16"
#restart-solver
let rec llist_fragment_tail_to_head
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: ref (ccell_ptrvalue a))
: SteelGhost (Ghost.erased (ccell_ptrvalue a)) opened
(llist_fragment_tail l phead `star` vptr ptail)
(fun head -> vptr phead `star` llist_fragment_head l phead (Ghost.reveal head))
(fun h -> Ghost.reveal ptail == sel_llist_fragment_tail l phead h)
(fun h head h' ->
let v = sel_llist_fragment_head l phead head h' in
fst v == ptail /\
snd v == h (vptr ptail) /\
h' (vptr phead) == Ghost.reveal head
)
(decreases (L.length (Ghost.reveal l)))
=
if Nil? l
then begin
let g = gget (llist_fragment_tail l phead) in
assert (Ghost.reveal g == ptail);
elim_llist_fragment_tail_nil l phead;
change_equal_slprop
(vptr ptail)
(vptr phead);
let head = gget (vptr phead) in
intro_llist_fragment_head_nil l phead head;
head
end else begin
let us = elim_llist_fragment_tail_snoc l phead in
let tail = gget (vptr ptail) in
assert (ccell_next us.ll_unsnoc_tail == ptail);
intro_llist_fragment_head_nil [] (ccell_next us.ll_unsnoc_tail) tail;
change_equal_slprop
(vptr ptail)
(vptr (ccell_next us.ll_unsnoc_tail));
intro_ccell us.ll_unsnoc_tail;
let lc = intro_llist_fragment_head_cons us.ll_unsnoc_ptail us.ll_unsnoc_tail tail [] in
let head = llist_fragment_tail_to_head us.ll_unsnoc_l phead us.ll_unsnoc_ptail in
let g = gget (llist_fragment_head us.ll_unsnoc_l phead head) in
let g : Ghost.erased (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = Ghost.hide (Ghost.reveal g) in
assert (Ghost.reveal g == (Ghost.reveal us.ll_unsnoc_ptail, Ghost.reveal us.ll_unsnoc_tail));
let l' = llist_fragment_head_append us.ll_unsnoc_l phead head lc us.ll_unsnoc_ptail us.ll_unsnoc_tail in
change_equal_slprop
(llist_fragment_head l' phead head)
(llist_fragment_head l phead head);
head
end
#pop-options
val llist_fragment_head_is_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> llist_fragment_head l phead head)
(fun h -> ccell_ptrvalue_is_null (snd (sel_llist_fragment_head l phead head h)) == true)
(fun h _ h' ->
Nil? l == ccell_ptrvalue_is_null head /\
h' (llist_fragment_head l phead head) == h (llist_fragment_head l phead head)
)
let llist_fragment_head_is_nil
l phead head
=
if Nil? l
then begin
elim_llist_fragment_head_nil l phead head;
assert (ccell_ptrvalue_is_null head == true);
intro_llist_fragment_head_nil l phead head
end else begin
let r = elim_llist_fragment_head_cons l phead head in
let head2 : ccell_lvalue _ = head in
change_equal_slprop
(llist_fragment_head r.ll_uncons_tl r.ll_uncons_pnext r.ll_uncons_next)
(llist_fragment_head r.ll_uncons_tl (ccell_next head2) r.ll_uncons_next);
change_equal_slprop
(ccell head)
(ccell head2);
let l' = intro_llist_fragment_head_cons phead head2 r.ll_uncons_next r.ll_uncons_tl in
change_equal_slprop
(llist_fragment_head l' phead head2)
(llist_fragment_head l phead head)
end
val llist_fragment_head_cons_change_phead
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
(phead' : ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> llist_fragment_head l phead' head)
(fun _ -> Cons? l)
(fun h _ h' -> h' (llist_fragment_head l phead' head) == h (llist_fragment_head l phead head))
let llist_fragment_head_cons_change_phead
l phead head phead'
=
let u = elim_llist_fragment_head_cons l phead head in
let head2 : ccell_lvalue _ = head in
change_equal_slprop
(ccell head)
(ccell head2);
change_equal_slprop
(llist_fragment_head u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next)
(llist_fragment_head u.ll_uncons_tl (ccell_next head2) u.ll_uncons_next);
let l' = intro_llist_fragment_head_cons phead' head2 u.ll_uncons_next u.ll_uncons_tl in
change_equal_slprop
(llist_fragment_head l' phead' head2)
(llist_fragment_head l phead' head)
let queue_head_refine
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
(tl: ref (ccell_ptrvalue a))
: Tot prop
= let ptl : (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = ptl in
tl == fst ptl /\ ccell_ptrvalue_is_null (snd ptl) == true
let queue_head_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
: Tot vprop
= vptr (cllist_tail x) `vrefine` queue_head_refine x l hd ptl | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: CQueue.t a -> l: FStar.Ghost.erased (Prims.list a) -> hd: CQueue.Cell.ccell_ptrvalue a
-> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"CQueue.t",
"FStar.Ghost.erased",
"Prims.list",
"CQueue.Cell.ccell_ptrvalue",
"Steel.Effect.Common.vdep",
"CQueue.llist_fragment_head",
"CQueue.LList.cllist_head",
"CQueue.queue_head_dep1",
"Steel.Effect.Common.vprop"
] | [] | false | false | false | true | false | let queue_head_dep2 (#a: Type) (x: t a) (l: Ghost.erased (list a)) (hd: ccell_ptrvalue a)
: Tot vprop =
| (llist_fragment_head l (cllist_head x) hd) `vdep` (queue_head_dep1 x l hd) | false |
SelectorsLList3Example.fst | SelectorsLList3Example.tail | val tail (ptr: t)
: Steel (t)
(LL.llist ptr)
(fun n -> (vptr ptr) `star` (LL.llist n))
(requires fun _ -> ptr =!= null_llist ())
(ensures
fun h0 n h1 ->
Cons? (LL.v_llist ptr h0) /\ sel ptr h1 == mk_cell n (L.hd (LL.v_llist ptr h0)) /\
LL.v_llist n h1 == L.tl (LL.v_llist ptr h0)) | val tail (ptr: t)
: Steel (t)
(LL.llist ptr)
(fun n -> (vptr ptr) `star` (LL.llist n))
(requires fun _ -> ptr =!= null_llist ())
(ensures
fun h0 n h1 ->
Cons? (LL.v_llist ptr h0) /\ sel ptr h1 == mk_cell n (L.hd (LL.v_llist ptr h0)) /\
LL.v_llist n h1 == L.tl (LL.v_llist ptr h0)) | let tail (ptr:t)
: Steel (t) (LL.llist ptr)
(fun n -> vptr ptr `star` LL.llist n)
(requires fun _ -> ptr =!= null_llist ())
(ensures fun h0 n h1 ->
Cons? (LL.v_llist ptr h0) /\
sel ptr h1 == mk_cell n (L.hd (LL.v_llist ptr h0)) /\
LL.v_llist n h1 == L.tl (LL.v_llist ptr h0))
= LL.tail ptr | {
"file_name": "share/steel/examples/steel/llist3/SelectorsLList3Example.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 13,
"end_line": 60,
"start_col": 0,
"start_line": 52
} | module SelectorsLList3Example
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.ArrayRef
module L = FStar.List.Tot
module LL = Selectors.LList3
module U32 = FStar.UInt32
module MB = LowStar.Monotonic.Buffer // for is_null
inline_for_extraction noextract let a = U32.t
let cell = LL.cell a
/// The type of a list: A reference to a cell
let t = LL.t a
let next (c:cell) : t = LL.next c
let data (c:cell) : a = LL.data c
let mk_cell (n: t) (d:a)
: Pure cell
(requires True)
(ensures fun c ->
next c == n /\
data c == d)
= LL.mk_cell n d
/// The null list pointer
let null_llist () : t = LL.null_llist
/// Lifting the null pointer check to empty lists
let is_null (ptr:t) : (b:bool{b <==> ptr == null_llist ()})
= LL.is_null ptr
let is_nil (ptr:t)
: Steel bool (LL.llist ptr) (fun _ -> LL.llist ptr)
(requires fun _ -> True)
(ensures fun h0 res h1 ->
(res == true <==> ptr == null_llist ()) /\
LL.v_llist ptr h0 == LL.v_llist ptr h1 /\
res == Nil? (LL.v_llist ptr h1))
= LL.is_nil ptr
let intro_llist_cons (ptr1 ptr2:t)
: Steel unit (vptr ptr1 `star` LL.llist ptr2)
(fun _ -> LL.llist ptr1)
(requires fun h -> next (sel ptr1 h) == ptr2)
(ensures fun h0 _ h1 -> LL.v_llist ptr1 h1 == (data (sel ptr1 h0)) :: LL.v_llist ptr2 h0)
= LL.intro_llist_cons ptr1 ptr2 | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"Steel.ArrayRef.fsti.checked",
"Selectors.LList3.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "SelectorsLList3Example.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer // for is_null",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "Selectors.LList3",
"short_module": "LL"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.ArrayRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ptr: SelectorsLList3Example.t -> Steel.Effect.Steel SelectorsLList3Example.t | Steel.Effect.Steel | [] | [] | [
"SelectorsLList3Example.t",
"Selectors.LList3.tail",
"SelectorsLList3Example.a",
"Selectors.LList3.t",
"Selectors.LList3.llist",
"Steel.Effect.Common.star",
"Steel.ArrayRef.vptr",
"Selectors.LList3.cell",
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.rmem",
"Prims.l_not",
"Prims.eq2",
"SelectorsLList3Example.null_llist",
"Prims.l_and",
"Prims.b2t",
"Prims.uu___is_Cons",
"Selectors.LList3.v_llist",
"Steel.ArrayRef.sel",
"SelectorsLList3Example.mk_cell",
"FStar.List.Tot.Base.hd",
"Prims.list",
"FStar.List.Tot.Base.tl"
] | [] | false | true | false | false | false | let tail (ptr: t)
: Steel (t)
(LL.llist ptr)
(fun n -> (vptr ptr) `star` (LL.llist n))
(requires fun _ -> ptr =!= null_llist ())
(ensures
fun h0 n h1 ->
Cons? (LL.v_llist ptr h0) /\ sel ptr h1 == mk_cell n (L.hd (LL.v_llist ptr h0)) /\
LL.v_llist n h1 == L.tl (LL.v_llist ptr h0)) =
| LL.tail ptr | false |
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.is_machine_heap_update | val is_machine_heap_update : mh: Vale.Arch.MachineHeap_s.machine_heap -> mh': Vale.Arch.MachineHeap_s.machine_heap
-> Prims.logical | let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i) | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 19,
"start_col": 0,
"start_line": 16
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8 | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | mh: Vale.Arch.MachineHeap_s.machine_heap -> mh': Vale.Arch.MachineHeap_s.machine_heap
-> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.l_and",
"FStar.Set.equal",
"Prims.int",
"FStar.Map.domain",
"Vale.Def.Types_s.nat8",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_Negation",
"FStar.Map.contains",
"Prims.eq2",
"FStar.Map.sel",
"Prims.logical"
] | [] | false | false | false | true | true | let is_machine_heap_update (mh mh': machine_heap) =
| Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i: int). {:pattern Map.sel mh i\/Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i) | false |
|
CQueue.fst | CQueue.llist_fragment_tail_eq | val llist_fragment_tail_eq (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead ==
(if Nil? l
then vconst phead
else
((llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
`vdep`
(llist_fragment_tail_cons_next_payload l))
`vrewrite`
(llist_fragment_tail_cons_rewrite l
(llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)))) | val llist_fragment_tail_eq (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead ==
(if Nil? l
then vconst phead
else
((llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
`vdep`
(llist_fragment_tail_cons_next_payload l))
`vrewrite`
(llist_fragment_tail_cons_rewrite l
(llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)))) | let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)) | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 4,
"end_line": 407,
"start_col": 0,
"start_line": 394
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: FStar.Ghost.erased (Prims.list a) -> phead: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a)
-> FStar.Pervasives.Lemma
(ensures
CQueue.llist_fragment_tail l phead ==
(match Nil? (FStar.Ghost.reveal l) with
| true -> CQueue.vconst phead
| _ ->
Steel.Effect.Common.vrewrite (Steel.Effect.Common.vdep (CQueue.llist_fragment_tail (FStar.Ghost.hide
(CQueue.unsnoc_hd (FStar.Ghost.reveal l)))
phead)
(CQueue.llist_fragment_tail_cons_next_payload l))
(CQueue.llist_fragment_tail_cons_rewrite l
(CQueue.llist_fragment_tail (FStar.Ghost.hide (CQueue.unsnoc_hd (FStar.Ghost.reveal l
)))
phead)))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Ghost.erased",
"Prims.list",
"Steel.Reference.ref",
"CQueue.Cell.ccell_ptrvalue",
"FStar.Pervasives.assert_norm",
"CQueue.op_Equals_Equals",
"Steel.Effect.Common.vprop",
"CQueue.llist_fragment_tail",
"Prims.uu___is_Nil",
"FStar.Ghost.reveal",
"CQueue.vconst",
"Prims.bool",
"Steel.Effect.Common.vrewrite",
"Steel.Effect.Common.vdep",
"FStar.Ghost.hide",
"CQueue.unsnoc_hd",
"CQueue.llist_fragment_tail_cons_next_payload",
"CQueue.llist_fragment_tail_cons_rewrite",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let llist_fragment_tail_eq (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead ==
(if Nil? l
then vconst phead
else
((llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
`vdep`
(llist_fragment_tail_cons_next_payload l))
`vrewrite`
(llist_fragment_tail_cons_rewrite l
(llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)))) =
| assert_norm (llist_fragment_tail l phead ==
(if Nil? l
then vconst phead
else
((llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
`vdep`
(llist_fragment_tail_cons_next_payload l))
`vrewrite`
(llist_fragment_tail_cons_rewrite l
(llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)))) | false |
CQueue.fst | CQueue.queue | val queue (#a: Type) (x: t a) (l: Ghost.erased (v a)) : Tot vprop | val queue (#a: Type) (x: t a) (l: Ghost.erased (v a)) : Tot vprop | let queue x l = queue_head x l | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 30,
"end_line": 1290,
"start_col": 0,
"start_line": 1290
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end
let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2
[@@__steel_reduce__]
let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop
= vptr tail2 `vrefine` queue_tail_refine tail1 tail2
[@@__steel_reduce__]
let queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop
= vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1
[@@__steel_reduce__; __reduce__]
let queue_tail
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
=
llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l
val intro_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun _ -> queue_tail x l)
(fun h ->
sel_llist_fragment_tail l (cllist_head x) h == tail /\
sel (cllist_tail x) h == tail /\
ccell_ptrvalue_is_null (sel tail h)
)
(fun _ _ _ -> True)
let intro_queue_tail
x l tail
=
intro_vrefine (vptr tail) (queue_tail_refine tail tail);
intro_vdep2
(vptr (cllist_tail x))
(vptr tail `vrefine` queue_tail_refine tail tail)
tail
(queue_tail_dep2 x l tail);
intro_vdep2
(llist_fragment_tail l (cllist_head x))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail)
tail
(queue_tail_dep1 x l)
val elim_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(queue_tail x l)
(fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun h -> True)
(fun _ tail h ->
sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\
sel (cllist_tail x) h == Ghost.reveal tail /\
ccell_ptrvalue_is_null (h (vptr tail))
)
let elim_queue_tail
#_ #a x l
=
let tail0 = elim_vdep
(llist_fragment_tail l (cllist_head x))
(queue_tail_dep1 x l)
in
let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in
change_equal_slprop
(queue_tail_dep1 x l (Ghost.reveal tail0))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0);
let tail2 = elim_vdep
(vptr (cllist_tail x))
(queue_tail_dep2 x l tail0)
in
let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in
change_equal_slprop
(queue_tail_dep2 x l tail0 (Ghost.reveal tail2))
(vptr tail3 `vrefine` queue_tail_refine tail0 tail3);
elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3);
change_equal_slprop
(vptr tail3)
(vptr tail);
tail
(* view from the head *)
let llist_fragment_head_data_refine
(#a: Type)
(d: a)
(c: vcell a)
: Tot prop
= c.vcell_data == d
let llist_fragment_head_payload
(#a: Type)
(head: ccell_ptrvalue a)
(d: a)
(llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop))
(x: t_of (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine d)))
: Tot vprop
=
llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next
let rec llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Tot vprop
(decreases (Ghost.reveal l))
=
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
let t_of_llist_fragment_head
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(t_of (llist_fragment_head l phead head) == ref (ccell_ptrvalue a) & ccell_ptrvalue a)
= ()
unfold
let sel_llist_fragment_head
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_head l phead head) /\ True) })
: GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
=
coerce (h (llist_fragment_head l phead head)) (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
val intro_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_head l phead head)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_head l phead head h' == (phead, head))
let intro_llist_fragment_head_nil
l phead head
=
intro_vconst (phead, head);
change_equal_slprop
(vconst (phead, head))
(llist_fragment_head l phead head)
val elim_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_head l phead head h == (phead, head))
let elim_llist_fragment_head_nil
l phead head
=
change_equal_slprop
(llist_fragment_head l phead head)
(vconst (phead, head));
elim_vconst (phead, head)
let llist_fragment_head_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(requires (Cons? (Ghost.reveal l)))
(ensures (
llist_fragment_head l phead head ==
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
))
= assert_norm
(llist_fragment_head l phead head == (
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
))
val intro_llist_fragment_head_cons
(#opened: _)
(#a: Type) (phead: ref (ccell_ptrvalue a)) (head: ccell_lvalue a) (next: (ccell_ptrvalue a)) (tl: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(ccell head `star` llist_fragment_head tl (ccell_next head) next)
(fun res -> llist_fragment_head res phead head)
(fun h -> (h (ccell head)).vcell_next == next)
(fun h res h' ->
Ghost.reveal res == (h (ccell head)).vcell_data :: Ghost.reveal tl /\
h' (llist_fragment_head res phead head) == h (llist_fragment_head tl (ccell_next head) next)
)
let intro_llist_fragment_head_cons
#_ #a phead head next tl
=
let vc = gget (ccell head) in
let l' : (l' : Ghost.erased (list a) { Cons? l' }) = Ghost.hide (vc.vcell_data :: tl) in
intro_ccell_is_lvalue head;
intro_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l'));
intro_vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l')))
(llist_fragment_head tl (ccell_next head) next)
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l')));
llist_fragment_head_eq_cons l' phead head;
change_equal_slprop
(vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l')))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l'))))
(llist_fragment_head l' phead head);
l'
[@@erasable]
noeq
type ll_uncons_t
(a: Type)
= {
ll_uncons_pnext: Ghost.erased (ref (ccell_ptrvalue a));
ll_uncons_next: Ghost.erased (ccell_ptrvalue a);
ll_uncons_tl: Ghost.erased (list a);
}
val elim_llist_fragment_head_cons
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost (ll_uncons_t a) opened
(llist_fragment_head l phead head)
(fun res -> ccell head `star` llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next)
(fun _ -> Cons? (Ghost.reveal l))
(fun h res h' ->
ccell_ptrvalue_is_null head == false /\
Ghost.reveal l == (h' (ccell head)).vcell_data :: Ghost.reveal res.ll_uncons_tl /\
Ghost.reveal res.ll_uncons_pnext == ccell_next head /\
Ghost.reveal res.ll_uncons_next == (h' (ccell head)).vcell_next /\
h' (llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next) == h (llist_fragment_head l phead head)
)
let elim_llist_fragment_head_cons
#_ #a l0 phead head
=
let l : (l : Ghost.erased (list a) { Cons? l }) = l0 in
change_equal_slprop
(llist_fragment_head l0 phead head)
(llist_fragment_head l phead head);
llist_fragment_head_eq_cons l phead head;
change_equal_slprop
(llist_fragment_head l phead head)
(vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l)))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l))));
let x = elim_vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l)))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)))
in
let head2 = gget (ccell_is_lvalue head) in
elim_ccell_is_lvalue head;
elim_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l));
let vhead2 = gget (ccell head) in
let res = {
ll_uncons_pnext = ccell_next head2;
ll_uncons_next = vhead2.vcell_next;
ll_uncons_tl = L.tl l;
} in
change_equal_slprop
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)) (Ghost.reveal x))
(llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next);
res
let rec llist_fragment_head_append
(#opened: _)
(#a: Type)
(l1: Ghost.erased (list a))
(phead1: ref (ccell_ptrvalue a))
(head1: ccell_ptrvalue a)
(l2: Ghost.erased (list a))
(phead2: ref (ccell_ptrvalue a))
(head2: ccell_ptrvalue a)
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_head l1 phead1 head1 `star` llist_fragment_head l2 phead2 head2)
(fun l -> llist_fragment_head l phead1 head1)
(fun h -> sel_llist_fragment_head l1 phead1 head1 h == (Ghost.reveal phead2, Ghost.reveal head2))
(fun h l h' ->
Ghost.reveal l == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
h' (llist_fragment_head l phead1 head1) == h (llist_fragment_head l2 phead2 head2)
)
(decreases (Ghost.reveal l1))
=
if Nil? l1
then begin
elim_llist_fragment_head_nil l1 phead1 head1;
change_equal_slprop
(llist_fragment_head l2 phead2 head2)
(llist_fragment_head l2 phead1 head1);
l2
end else begin
let u = elim_llist_fragment_head_cons l1 phead1 head1 in
let head1' : Ghost.erased (ccell_lvalue a) = head1 in
let l3 = llist_fragment_head_append u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next l2 phead2 head2 in
change_equal_slprop
(llist_fragment_head l3 u.ll_uncons_pnext u.ll_uncons_next)
(llist_fragment_head l3 (ccell_next head1') u.ll_uncons_next);
change_equal_slprop
(ccell head1)
(ccell head1');
let l4 = intro_llist_fragment_head_cons phead1 head1' u.ll_uncons_next l3 in
change_equal_slprop
(llist_fragment_head l4 phead1 head1')
(llist_fragment_head l4 phead1 head1);
l4
end
let rec llist_fragment_head_to_tail
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(vptr phead `star` llist_fragment_head l phead head)
(fun res -> llist_fragment_tail l phead `star` vptr res)
(fun h -> h (vptr phead) == head)
(fun h res h' ->
let v = sel_llist_fragment_head l phead head h in
fst v == Ghost.reveal res /\
fst v == sel_llist_fragment_tail l phead h' /\
snd v == h' (vptr res)
)
(decreases (L.length (Ghost.reveal l)))
=
if Nil? l
then begin
let ptail = Ghost.hide phead in
let gh = gget (vptr phead) in
assert (Ghost.reveal gh == head);
elim_llist_fragment_head_nil l phead head;
intro_llist_fragment_tail_nil l phead;
change_equal_slprop
(vptr phead)
(vptr ptail);
ptail
end else begin
intro_llist_fragment_tail_nil [] phead;
change_equal_slprop
(vptr phead)
(vptr (Ghost.reveal (Ghost.hide phead)));
let uc = elim_llist_fragment_head_cons l phead head in
let head' = elim_ccell_ghost head in
change_equal_slprop
(vptr (ccell_next head'))
(vptr uc.ll_uncons_pnext);
let lc = intro_llist_fragment_tail_snoc [] phead phead head' in
let ptail = llist_fragment_head_to_tail
uc.ll_uncons_tl
uc.ll_uncons_pnext
uc.ll_uncons_next
in
let l' = llist_fragment_tail_append phead lc uc.ll_uncons_pnext uc.ll_uncons_tl in
change_equal_slprop
(llist_fragment_tail l' phead)
(llist_fragment_tail l phead);
ptail
end
#push-options "--z3rlimit 16"
#restart-solver
let rec llist_fragment_tail_to_head
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: ref (ccell_ptrvalue a))
: SteelGhost (Ghost.erased (ccell_ptrvalue a)) opened
(llist_fragment_tail l phead `star` vptr ptail)
(fun head -> vptr phead `star` llist_fragment_head l phead (Ghost.reveal head))
(fun h -> Ghost.reveal ptail == sel_llist_fragment_tail l phead h)
(fun h head h' ->
let v = sel_llist_fragment_head l phead head h' in
fst v == ptail /\
snd v == h (vptr ptail) /\
h' (vptr phead) == Ghost.reveal head
)
(decreases (L.length (Ghost.reveal l)))
=
if Nil? l
then begin
let g = gget (llist_fragment_tail l phead) in
assert (Ghost.reveal g == ptail);
elim_llist_fragment_tail_nil l phead;
change_equal_slprop
(vptr ptail)
(vptr phead);
let head = gget (vptr phead) in
intro_llist_fragment_head_nil l phead head;
head
end else begin
let us = elim_llist_fragment_tail_snoc l phead in
let tail = gget (vptr ptail) in
assert (ccell_next us.ll_unsnoc_tail == ptail);
intro_llist_fragment_head_nil [] (ccell_next us.ll_unsnoc_tail) tail;
change_equal_slprop
(vptr ptail)
(vptr (ccell_next us.ll_unsnoc_tail));
intro_ccell us.ll_unsnoc_tail;
let lc = intro_llist_fragment_head_cons us.ll_unsnoc_ptail us.ll_unsnoc_tail tail [] in
let head = llist_fragment_tail_to_head us.ll_unsnoc_l phead us.ll_unsnoc_ptail in
let g = gget (llist_fragment_head us.ll_unsnoc_l phead head) in
let g : Ghost.erased (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = Ghost.hide (Ghost.reveal g) in
assert (Ghost.reveal g == (Ghost.reveal us.ll_unsnoc_ptail, Ghost.reveal us.ll_unsnoc_tail));
let l' = llist_fragment_head_append us.ll_unsnoc_l phead head lc us.ll_unsnoc_ptail us.ll_unsnoc_tail in
change_equal_slprop
(llist_fragment_head l' phead head)
(llist_fragment_head l phead head);
head
end
#pop-options
val llist_fragment_head_is_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> llist_fragment_head l phead head)
(fun h -> ccell_ptrvalue_is_null (snd (sel_llist_fragment_head l phead head h)) == true)
(fun h _ h' ->
Nil? l == ccell_ptrvalue_is_null head /\
h' (llist_fragment_head l phead head) == h (llist_fragment_head l phead head)
)
let llist_fragment_head_is_nil
l phead head
=
if Nil? l
then begin
elim_llist_fragment_head_nil l phead head;
assert (ccell_ptrvalue_is_null head == true);
intro_llist_fragment_head_nil l phead head
end else begin
let r = elim_llist_fragment_head_cons l phead head in
let head2 : ccell_lvalue _ = head in
change_equal_slprop
(llist_fragment_head r.ll_uncons_tl r.ll_uncons_pnext r.ll_uncons_next)
(llist_fragment_head r.ll_uncons_tl (ccell_next head2) r.ll_uncons_next);
change_equal_slprop
(ccell head)
(ccell head2);
let l' = intro_llist_fragment_head_cons phead head2 r.ll_uncons_next r.ll_uncons_tl in
change_equal_slprop
(llist_fragment_head l' phead head2)
(llist_fragment_head l phead head)
end
val llist_fragment_head_cons_change_phead
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
(phead' : ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> llist_fragment_head l phead' head)
(fun _ -> Cons? l)
(fun h _ h' -> h' (llist_fragment_head l phead' head) == h (llist_fragment_head l phead head))
let llist_fragment_head_cons_change_phead
l phead head phead'
=
let u = elim_llist_fragment_head_cons l phead head in
let head2 : ccell_lvalue _ = head in
change_equal_slprop
(ccell head)
(ccell head2);
change_equal_slprop
(llist_fragment_head u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next)
(llist_fragment_head u.ll_uncons_tl (ccell_next head2) u.ll_uncons_next);
let l' = intro_llist_fragment_head_cons phead' head2 u.ll_uncons_next u.ll_uncons_tl in
change_equal_slprop
(llist_fragment_head l' phead' head2)
(llist_fragment_head l phead' head)
let queue_head_refine
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
(tl: ref (ccell_ptrvalue a))
: Tot prop
= let ptl : (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = ptl in
tl == fst ptl /\ ccell_ptrvalue_is_null (snd ptl) == true
let queue_head_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
: Tot vprop
= vptr (cllist_tail x) `vrefine` queue_head_refine x l hd ptl
let queue_head_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
: Tot vprop
= llist_fragment_head l (cllist_head x) hd `vdep` queue_head_dep1 x l hd
[@@__reduce__]
let queue_head
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
= vptr (cllist_head x) `vdep` queue_head_dep2 x l
val intro_queue_head
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: Ghost.erased (ccell_ptrvalue a))
: SteelGhost unit opened
(vptr (cllist_head x) `star` llist_fragment_head l (cllist_head x) hd `star` vptr (cllist_tail x))
(fun _ -> queue_head x l)
(fun h -> (
let frag = (sel_llist_fragment_head l (cllist_head x) hd) h in
sel (cllist_head x) h == Ghost.reveal hd /\
sel (cllist_tail x) h == fst frag /\
ccell_ptrvalue_is_null (snd frag) == true
))
(fun _ _ _ -> True)
let intro_queue_head
#_ #a x l hd
=
let ptl = gget (llist_fragment_head l (cllist_head x) hd) in
intro_vrefine
(vptr (cllist_tail x))
(queue_head_refine x l hd ptl);
assert_norm (vptr (cllist_tail x) `vrefine` queue_head_refine x l hd ptl == queue_head_dep1 x l hd ptl);
intro_vdep
(llist_fragment_head l (cllist_head x) hd)
(vptr (cllist_tail x) `vrefine` queue_head_refine x l hd ptl)
(queue_head_dep1 x l hd);
intro_vdep
(vptr (cllist_head x))
(llist_fragment_head l (cllist_head x) hd `vdep` queue_head_dep1 x l hd)
(queue_head_dep2 x l)
val elim_queue_head
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhost (Ghost.erased (ccell_ptrvalue a)) opened
(queue_head x l)
(fun hd -> vptr (cllist_head x) `star` llist_fragment_head l (cllist_head x) hd `star` vptr (cllist_tail x))
(fun _ -> True)
(fun _ hd h -> (
let frag = (sel_llist_fragment_head l (cllist_head x) hd) h in
sel (cllist_head x) h == Ghost.reveal hd /\
sel (cllist_tail x) h == fst frag /\
ccell_ptrvalue_is_null (snd frag) == true
))
let elim_queue_head
#_ #a x l
=
let hd = elim_vdep
(vptr (cllist_head x))
(queue_head_dep2 x l)
in
let ptl = elim_vdep
(llist_fragment_head l (cllist_head x) hd)
(queue_head_dep1 x l hd)
in
elim_vrefine
(vptr (cllist_tail x))
(queue_head_refine x l hd ptl);
hd
let queue_head_to_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhostT unit opened
(queue_head x l)
(fun _ -> queue_tail x l)
=
let hd = elim_queue_head x l in
let tl = llist_fragment_head_to_tail l (cllist_head x) hd in
intro_queue_tail x l tl
let queue_tail_to_head
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhostT unit opened
(queue_tail x l)
(fun _ -> queue_head x l)
=
let tl = elim_queue_tail x l in
let hd = llist_fragment_tail_to_head l (cllist_head x) tl in
intro_queue_head x l hd
(* We choose the head representation, since queue_is_empty and dequeue
need the head representation, but only enqueue needs the tail
representation. *) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: CQueue.t a -> l: FStar.Ghost.erased (CQueue.v a) -> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"CQueue.t",
"FStar.Ghost.erased",
"CQueue.v",
"CQueue.queue_head",
"Steel.Effect.Common.vprop"
] | [] | false | false | false | true | false | let queue x l =
| queue_head x l | false |
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.get_heap_val32 | val get_heap_val32 : _: Prims.int -> _: Vale.Arch.MachineHeap_s.machine_heap -> Vale.Def.Types_s.nat32 | let get_heap_val32 = opaque_make get_heap_val32_def | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 70,
"end_line": 28,
"start_col": 19,
"start_line": 28
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2] | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.int -> _: Vale.Arch.MachineHeap_s.machine_heap -> Vale.Def.Types_s.nat32 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Prims.int",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Def.Types_s.nat32",
"Vale.Arch.MachineHeap_s.get_heap_val32_def"
] | [] | false | false | false | true | false | let get_heap_val32 =
| opaque_make get_heap_val32_def | false |
|
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.get_heap_val32_reveal | val get_heap_val32_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.Arch.MachineHeap_s.get_heap_val32 == Vale.Arch.MachineHeap_s.get_heap_val32_def) | let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 108,
"end_line": 29,
"start_col": 12,
"start_line": 29
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3]) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.Arch.MachineHeap_s.get_heap_val32 == Vale.Arch.MachineHeap_s.get_heap_val32_def) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Prims.int",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Def.Types_s.nat32",
"Vale.Arch.MachineHeap_s.get_heap_val32",
"Vale.Arch.MachineHeap_s.get_heap_val32_def"
] | [] | true | false | true | false | false | let get_heap_val32_reveal =
| opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def | false |
|
CQueue.fst | CQueue.sel_llist_fragment_tail | val sel_llist_fragment_tail
(#a: Type)
(#p: vprop)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(h:
rmem p
{ FStar.Tactics.with_tactic selector_tactic
(can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a)) | val sel_llist_fragment_tail
(#a: Type)
(#p: vprop)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(h:
rmem p
{ FStar.Tactics.with_tactic selector_tactic
(can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a)) | let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a)) | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 67,
"end_line": 426,
"start_col": 0,
"start_line": 420
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
l: FStar.Ghost.erased (Prims.list a) ->
phead: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) ->
h:
Steel.Effect.Common.rmem p
{ FStar.Tactics.Effect.with_tactic Steel.Effect.Common.selector_tactic
(Steel.Effect.Common.can_be_split p (CQueue.llist_fragment_tail l phead) /\ Prims.l_True
) }
-> Prims.GTot (Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a)) | Prims.GTot | [
"sometrivial"
] | [] | [
"Steel.Effect.Common.vprop",
"FStar.Ghost.erased",
"Prims.list",
"Steel.Reference.ref",
"CQueue.Cell.ccell_ptrvalue",
"Steel.Effect.Common.rmem",
"FStar.Tactics.Effect.with_tactic",
"Steel.Effect.Common.selector_tactic",
"Prims.l_and",
"Steel.Effect.Common.can_be_split",
"CQueue.llist_fragment_tail",
"Prims.l_True",
"CQueue.coerce",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.t_of"
] | [] | false | false | false | false | false | let sel_llist_fragment_tail
(#a: Type)
(#p: vprop)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(h:
rmem p
{ FStar.Tactics.with_tactic selector_tactic
(can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a)) =
| coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a)) | false |
CQueue.fst | CQueue.queue_head | val queue_head (#a: Type) (x: t a) (l: Ghost.erased (list a)) : Tot vprop | val queue_head (#a: Type) (x: t a) (l: Ghost.erased (list a)) : Tot vprop | let queue_head
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
= vptr (cllist_head x) `vdep` queue_head_dep2 x l | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 49,
"end_line": 1191,
"start_col": 0,
"start_line": 1186
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end
let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2
[@@__steel_reduce__]
let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop
= vptr tail2 `vrefine` queue_tail_refine tail1 tail2
[@@__steel_reduce__]
let queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop
= vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1
[@@__steel_reduce__; __reduce__]
let queue_tail
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
=
llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l
val intro_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun _ -> queue_tail x l)
(fun h ->
sel_llist_fragment_tail l (cllist_head x) h == tail /\
sel (cllist_tail x) h == tail /\
ccell_ptrvalue_is_null (sel tail h)
)
(fun _ _ _ -> True)
let intro_queue_tail
x l tail
=
intro_vrefine (vptr tail) (queue_tail_refine tail tail);
intro_vdep2
(vptr (cllist_tail x))
(vptr tail `vrefine` queue_tail_refine tail tail)
tail
(queue_tail_dep2 x l tail);
intro_vdep2
(llist_fragment_tail l (cllist_head x))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail)
tail
(queue_tail_dep1 x l)
val elim_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(queue_tail x l)
(fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun h -> True)
(fun _ tail h ->
sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\
sel (cllist_tail x) h == Ghost.reveal tail /\
ccell_ptrvalue_is_null (h (vptr tail))
)
let elim_queue_tail
#_ #a x l
=
let tail0 = elim_vdep
(llist_fragment_tail l (cllist_head x))
(queue_tail_dep1 x l)
in
let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in
change_equal_slprop
(queue_tail_dep1 x l (Ghost.reveal tail0))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0);
let tail2 = elim_vdep
(vptr (cllist_tail x))
(queue_tail_dep2 x l tail0)
in
let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in
change_equal_slprop
(queue_tail_dep2 x l tail0 (Ghost.reveal tail2))
(vptr tail3 `vrefine` queue_tail_refine tail0 tail3);
elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3);
change_equal_slprop
(vptr tail3)
(vptr tail);
tail
(* view from the head *)
let llist_fragment_head_data_refine
(#a: Type)
(d: a)
(c: vcell a)
: Tot prop
= c.vcell_data == d
let llist_fragment_head_payload
(#a: Type)
(head: ccell_ptrvalue a)
(d: a)
(llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop))
(x: t_of (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine d)))
: Tot vprop
=
llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next
let rec llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Tot vprop
(decreases (Ghost.reveal l))
=
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
let t_of_llist_fragment_head
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(t_of (llist_fragment_head l phead head) == ref (ccell_ptrvalue a) & ccell_ptrvalue a)
= ()
unfold
let sel_llist_fragment_head
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_head l phead head) /\ True) })
: GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
=
coerce (h (llist_fragment_head l phead head)) (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
val intro_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_head l phead head)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_head l phead head h' == (phead, head))
let intro_llist_fragment_head_nil
l phead head
=
intro_vconst (phead, head);
change_equal_slprop
(vconst (phead, head))
(llist_fragment_head l phead head)
val elim_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_head l phead head h == (phead, head))
let elim_llist_fragment_head_nil
l phead head
=
change_equal_slprop
(llist_fragment_head l phead head)
(vconst (phead, head));
elim_vconst (phead, head)
let llist_fragment_head_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(requires (Cons? (Ghost.reveal l)))
(ensures (
llist_fragment_head l phead head ==
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
))
= assert_norm
(llist_fragment_head l phead head == (
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
))
val intro_llist_fragment_head_cons
(#opened: _)
(#a: Type) (phead: ref (ccell_ptrvalue a)) (head: ccell_lvalue a) (next: (ccell_ptrvalue a)) (tl: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(ccell head `star` llist_fragment_head tl (ccell_next head) next)
(fun res -> llist_fragment_head res phead head)
(fun h -> (h (ccell head)).vcell_next == next)
(fun h res h' ->
Ghost.reveal res == (h (ccell head)).vcell_data :: Ghost.reveal tl /\
h' (llist_fragment_head res phead head) == h (llist_fragment_head tl (ccell_next head) next)
)
let intro_llist_fragment_head_cons
#_ #a phead head next tl
=
let vc = gget (ccell head) in
let l' : (l' : Ghost.erased (list a) { Cons? l' }) = Ghost.hide (vc.vcell_data :: tl) in
intro_ccell_is_lvalue head;
intro_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l'));
intro_vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l')))
(llist_fragment_head tl (ccell_next head) next)
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l')));
llist_fragment_head_eq_cons l' phead head;
change_equal_slprop
(vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l')))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l'))))
(llist_fragment_head l' phead head);
l'
[@@erasable]
noeq
type ll_uncons_t
(a: Type)
= {
ll_uncons_pnext: Ghost.erased (ref (ccell_ptrvalue a));
ll_uncons_next: Ghost.erased (ccell_ptrvalue a);
ll_uncons_tl: Ghost.erased (list a);
}
val elim_llist_fragment_head_cons
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost (ll_uncons_t a) opened
(llist_fragment_head l phead head)
(fun res -> ccell head `star` llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next)
(fun _ -> Cons? (Ghost.reveal l))
(fun h res h' ->
ccell_ptrvalue_is_null head == false /\
Ghost.reveal l == (h' (ccell head)).vcell_data :: Ghost.reveal res.ll_uncons_tl /\
Ghost.reveal res.ll_uncons_pnext == ccell_next head /\
Ghost.reveal res.ll_uncons_next == (h' (ccell head)).vcell_next /\
h' (llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next) == h (llist_fragment_head l phead head)
)
let elim_llist_fragment_head_cons
#_ #a l0 phead head
=
let l : (l : Ghost.erased (list a) { Cons? l }) = l0 in
change_equal_slprop
(llist_fragment_head l0 phead head)
(llist_fragment_head l phead head);
llist_fragment_head_eq_cons l phead head;
change_equal_slprop
(llist_fragment_head l phead head)
(vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l)))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l))));
let x = elim_vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l)))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)))
in
let head2 = gget (ccell_is_lvalue head) in
elim_ccell_is_lvalue head;
elim_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l));
let vhead2 = gget (ccell head) in
let res = {
ll_uncons_pnext = ccell_next head2;
ll_uncons_next = vhead2.vcell_next;
ll_uncons_tl = L.tl l;
} in
change_equal_slprop
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)) (Ghost.reveal x))
(llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next);
res
let rec llist_fragment_head_append
(#opened: _)
(#a: Type)
(l1: Ghost.erased (list a))
(phead1: ref (ccell_ptrvalue a))
(head1: ccell_ptrvalue a)
(l2: Ghost.erased (list a))
(phead2: ref (ccell_ptrvalue a))
(head2: ccell_ptrvalue a)
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_head l1 phead1 head1 `star` llist_fragment_head l2 phead2 head2)
(fun l -> llist_fragment_head l phead1 head1)
(fun h -> sel_llist_fragment_head l1 phead1 head1 h == (Ghost.reveal phead2, Ghost.reveal head2))
(fun h l h' ->
Ghost.reveal l == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
h' (llist_fragment_head l phead1 head1) == h (llist_fragment_head l2 phead2 head2)
)
(decreases (Ghost.reveal l1))
=
if Nil? l1
then begin
elim_llist_fragment_head_nil l1 phead1 head1;
change_equal_slprop
(llist_fragment_head l2 phead2 head2)
(llist_fragment_head l2 phead1 head1);
l2
end else begin
let u = elim_llist_fragment_head_cons l1 phead1 head1 in
let head1' : Ghost.erased (ccell_lvalue a) = head1 in
let l3 = llist_fragment_head_append u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next l2 phead2 head2 in
change_equal_slprop
(llist_fragment_head l3 u.ll_uncons_pnext u.ll_uncons_next)
(llist_fragment_head l3 (ccell_next head1') u.ll_uncons_next);
change_equal_slprop
(ccell head1)
(ccell head1');
let l4 = intro_llist_fragment_head_cons phead1 head1' u.ll_uncons_next l3 in
change_equal_slprop
(llist_fragment_head l4 phead1 head1')
(llist_fragment_head l4 phead1 head1);
l4
end
let rec llist_fragment_head_to_tail
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(vptr phead `star` llist_fragment_head l phead head)
(fun res -> llist_fragment_tail l phead `star` vptr res)
(fun h -> h (vptr phead) == head)
(fun h res h' ->
let v = sel_llist_fragment_head l phead head h in
fst v == Ghost.reveal res /\
fst v == sel_llist_fragment_tail l phead h' /\
snd v == h' (vptr res)
)
(decreases (L.length (Ghost.reveal l)))
=
if Nil? l
then begin
let ptail = Ghost.hide phead in
let gh = gget (vptr phead) in
assert (Ghost.reveal gh == head);
elim_llist_fragment_head_nil l phead head;
intro_llist_fragment_tail_nil l phead;
change_equal_slprop
(vptr phead)
(vptr ptail);
ptail
end else begin
intro_llist_fragment_tail_nil [] phead;
change_equal_slprop
(vptr phead)
(vptr (Ghost.reveal (Ghost.hide phead)));
let uc = elim_llist_fragment_head_cons l phead head in
let head' = elim_ccell_ghost head in
change_equal_slprop
(vptr (ccell_next head'))
(vptr uc.ll_uncons_pnext);
let lc = intro_llist_fragment_tail_snoc [] phead phead head' in
let ptail = llist_fragment_head_to_tail
uc.ll_uncons_tl
uc.ll_uncons_pnext
uc.ll_uncons_next
in
let l' = llist_fragment_tail_append phead lc uc.ll_uncons_pnext uc.ll_uncons_tl in
change_equal_slprop
(llist_fragment_tail l' phead)
(llist_fragment_tail l phead);
ptail
end
#push-options "--z3rlimit 16"
#restart-solver
let rec llist_fragment_tail_to_head
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: ref (ccell_ptrvalue a))
: SteelGhost (Ghost.erased (ccell_ptrvalue a)) opened
(llist_fragment_tail l phead `star` vptr ptail)
(fun head -> vptr phead `star` llist_fragment_head l phead (Ghost.reveal head))
(fun h -> Ghost.reveal ptail == sel_llist_fragment_tail l phead h)
(fun h head h' ->
let v = sel_llist_fragment_head l phead head h' in
fst v == ptail /\
snd v == h (vptr ptail) /\
h' (vptr phead) == Ghost.reveal head
)
(decreases (L.length (Ghost.reveal l)))
=
if Nil? l
then begin
let g = gget (llist_fragment_tail l phead) in
assert (Ghost.reveal g == ptail);
elim_llist_fragment_tail_nil l phead;
change_equal_slprop
(vptr ptail)
(vptr phead);
let head = gget (vptr phead) in
intro_llist_fragment_head_nil l phead head;
head
end else begin
let us = elim_llist_fragment_tail_snoc l phead in
let tail = gget (vptr ptail) in
assert (ccell_next us.ll_unsnoc_tail == ptail);
intro_llist_fragment_head_nil [] (ccell_next us.ll_unsnoc_tail) tail;
change_equal_slprop
(vptr ptail)
(vptr (ccell_next us.ll_unsnoc_tail));
intro_ccell us.ll_unsnoc_tail;
let lc = intro_llist_fragment_head_cons us.ll_unsnoc_ptail us.ll_unsnoc_tail tail [] in
let head = llist_fragment_tail_to_head us.ll_unsnoc_l phead us.ll_unsnoc_ptail in
let g = gget (llist_fragment_head us.ll_unsnoc_l phead head) in
let g : Ghost.erased (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = Ghost.hide (Ghost.reveal g) in
assert (Ghost.reveal g == (Ghost.reveal us.ll_unsnoc_ptail, Ghost.reveal us.ll_unsnoc_tail));
let l' = llist_fragment_head_append us.ll_unsnoc_l phead head lc us.ll_unsnoc_ptail us.ll_unsnoc_tail in
change_equal_slprop
(llist_fragment_head l' phead head)
(llist_fragment_head l phead head);
head
end
#pop-options
val llist_fragment_head_is_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> llist_fragment_head l phead head)
(fun h -> ccell_ptrvalue_is_null (snd (sel_llist_fragment_head l phead head h)) == true)
(fun h _ h' ->
Nil? l == ccell_ptrvalue_is_null head /\
h' (llist_fragment_head l phead head) == h (llist_fragment_head l phead head)
)
let llist_fragment_head_is_nil
l phead head
=
if Nil? l
then begin
elim_llist_fragment_head_nil l phead head;
assert (ccell_ptrvalue_is_null head == true);
intro_llist_fragment_head_nil l phead head
end else begin
let r = elim_llist_fragment_head_cons l phead head in
let head2 : ccell_lvalue _ = head in
change_equal_slprop
(llist_fragment_head r.ll_uncons_tl r.ll_uncons_pnext r.ll_uncons_next)
(llist_fragment_head r.ll_uncons_tl (ccell_next head2) r.ll_uncons_next);
change_equal_slprop
(ccell head)
(ccell head2);
let l' = intro_llist_fragment_head_cons phead head2 r.ll_uncons_next r.ll_uncons_tl in
change_equal_slprop
(llist_fragment_head l' phead head2)
(llist_fragment_head l phead head)
end
val llist_fragment_head_cons_change_phead
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
(phead' : ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> llist_fragment_head l phead' head)
(fun _ -> Cons? l)
(fun h _ h' -> h' (llist_fragment_head l phead' head) == h (llist_fragment_head l phead head))
let llist_fragment_head_cons_change_phead
l phead head phead'
=
let u = elim_llist_fragment_head_cons l phead head in
let head2 : ccell_lvalue _ = head in
change_equal_slprop
(ccell head)
(ccell head2);
change_equal_slprop
(llist_fragment_head u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next)
(llist_fragment_head u.ll_uncons_tl (ccell_next head2) u.ll_uncons_next);
let l' = intro_llist_fragment_head_cons phead' head2 u.ll_uncons_next u.ll_uncons_tl in
change_equal_slprop
(llist_fragment_head l' phead' head2)
(llist_fragment_head l phead' head)
let queue_head_refine
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
(tl: ref (ccell_ptrvalue a))
: Tot prop
= let ptl : (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = ptl in
tl == fst ptl /\ ccell_ptrvalue_is_null (snd ptl) == true
let queue_head_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
: Tot vprop
= vptr (cllist_tail x) `vrefine` queue_head_refine x l hd ptl
let queue_head_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
: Tot vprop
= llist_fragment_head l (cllist_head x) hd `vdep` queue_head_dep1 x l hd | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: CQueue.t a -> l: FStar.Ghost.erased (Prims.list a) -> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"CQueue.t",
"FStar.Ghost.erased",
"Prims.list",
"Steel.Effect.Common.vdep",
"Steel.Reference.vptr",
"CQueue.Cell.ccell_ptrvalue",
"CQueue.LList.cllist_head",
"CQueue.queue_head_dep2",
"Steel.Effect.Common.vprop"
] | [] | false | false | false | true | false | let queue_head (#a: Type) (x: t a) (l: Ghost.erased (list a)) : Tot vprop =
| (vptr (cllist_head x)) `vdep` (queue_head_dep2 x l) | false |
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.get_heap_val64 | val get_heap_val64 : _: Prims.int -> _: Vale.Arch.MachineHeap_s.machine_heap -> Vale.Def.Types_s.nat64 | let get_heap_val64 = opaque_make get_heap_val64_def | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 70,
"end_line": 37,
"start_col": 19,
"start_line": 37
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7])) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.int -> _: Vale.Arch.MachineHeap_s.machine_heap -> Vale.Def.Types_s.nat64 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Prims.int",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Def.Types_s.nat64",
"Vale.Arch.MachineHeap_s.get_heap_val64_def"
] | [] | false | false | false | true | false | let get_heap_val64 =
| opaque_make get_heap_val64_def | false |
|
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.get_heap_val128 | val get_heap_val128 : _: Prims.int -> _: Vale.Arch.MachineHeap_s.machine_heap -> Vale.Def.Types_s.quad32 | let get_heap_val128 = opaque_make get_heap_val128_def | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 72,
"end_line": 45,
"start_col": 19,
"start_line": 45
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
)
[@"opaque_to_smt"] let get_heap_val64 = opaque_make get_heap_val64_def
irreducible let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def
let get_heap_val128_def (ptr:int) (mem:machine_heap) : quad32 = Mkfour
(get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.int -> _: Vale.Arch.MachineHeap_s.machine_heap -> Vale.Def.Types_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Prims.int",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Def.Types_s.quad32",
"Vale.Arch.MachineHeap_s.get_heap_val128_def"
] | [] | false | false | false | true | false | let get_heap_val128 =
| opaque_make get_heap_val128_def | false |
|
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.get_heap_val64_reveal | val get_heap_val64_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.Arch.MachineHeap_s.get_heap_val64 == Vale.Arch.MachineHeap_s.get_heap_val64_def) | let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 108,
"end_line": 38,
"start_col": 12,
"start_line": 38
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.Arch.MachineHeap_s.get_heap_val64 == Vale.Arch.MachineHeap_s.get_heap_val64_def) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Prims.int",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Def.Types_s.nat64",
"Vale.Arch.MachineHeap_s.get_heap_val64",
"Vale.Arch.MachineHeap_s.get_heap_val64_def"
] | [] | true | false | true | false | false | let get_heap_val64_reveal =
| opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def | false |
|
CQueue.fst | CQueue.llist_fragment_tail_eq_cons | val llist_fragment_tail_eq_cons
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: Lemma (requires (Cons? l))
(ensures
(Cons? l /\
llist_fragment_tail l phead ==
(((llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
`vdep`
(llist_fragment_tail_cons_next_payload l))
`vrewrite`
(llist_fragment_tail_cons_rewrite l
(llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead))))) | val llist_fragment_tail_eq_cons
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: Lemma (requires (Cons? l))
(ensures
(Cons? l /\
llist_fragment_tail l phead ==
(((llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
`vdep`
(llist_fragment_tail_cons_next_payload l))
`vrewrite`
(llist_fragment_tail_cons_rewrite l
(llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead))))) | let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 32,
"end_line": 417,
"start_col": 0,
"start_line": 409
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: FStar.Ghost.erased (Prims.list a) -> phead: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a)
-> FStar.Pervasives.Lemma (requires Cons? (FStar.Ghost.reveal l))
(ensures
Cons? (FStar.Ghost.reveal l) /\
CQueue.llist_fragment_tail l phead ==
Steel.Effect.Common.vrewrite (Steel.Effect.Common.vdep (CQueue.llist_fragment_tail (FStar.Ghost.hide
(CQueue.unsnoc_hd (FStar.Ghost.reveal l)))
phead)
(CQueue.llist_fragment_tail_cons_next_payload l))
(CQueue.llist_fragment_tail_cons_rewrite l
(CQueue.llist_fragment_tail (FStar.Ghost.hide (CQueue.unsnoc_hd (FStar.Ghost.reveal l)
))
phead))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Ghost.erased",
"Prims.list",
"Steel.Reference.ref",
"CQueue.Cell.ccell_ptrvalue",
"CQueue.llist_fragment_tail_eq",
"Prims.unit",
"Prims.b2t",
"Prims.uu___is_Cons",
"FStar.Ghost.reveal",
"Prims.squash",
"Prims.l_and",
"CQueue.op_Equals_Equals",
"Steel.Effect.Common.vprop",
"CQueue.llist_fragment_tail",
"Steel.Effect.Common.vrewrite",
"Steel.Effect.Common.vdep",
"FStar.Ghost.hide",
"CQueue.unsnoc_hd",
"CQueue.llist_fragment_tail_cons_next_payload",
"CQueue.llist_fragment_tail_cons_rewrite",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let llist_fragment_tail_eq_cons
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: Lemma (requires (Cons? l))
(ensures
(Cons? l /\
llist_fragment_tail l phead ==
(((llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
`vdep`
(llist_fragment_tail_cons_next_payload l))
`vrewrite`
(llist_fragment_tail_cons_rewrite l
(llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead))))) =
| llist_fragment_tail_eq l phead | false |
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.get_heap_val128_def | val get_heap_val128_def (ptr: int) (mem: machine_heap) : quad32 | val get_heap_val128_def (ptr: int) (mem: machine_heap) : quad32 | let get_heap_val128_def (ptr:int) (mem:machine_heap) : quad32 = Mkfour
(get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem)
(get_heap_val32 (ptr + 12) mem) | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 44,
"start_col": 0,
"start_line": 40
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
)
[@"opaque_to_smt"] let get_heap_val64 = opaque_make get_heap_val64_def
irreducible let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ptr: Prims.int -> mem: Vale.Arch.MachineHeap_s.machine_heap -> Vale.Def.Types_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.Arch.MachineHeap_s.get_heap_val32",
"Prims.op_Addition",
"Vale.Def.Types_s.quad32"
] | [] | false | false | false | true | false | let get_heap_val128_def (ptr: int) (mem: machine_heap) : quad32 =
| Mkfour (get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem)
(get_heap_val32 (ptr + 12) mem) | false |
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.update_heap32_reveal | val update_heap32_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.Arch.MachineHeap_s.update_heap32 == Vale.Arch.MachineHeap_s.update_heap32_def) | let update_heap32_reveal = opaque_revealer (`%update_heap32) update_heap32 update_heap32_def | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 104,
"end_line": 56,
"start_col": 12,
"start_line": 56
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
)
[@"opaque_to_smt"] let get_heap_val64 = opaque_make get_heap_val64_def
irreducible let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def
let get_heap_val128_def (ptr:int) (mem:machine_heap) : quad32 = Mkfour
(get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem)
(get_heap_val32 (ptr + 12) mem)
[@"opaque_to_smt"] let get_heap_val128 = opaque_make get_heap_val128_def
irreducible let get_heap_val128_reveal = opaque_revealer (`%get_heap_val128) get_heap_val128 get_heap_val128_def
let update_heap32_def (ptr:int) (v:nat32) (mem:machine_heap) : machine_heap =
let v = nat_to_four 8 v in
let mem = mem.[ptr] <- v.lo0 in
let mem = mem.[ptr + 1] <- v.lo1 in
let mem = mem.[ptr + 2] <- v.hi2 in
let mem = mem.[ptr + 3] <- v.hi3 in
mem | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.Arch.MachineHeap_s.update_heap32 == Vale.Arch.MachineHeap_s.update_heap32_def) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Prims.int",
"Vale.Def.Types_s.nat32",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Arch.MachineHeap_s.update_heap32",
"Vale.Arch.MachineHeap_s.update_heap32_def"
] | [] | true | false | true | false | false | let update_heap32_reveal =
| opaque_revealer (`%update_heap32) update_heap32 update_heap32_def | false |
|
FStar.DM4F.StExnC.fst | FStar.DM4F.StExnC.stexnc | val stexnc : a: Type -> Type | let stexnc a =
int -> M (option a * (int * int)) | {
"file_name": "examples/dm4free/FStar.DM4F.StExnC.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 35,
"end_line": 31,
"start_col": 0,
"start_line": 30
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.StExnC
(**********************************************************
* Dijkstra Monads for Free : State with exceptions
*
* State over exceptions (state kept when raising).
*
* We don't define a get and put, but instead use the state
* for counting the amount of exceptions thrown.
*
**********************************************************)
(* The underlying representation type. The two ints are | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.StExnC.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type -> Type | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | true | let stexnc a =
| int -> M (option a * (int * int)) | false |
|
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.get_heap_val128_reveal | val get_heap_val128_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.Arch.MachineHeap_s.get_heap_val128 == Vale.Arch.MachineHeap_s.get_heap_val128_def) | let get_heap_val128_reveal = opaque_revealer (`%get_heap_val128) get_heap_val128 get_heap_val128_def | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 112,
"end_line": 46,
"start_col": 12,
"start_line": 46
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
)
[@"opaque_to_smt"] let get_heap_val64 = opaque_make get_heap_val64_def
irreducible let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def
let get_heap_val128_def (ptr:int) (mem:machine_heap) : quad32 = Mkfour
(get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem)
(get_heap_val32 (ptr + 12) mem) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.Arch.MachineHeap_s.get_heap_val128 == Vale.Arch.MachineHeap_s.get_heap_val128_def) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Prims.int",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Def.Types_s.quad32",
"Vale.Arch.MachineHeap_s.get_heap_val128",
"Vale.Arch.MachineHeap_s.get_heap_val128_def"
] | [] | true | false | true | false | false | let get_heap_val128_reveal =
| opaque_revealer (`%get_heap_val128) get_heap_val128 get_heap_val128_def | false |
|
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.update_heap32 | val update_heap32 : _: Prims.int -> _: Vale.Def.Types_s.nat32 -> _: Vale.Arch.MachineHeap_s.machine_heap
-> Vale.Arch.MachineHeap_s.machine_heap | let update_heap32 = opaque_make update_heap32_def | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 68,
"end_line": 55,
"start_col": 19,
"start_line": 55
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
)
[@"opaque_to_smt"] let get_heap_val64 = opaque_make get_heap_val64_def
irreducible let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def
let get_heap_val128_def (ptr:int) (mem:machine_heap) : quad32 = Mkfour
(get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem)
(get_heap_val32 (ptr + 12) mem)
[@"opaque_to_smt"] let get_heap_val128 = opaque_make get_heap_val128_def
irreducible let get_heap_val128_reveal = opaque_revealer (`%get_heap_val128) get_heap_val128 get_heap_val128_def
let update_heap32_def (ptr:int) (v:nat32) (mem:machine_heap) : machine_heap =
let v = nat_to_four 8 v in
let mem = mem.[ptr] <- v.lo0 in
let mem = mem.[ptr + 1] <- v.lo1 in
let mem = mem.[ptr + 2] <- v.hi2 in
let mem = mem.[ptr + 3] <- v.hi3 in | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.int -> _: Vale.Def.Types_s.nat32 -> _: Vale.Arch.MachineHeap_s.machine_heap
-> Vale.Arch.MachineHeap_s.machine_heap | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Prims.int",
"Vale.Def.Types_s.nat32",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Arch.MachineHeap_s.update_heap32_def"
] | [] | false | false | false | true | false | let update_heap32 =
| opaque_make update_heap32_def | false |
|
FStar.DM4F.StExnC.fst | FStar.DM4F.StExnC.return | val return : (a:Type) -> (x:a) -> stexnc a | val return : (a:Type) -> (x:a) -> stexnc a | let return a x = fun s -> Some x, (s, 0) | {
"file_name": "examples/dm4free/FStar.DM4F.StExnC.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 35,
"start_col": 0,
"start_line": 35
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.StExnC
(**********************************************************
* Dijkstra Monads for Free : State with exceptions
*
* State over exceptions (state kept when raising).
*
* We don't define a get and put, but instead use the state
* for counting the amount of exceptions thrown.
*
**********************************************************)
(* The underlying representation type. The two ints are
* resulting state and exception count, respectively. *)
let stexnc a =
int -> M (option a * (int * int))
(* Monad definition *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.StExnC.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type -> x: a -> FStar.DM4F.StExnC.stexnc a | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Some"
] | [] | false | false | false | true | false | let return a x =
| fun s -> Some x, (s, 0) | false |
FStar.DM4F.StExnC.fst | FStar.DM4F.StExnC.raise | val raise (a: Type) : stexnc a | val raise (a: Type) : stexnc a | let raise (a:Type) : stexnc a = fun s0 -> (None, (s0, 1)) | {
"file_name": "examples/dm4free/FStar.DM4F.StExnC.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 57,
"end_line": 47,
"start_col": 0,
"start_line": 47
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.StExnC
(**********************************************************
* Dijkstra Monads for Free : State with exceptions
*
* State over exceptions (state kept when raising).
*
* We don't define a get and put, but instead use the state
* for counting the amount of exceptions thrown.
*
**********************************************************)
(* The underlying representation type. The two ints are
* resulting state and exception count, respectively. *)
let stexnc a =
int -> M (option a * (int * int))
(* Monad definition *)
val return : (a:Type) -> (x:a) -> stexnc a
let return a x = fun s -> Some x, (s, 0)
val bind : (a:Type) -> (b:Type) ->
(m:stexnc a) -> (f:a -> stexnc b) -> stexnc b
let bind a b m f =
fun s0 ->
let r0 = m s0 in
match r0 with
| None, (s1, c1) -> None, (s1, c1)
| Some r, (s1, c1) -> let res, (s, c2) = f r s1
in res, (s, c1 + c2) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.StExnC.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type -> FStar.DM4F.StExnC.stexnc a | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.None",
"FStar.DM4F.StExnC.stexnc"
] | [] | false | false | false | true | false | let raise (a: Type) : stexnc a =
| fun s0 -> (None, (s0, 1)) | false |
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.update_heap128_def | val update_heap128_def : ptr: Prims.int -> v: Vale.Def.Types_s.quad32 -> mem: Vale.Arch.MachineHeap_s.machine_heap
-> Vale.Arch.MachineHeap_s.machine_heap | let update_heap128_def (ptr:int) (v:quad32) (mem:machine_heap) =
let mem = update_heap32 ptr v.lo0 mem in
let mem = update_heap32 (ptr + 4) v.lo1 mem in
let mem = update_heap32 (ptr + 8) v.hi2 mem in
let mem = update_heap32 (ptr + 12) v.hi3 mem in
mem | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 79,
"start_col": 0,
"start_line": 74
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
)
[@"opaque_to_smt"] let get_heap_val64 = opaque_make get_heap_val64_def
irreducible let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def
let get_heap_val128_def (ptr:int) (mem:machine_heap) : quad32 = Mkfour
(get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem)
(get_heap_val32 (ptr + 12) mem)
[@"opaque_to_smt"] let get_heap_val128 = opaque_make get_heap_val128_def
irreducible let get_heap_val128_reveal = opaque_revealer (`%get_heap_val128) get_heap_val128 get_heap_val128_def
let update_heap32_def (ptr:int) (v:nat32) (mem:machine_heap) : machine_heap =
let v = nat_to_four 8 v in
let mem = mem.[ptr] <- v.lo0 in
let mem = mem.[ptr + 1] <- v.lo1 in
let mem = mem.[ptr + 2] <- v.hi2 in
let mem = mem.[ptr + 3] <- v.hi3 in
mem
[@"opaque_to_smt"] let update_heap32 = opaque_make update_heap32_def
irreducible let update_heap32_reveal = opaque_revealer (`%update_heap32) update_heap32 update_heap32_def
let update_heap64_def (ptr:int) (v:nat64) (mem:machine_heap) : machine_heap =
let v = nat_to_two 32 v in
let lo = nat_to_four 8 v.lo in
let hi = nat_to_four 8 v.hi in
let mem = mem.[ptr] <- lo.lo0 in
let mem = mem.[ptr + 1] <- lo.lo1 in
let mem = mem.[ptr + 2] <- lo.hi2 in
let mem = mem.[ptr + 3] <- lo.hi3 in
let mem = mem.[ptr + 4] <- hi.lo0 in
let mem = mem.[ptr + 5] <- hi.lo1 in
let mem = mem.[ptr + 6] <- hi.hi2 in
let mem = mem.[ptr + 7] <- hi.hi3 in
mem
[@"opaque_to_smt"] let update_heap64 = opaque_make update_heap64_def
irreducible let update_heap64_reveal = opaque_revealer (`%update_heap64) update_heap64 update_heap64_def | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ptr: Prims.int -> v: Vale.Def.Types_s.quad32 -> mem: Vale.Arch.MachineHeap_s.machine_heap
-> Vale.Arch.MachineHeap_s.machine_heap | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.Def.Types_s.quad32",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Arch.MachineHeap_s.update_heap32",
"Prims.op_Addition",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0"
] | [] | false | false | false | true | false | let update_heap128_def (ptr: int) (v: quad32) (mem: machine_heap) =
| let mem = update_heap32 ptr v.lo0 mem in
let mem = update_heap32 (ptr + 4) v.lo1 mem in
let mem = update_heap32 (ptr + 8) v.hi2 mem in
let mem = update_heap32 (ptr + 12) v.hi3 mem in
mem | false |
|
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.update_heap64 | val update_heap64 : _: Prims.int -> _: Vale.Def.Types_s.nat64 -> _: Vale.Arch.MachineHeap_s.machine_heap
-> Vale.Arch.MachineHeap_s.machine_heap | let update_heap64 = opaque_make update_heap64_def | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 68,
"end_line": 71,
"start_col": 19,
"start_line": 71
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
)
[@"opaque_to_smt"] let get_heap_val64 = opaque_make get_heap_val64_def
irreducible let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def
let get_heap_val128_def (ptr:int) (mem:machine_heap) : quad32 = Mkfour
(get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem)
(get_heap_val32 (ptr + 12) mem)
[@"opaque_to_smt"] let get_heap_val128 = opaque_make get_heap_val128_def
irreducible let get_heap_val128_reveal = opaque_revealer (`%get_heap_val128) get_heap_val128 get_heap_val128_def
let update_heap32_def (ptr:int) (v:nat32) (mem:machine_heap) : machine_heap =
let v = nat_to_four 8 v in
let mem = mem.[ptr] <- v.lo0 in
let mem = mem.[ptr + 1] <- v.lo1 in
let mem = mem.[ptr + 2] <- v.hi2 in
let mem = mem.[ptr + 3] <- v.hi3 in
mem
[@"opaque_to_smt"] let update_heap32 = opaque_make update_heap32_def
irreducible let update_heap32_reveal = opaque_revealer (`%update_heap32) update_heap32 update_heap32_def
let update_heap64_def (ptr:int) (v:nat64) (mem:machine_heap) : machine_heap =
let v = nat_to_two 32 v in
let lo = nat_to_four 8 v.lo in
let hi = nat_to_four 8 v.hi in
let mem = mem.[ptr] <- lo.lo0 in
let mem = mem.[ptr + 1] <- lo.lo1 in
let mem = mem.[ptr + 2] <- lo.hi2 in
let mem = mem.[ptr + 3] <- lo.hi3 in
let mem = mem.[ptr + 4] <- hi.lo0 in
let mem = mem.[ptr + 5] <- hi.lo1 in
let mem = mem.[ptr + 6] <- hi.hi2 in
let mem = mem.[ptr + 7] <- hi.hi3 in | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.int -> _: Vale.Def.Types_s.nat64 -> _: Vale.Arch.MachineHeap_s.machine_heap
-> Vale.Arch.MachineHeap_s.machine_heap | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Prims.int",
"Vale.Def.Types_s.nat64",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Arch.MachineHeap_s.update_heap64_def"
] | [] | false | false | false | true | false | let update_heap64 =
| opaque_make update_heap64_def | false |
|
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.update_heap128 | val update_heap128 : _: Prims.int -> _: Vale.Def.Types_s.quad32 -> _: Vale.Arch.MachineHeap_s.machine_heap
-> Vale.Arch.MachineHeap_s.machine_heap | let update_heap128 = opaque_make update_heap128_def | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 70,
"end_line": 80,
"start_col": 19,
"start_line": 80
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
)
[@"opaque_to_smt"] let get_heap_val64 = opaque_make get_heap_val64_def
irreducible let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def
let get_heap_val128_def (ptr:int) (mem:machine_heap) : quad32 = Mkfour
(get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem)
(get_heap_val32 (ptr + 12) mem)
[@"opaque_to_smt"] let get_heap_val128 = opaque_make get_heap_val128_def
irreducible let get_heap_val128_reveal = opaque_revealer (`%get_heap_val128) get_heap_val128 get_heap_val128_def
let update_heap32_def (ptr:int) (v:nat32) (mem:machine_heap) : machine_heap =
let v = nat_to_four 8 v in
let mem = mem.[ptr] <- v.lo0 in
let mem = mem.[ptr + 1] <- v.lo1 in
let mem = mem.[ptr + 2] <- v.hi2 in
let mem = mem.[ptr + 3] <- v.hi3 in
mem
[@"opaque_to_smt"] let update_heap32 = opaque_make update_heap32_def
irreducible let update_heap32_reveal = opaque_revealer (`%update_heap32) update_heap32 update_heap32_def
let update_heap64_def (ptr:int) (v:nat64) (mem:machine_heap) : machine_heap =
let v = nat_to_two 32 v in
let lo = nat_to_four 8 v.lo in
let hi = nat_to_four 8 v.hi in
let mem = mem.[ptr] <- lo.lo0 in
let mem = mem.[ptr + 1] <- lo.lo1 in
let mem = mem.[ptr + 2] <- lo.hi2 in
let mem = mem.[ptr + 3] <- lo.hi3 in
let mem = mem.[ptr + 4] <- hi.lo0 in
let mem = mem.[ptr + 5] <- hi.lo1 in
let mem = mem.[ptr + 6] <- hi.hi2 in
let mem = mem.[ptr + 7] <- hi.hi3 in
mem
[@"opaque_to_smt"] let update_heap64 = opaque_make update_heap64_def
irreducible let update_heap64_reveal = opaque_revealer (`%update_heap64) update_heap64 update_heap64_def
let update_heap128_def (ptr:int) (v:quad32) (mem:machine_heap) =
let mem = update_heap32 ptr v.lo0 mem in
let mem = update_heap32 (ptr + 4) v.lo1 mem in
let mem = update_heap32 (ptr + 8) v.hi2 mem in
let mem = update_heap32 (ptr + 12) v.hi3 mem in | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.int -> _: Vale.Def.Types_s.quad32 -> _: Vale.Arch.MachineHeap_s.machine_heap
-> Vale.Arch.MachineHeap_s.machine_heap | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Prims.int",
"Vale.Def.Types_s.quad32",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Arch.MachineHeap_s.update_heap128_def"
] | [] | false | false | false | true | false | let update_heap128 =
| opaque_make update_heap128_def | false |
|
SelectorsLList3Example.fst | SelectorsLList3Example.intro_llist_cons | val intro_llist_cons (ptr1 ptr2: t)
: Steel unit
((vptr ptr1) `star` (LL.llist ptr2))
(fun _ -> LL.llist ptr1)
(requires fun h -> next (sel ptr1 h) == ptr2)
(ensures fun h0 _ h1 -> LL.v_llist ptr1 h1 == (data (sel ptr1 h0)) :: LL.v_llist ptr2 h0) | val intro_llist_cons (ptr1 ptr2: t)
: Steel unit
((vptr ptr1) `star` (LL.llist ptr2))
(fun _ -> LL.llist ptr1)
(requires fun h -> next (sel ptr1 h) == ptr2)
(ensures fun h0 _ h1 -> LL.v_llist ptr1 h1 == (data (sel ptr1 h0)) :: LL.v_llist ptr2 h0) | let intro_llist_cons (ptr1 ptr2:t)
: Steel unit (vptr ptr1 `star` LL.llist ptr2)
(fun _ -> LL.llist ptr1)
(requires fun h -> next (sel ptr1 h) == ptr2)
(ensures fun h0 _ h1 -> LL.v_llist ptr1 h1 == (data (sel ptr1 h0)) :: LL.v_llist ptr2 h0)
= LL.intro_llist_cons ptr1 ptr2 | {
"file_name": "share/steel/examples/steel/llist3/SelectorsLList3Example.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 31,
"end_line": 50,
"start_col": 0,
"start_line": 45
} | module SelectorsLList3Example
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.ArrayRef
module L = FStar.List.Tot
module LL = Selectors.LList3
module U32 = FStar.UInt32
module MB = LowStar.Monotonic.Buffer // for is_null
inline_for_extraction noextract let a = U32.t
let cell = LL.cell a
/// The type of a list: A reference to a cell
let t = LL.t a
let next (c:cell) : t = LL.next c
let data (c:cell) : a = LL.data c
let mk_cell (n: t) (d:a)
: Pure cell
(requires True)
(ensures fun c ->
next c == n /\
data c == d)
= LL.mk_cell n d
/// The null list pointer
let null_llist () : t = LL.null_llist
/// Lifting the null pointer check to empty lists
let is_null (ptr:t) : (b:bool{b <==> ptr == null_llist ()})
= LL.is_null ptr
let is_nil (ptr:t)
: Steel bool (LL.llist ptr) (fun _ -> LL.llist ptr)
(requires fun _ -> True)
(ensures fun h0 res h1 ->
(res == true <==> ptr == null_llist ()) /\
LL.v_llist ptr h0 == LL.v_llist ptr h1 /\
res == Nil? (LL.v_llist ptr h1))
= LL.is_nil ptr | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"Steel.ArrayRef.fsti.checked",
"Selectors.LList3.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "SelectorsLList3Example.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer // for is_null",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "Selectors.LList3",
"short_module": "LL"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.ArrayRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ptr1: SelectorsLList3Example.t -> ptr2: SelectorsLList3Example.t -> Steel.Effect.Steel Prims.unit | Steel.Effect.Steel | [] | [] | [
"SelectorsLList3Example.t",
"Selectors.LList3.intro_llist_cons",
"SelectorsLList3Example.a",
"Prims.unit",
"Steel.Effect.Common.star",
"Steel.ArrayRef.vptr",
"Selectors.LList3.cell",
"Selectors.LList3.llist",
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.rmem",
"Prims.eq2",
"SelectorsLList3Example.next",
"Steel.ArrayRef.sel",
"Prims.list",
"Selectors.LList3.v_llist",
"Prims.Cons",
"SelectorsLList3Example.data"
] | [] | false | true | false | false | false | let intro_llist_cons (ptr1 ptr2: t)
: Steel unit
((vptr ptr1) `star` (LL.llist ptr2))
(fun _ -> LL.llist ptr1)
(requires fun h -> next (sel ptr1 h) == ptr2)
(ensures fun h0 _ h1 -> LL.v_llist ptr1 h1 == (data (sel ptr1 h0)) :: LL.v_llist ptr2 h0) =
| LL.intro_llist_cons ptr1 ptr2 | false |
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.update_heap64_reveal | val update_heap64_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.Arch.MachineHeap_s.update_heap64 == Vale.Arch.MachineHeap_s.update_heap64_def) | let update_heap64_reveal = opaque_revealer (`%update_heap64) update_heap64 update_heap64_def | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 104,
"end_line": 72,
"start_col": 12,
"start_line": 72
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
)
[@"opaque_to_smt"] let get_heap_val64 = opaque_make get_heap_val64_def
irreducible let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def
let get_heap_val128_def (ptr:int) (mem:machine_heap) : quad32 = Mkfour
(get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem)
(get_heap_val32 (ptr + 12) mem)
[@"opaque_to_smt"] let get_heap_val128 = opaque_make get_heap_val128_def
irreducible let get_heap_val128_reveal = opaque_revealer (`%get_heap_val128) get_heap_val128 get_heap_val128_def
let update_heap32_def (ptr:int) (v:nat32) (mem:machine_heap) : machine_heap =
let v = nat_to_four 8 v in
let mem = mem.[ptr] <- v.lo0 in
let mem = mem.[ptr + 1] <- v.lo1 in
let mem = mem.[ptr + 2] <- v.hi2 in
let mem = mem.[ptr + 3] <- v.hi3 in
mem
[@"opaque_to_smt"] let update_heap32 = opaque_make update_heap32_def
irreducible let update_heap32_reveal = opaque_revealer (`%update_heap32) update_heap32 update_heap32_def
let update_heap64_def (ptr:int) (v:nat64) (mem:machine_heap) : machine_heap =
let v = nat_to_two 32 v in
let lo = nat_to_four 8 v.lo in
let hi = nat_to_four 8 v.hi in
let mem = mem.[ptr] <- lo.lo0 in
let mem = mem.[ptr + 1] <- lo.lo1 in
let mem = mem.[ptr + 2] <- lo.hi2 in
let mem = mem.[ptr + 3] <- lo.hi3 in
let mem = mem.[ptr + 4] <- hi.lo0 in
let mem = mem.[ptr + 5] <- hi.lo1 in
let mem = mem.[ptr + 6] <- hi.hi2 in
let mem = mem.[ptr + 7] <- hi.hi3 in
mem | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.Arch.MachineHeap_s.update_heap64 == Vale.Arch.MachineHeap_s.update_heap64_def) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Prims.int",
"Vale.Def.Types_s.nat64",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Arch.MachineHeap_s.update_heap64",
"Vale.Arch.MachineHeap_s.update_heap64_def"
] | [] | true | false | true | false | false | let update_heap64_reveal =
| opaque_revealer (`%update_heap64) update_heap64 update_heap64_def | false |
|
CQueue.fst | CQueue.sel_llist_fragment_head | val sel_llist_fragment_head
(#a: Type)
(#p: vprop)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
(h:
rmem p
{ FStar.Tactics.with_tactic selector_tactic
(can_be_split p (llist_fragment_head l phead head) /\ True) })
: GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a) | val sel_llist_fragment_head
(#a: Type)
(#p: vprop)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
(h:
rmem p
{ FStar.Tactics.with_tactic selector_tactic
(can_be_split p (llist_fragment_head l phead head) /\ True) })
: GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a) | let sel_llist_fragment_head
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_head l phead head) /\ True) })
: GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
=
coerce (h (llist_fragment_head l phead head)) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 91,
"end_line": 782,
"start_col": 0,
"start_line": 776
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end
let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2
[@@__steel_reduce__]
let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop
= vptr tail2 `vrefine` queue_tail_refine tail1 tail2
[@@__steel_reduce__]
let queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop
= vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1
[@@__steel_reduce__; __reduce__]
let queue_tail
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
=
llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l
val intro_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun _ -> queue_tail x l)
(fun h ->
sel_llist_fragment_tail l (cllist_head x) h == tail /\
sel (cllist_tail x) h == tail /\
ccell_ptrvalue_is_null (sel tail h)
)
(fun _ _ _ -> True)
let intro_queue_tail
x l tail
=
intro_vrefine (vptr tail) (queue_tail_refine tail tail);
intro_vdep2
(vptr (cllist_tail x))
(vptr tail `vrefine` queue_tail_refine tail tail)
tail
(queue_tail_dep2 x l tail);
intro_vdep2
(llist_fragment_tail l (cllist_head x))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail)
tail
(queue_tail_dep1 x l)
val elim_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(queue_tail x l)
(fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun h -> True)
(fun _ tail h ->
sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\
sel (cllist_tail x) h == Ghost.reveal tail /\
ccell_ptrvalue_is_null (h (vptr tail))
)
let elim_queue_tail
#_ #a x l
=
let tail0 = elim_vdep
(llist_fragment_tail l (cllist_head x))
(queue_tail_dep1 x l)
in
let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in
change_equal_slprop
(queue_tail_dep1 x l (Ghost.reveal tail0))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0);
let tail2 = elim_vdep
(vptr (cllist_tail x))
(queue_tail_dep2 x l tail0)
in
let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in
change_equal_slprop
(queue_tail_dep2 x l tail0 (Ghost.reveal tail2))
(vptr tail3 `vrefine` queue_tail_refine tail0 tail3);
elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3);
change_equal_slprop
(vptr tail3)
(vptr tail);
tail
(* view from the head *)
let llist_fragment_head_data_refine
(#a: Type)
(d: a)
(c: vcell a)
: Tot prop
= c.vcell_data == d
let llist_fragment_head_payload
(#a: Type)
(head: ccell_ptrvalue a)
(d: a)
(llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop))
(x: t_of (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine d)))
: Tot vprop
=
llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next
let rec llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Tot vprop
(decreases (Ghost.reveal l))
=
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
let t_of_llist_fragment_head
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(t_of (llist_fragment_head l phead head) == ref (ccell_ptrvalue a) & ccell_ptrvalue a)
= () | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
l: FStar.Ghost.erased (Prims.list a) ->
phead: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) ->
head: CQueue.Cell.ccell_ptrvalue a ->
h:
Steel.Effect.Common.rmem p
{ FStar.Tactics.Effect.with_tactic Steel.Effect.Common.selector_tactic
(Steel.Effect.Common.can_be_split p (CQueue.llist_fragment_head l phead head) /\
Prims.l_True) }
-> Prims.GTot (Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) * CQueue.Cell.ccell_ptrvalue a) | Prims.GTot | [
"sometrivial"
] | [] | [
"Steel.Effect.Common.vprop",
"FStar.Ghost.erased",
"Prims.list",
"Steel.Reference.ref",
"CQueue.Cell.ccell_ptrvalue",
"Steel.Effect.Common.rmem",
"FStar.Tactics.Effect.with_tactic",
"Steel.Effect.Common.selector_tactic",
"Prims.l_and",
"Steel.Effect.Common.can_be_split",
"CQueue.llist_fragment_head",
"Prims.l_True",
"CQueue.coerce",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.t_of",
"FStar.Pervasives.Native.tuple2"
] | [] | false | false | false | false | false | let sel_llist_fragment_head
(#a: Type)
(#p: vprop)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
(h:
rmem p
{ FStar.Tactics.with_tactic selector_tactic
(can_be_split p (llist_fragment_head l phead head) /\ True) })
: GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a) =
| coerce (h (llist_fragment_head l phead head)) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) | false |
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.update_heap128_reveal | val update_heap128_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.Arch.MachineHeap_s.update_heap128 == Vale.Arch.MachineHeap_s.update_heap128_def) | let update_heap128_reveal = opaque_revealer (`%update_heap128) update_heap128 update_heap128_def | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 108,
"end_line": 81,
"start_col": 12,
"start_line": 81
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
)
[@"opaque_to_smt"] let get_heap_val64 = opaque_make get_heap_val64_def
irreducible let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def
let get_heap_val128_def (ptr:int) (mem:machine_heap) : quad32 = Mkfour
(get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem)
(get_heap_val32 (ptr + 12) mem)
[@"opaque_to_smt"] let get_heap_val128 = opaque_make get_heap_val128_def
irreducible let get_heap_val128_reveal = opaque_revealer (`%get_heap_val128) get_heap_val128 get_heap_val128_def
let update_heap32_def (ptr:int) (v:nat32) (mem:machine_heap) : machine_heap =
let v = nat_to_four 8 v in
let mem = mem.[ptr] <- v.lo0 in
let mem = mem.[ptr + 1] <- v.lo1 in
let mem = mem.[ptr + 2] <- v.hi2 in
let mem = mem.[ptr + 3] <- v.hi3 in
mem
[@"opaque_to_smt"] let update_heap32 = opaque_make update_heap32_def
irreducible let update_heap32_reveal = opaque_revealer (`%update_heap32) update_heap32 update_heap32_def
let update_heap64_def (ptr:int) (v:nat64) (mem:machine_heap) : machine_heap =
let v = nat_to_two 32 v in
let lo = nat_to_four 8 v.lo in
let hi = nat_to_four 8 v.hi in
let mem = mem.[ptr] <- lo.lo0 in
let mem = mem.[ptr + 1] <- lo.lo1 in
let mem = mem.[ptr + 2] <- lo.hi2 in
let mem = mem.[ptr + 3] <- lo.hi3 in
let mem = mem.[ptr + 4] <- hi.lo0 in
let mem = mem.[ptr + 5] <- hi.lo1 in
let mem = mem.[ptr + 6] <- hi.hi2 in
let mem = mem.[ptr + 7] <- hi.hi3 in
mem
[@"opaque_to_smt"] let update_heap64 = opaque_make update_heap64_def
irreducible let update_heap64_reveal = opaque_revealer (`%update_heap64) update_heap64 update_heap64_def
let update_heap128_def (ptr:int) (v:quad32) (mem:machine_heap) =
let mem = update_heap32 ptr v.lo0 mem in
let mem = update_heap32 (ptr + 4) v.lo1 mem in
let mem = update_heap32 (ptr + 8) v.hi2 mem in
let mem = update_heap32 (ptr + 12) v.hi3 mem in
mem | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.Arch.MachineHeap_s.update_heap128 == Vale.Arch.MachineHeap_s.update_heap128_def) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Prims.int",
"Vale.Def.Types_s.quad32",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Arch.MachineHeap_s.update_heap128",
"Vale.Arch.MachineHeap_s.update_heap128_def"
] | [] | true | false | true | false | false | let update_heap128_reveal =
| opaque_revealer (`%update_heap128) update_heap128 update_heap128_def | false |
|
FStar.DM4F.StExnC.fst | FStar.DM4F.StExnC.lift_pure_stexnc | val lift_pure_stexnc : a: Type -> wp: Prims.pure_wp a -> h0: Prims.int -> p: FStar.DM4F.StExnC._dm4f_STEXNC_post a
-> Prims.pure_pre | let lift_pure_stexnc (a:Type) (wp:pure_wp a) (h0:int) (p:STEXNC?.post a) =
wp (fun a -> p (Some a, (h0, 0))) | {
"file_name": "examples/dm4free/FStar.DM4F.StExnC.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 41,
"end_line": 63,
"start_col": 7,
"start_line": 62
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.StExnC
(**********************************************************
* Dijkstra Monads for Free : State with exceptions
*
* State over exceptions (state kept when raising).
*
* We don't define a get and put, but instead use the state
* for counting the amount of exceptions thrown.
*
**********************************************************)
(* The underlying representation type. The two ints are
* resulting state and exception count, respectively. *)
let stexnc a =
int -> M (option a * (int * int))
(* Monad definition *)
val return : (a:Type) -> (x:a) -> stexnc a
let return a x = fun s -> Some x, (s, 0)
val bind : (a:Type) -> (b:Type) ->
(m:stexnc a) -> (f:a -> stexnc b) -> stexnc b
let bind a b m f =
fun s0 ->
let r0 = m s0 in
match r0 with
| None, (s1, c1) -> None, (s1, c1)
| Some r, (s1, c1) -> let res, (s, c2) = f r s1
in res, (s, c1 + c2)
let raise (a:Type) : stexnc a = fun s0 -> (None, (s0, 1))
(*
* Define the new effect using DM4F. We don't mark it as reflectable
* so we know the invariant of exception-counting is enforced
*)
total reifiable new_effect {
STEXNC: a:Type -> Effect
with repr = stexnc
; return = return
; bind = bind
; raise = raise
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.StExnC.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type -> wp: Prims.pure_wp a -> h0: Prims.int -> p: FStar.DM4F.StExnC._dm4f_STEXNC_post a
-> Prims.pure_pre | Prims.Tot | [
"total"
] | [] | [
"Prims.pure_wp",
"Prims.int",
"FStar.DM4F.StExnC._dm4f_STEXNC_post",
"Prims.l_True",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Some",
"Prims.pure_pre"
] | [] | false | false | false | true | false | let lift_pure_stexnc (a: Type) (wp: pure_wp a) (h0: int) (p: STEXNC?.post a) =
| wp (fun a -> p (Some a, (h0, 0))) | false |
|
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.valid_addr64 | val valid_addr64 : ptr: Prims.int -> mem: Vale.Arch.MachineHeap_s.machine_heap -> Prims.bool | let valid_addr64 (ptr:int) (mem:machine_heap) =
valid_addr ptr mem &&
valid_addr (ptr + 1) mem &&
valid_addr (ptr + 2) mem &&
valid_addr (ptr + 3) mem &&
valid_addr (ptr + 4) mem &&
valid_addr (ptr + 5) mem &&
valid_addr (ptr + 6) mem &&
valid_addr (ptr + 7) mem | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 26,
"end_line": 95,
"start_col": 0,
"start_line": 87
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
)
[@"opaque_to_smt"] let get_heap_val64 = opaque_make get_heap_val64_def
irreducible let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def
let get_heap_val128_def (ptr:int) (mem:machine_heap) : quad32 = Mkfour
(get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem)
(get_heap_val32 (ptr + 12) mem)
[@"opaque_to_smt"] let get_heap_val128 = opaque_make get_heap_val128_def
irreducible let get_heap_val128_reveal = opaque_revealer (`%get_heap_val128) get_heap_val128 get_heap_val128_def
let update_heap32_def (ptr:int) (v:nat32) (mem:machine_heap) : machine_heap =
let v = nat_to_four 8 v in
let mem = mem.[ptr] <- v.lo0 in
let mem = mem.[ptr + 1] <- v.lo1 in
let mem = mem.[ptr + 2] <- v.hi2 in
let mem = mem.[ptr + 3] <- v.hi3 in
mem
[@"opaque_to_smt"] let update_heap32 = opaque_make update_heap32_def
irreducible let update_heap32_reveal = opaque_revealer (`%update_heap32) update_heap32 update_heap32_def
let update_heap64_def (ptr:int) (v:nat64) (mem:machine_heap) : machine_heap =
let v = nat_to_two 32 v in
let lo = nat_to_four 8 v.lo in
let hi = nat_to_four 8 v.hi in
let mem = mem.[ptr] <- lo.lo0 in
let mem = mem.[ptr + 1] <- lo.lo1 in
let mem = mem.[ptr + 2] <- lo.hi2 in
let mem = mem.[ptr + 3] <- lo.hi3 in
let mem = mem.[ptr + 4] <- hi.lo0 in
let mem = mem.[ptr + 5] <- hi.lo1 in
let mem = mem.[ptr + 6] <- hi.hi2 in
let mem = mem.[ptr + 7] <- hi.hi3 in
mem
[@"opaque_to_smt"] let update_heap64 = opaque_make update_heap64_def
irreducible let update_heap64_reveal = opaque_revealer (`%update_heap64) update_heap64 update_heap64_def
let update_heap128_def (ptr:int) (v:quad32) (mem:machine_heap) =
let mem = update_heap32 ptr v.lo0 mem in
let mem = update_heap32 (ptr + 4) v.lo1 mem in
let mem = update_heap32 (ptr + 8) v.hi2 mem in
let mem = update_heap32 (ptr + 12) v.hi3 mem in
mem
[@"opaque_to_smt"] let update_heap128 = opaque_make update_heap128_def
irreducible let update_heap128_reveal = opaque_revealer (`%update_heap128) update_heap128 update_heap128_def
let valid_addr (ptr:int) (mem:machine_heap) : bool =
Map.contains mem ptr | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ptr: Prims.int -> mem: Vale.Arch.MachineHeap_s.machine_heap -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.op_AmpAmp",
"Vale.Arch.MachineHeap_s.valid_addr",
"Prims.op_Addition",
"Prims.bool"
] | [] | false | false | false | true | false | let valid_addr64 (ptr: int) (mem: machine_heap) =
| valid_addr ptr mem && valid_addr (ptr + 1) mem && valid_addr (ptr + 2) mem &&
valid_addr (ptr + 3) mem &&
valid_addr (ptr + 4) mem &&
valid_addr (ptr + 5) mem &&
valid_addr (ptr + 6) mem &&
valid_addr (ptr + 7) mem | false |
|
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.get_heap_val32_def | val get_heap_val32_def (ptr: int) (mem: machine_heap) : nat32 | val get_heap_val32_def (ptr: int) (mem: machine_heap) : nat32 | let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3]) | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 18,
"end_line": 27,
"start_col": 0,
"start_line": 21
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ptr: Prims.int -> mem: Vale.Arch.MachineHeap_s.machine_heap -> Vale.Def.Types_s.nat32 | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Def.Words.Four_s.four_to_nat",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Words_s.natN",
"Prims.pow2",
"Vale.Arch.MachineHeap_s.op_String_Access",
"Vale.Def.Types_s.nat8",
"Prims.op_Addition",
"Vale.Def.Types_s.nat32"
] | [] | false | false | false | true | false | let get_heap_val32_def (ptr: int) (mem: machine_heap) : nat32 =
| four_to_nat 8 (Mkfour mem.[ ptr ] mem.[ ptr + 1 ] mem.[ ptr + 2 ] mem.[ ptr + 3 ]) | false |
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.valid_addr128 | val valid_addr128 : ptr: Prims.int -> mem: Vale.Arch.MachineHeap_s.machine_heap -> Prims.bool | let valid_addr128 (ptr:int) (mem:machine_heap) =
valid_addr ptr mem &&
valid_addr (ptr + 1) mem &&
valid_addr (ptr + 2) mem &&
valid_addr (ptr + 3) mem &&
valid_addr (ptr + 4) mem &&
valid_addr (ptr + 5) mem &&
valid_addr (ptr + 6) mem &&
valid_addr (ptr + 7) mem &&
valid_addr (ptr + 8) mem &&
valid_addr (ptr + 9) mem &&
valid_addr (ptr + 10) mem &&
valid_addr (ptr + 11) mem &&
valid_addr (ptr + 12) mem &&
valid_addr (ptr + 13) mem &&
valid_addr (ptr + 14) mem &&
valid_addr (ptr + 15) mem | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 114,
"start_col": 0,
"start_line": 98
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
)
[@"opaque_to_smt"] let get_heap_val64 = opaque_make get_heap_val64_def
irreducible let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def
let get_heap_val128_def (ptr:int) (mem:machine_heap) : quad32 = Mkfour
(get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem)
(get_heap_val32 (ptr + 12) mem)
[@"opaque_to_smt"] let get_heap_val128 = opaque_make get_heap_val128_def
irreducible let get_heap_val128_reveal = opaque_revealer (`%get_heap_val128) get_heap_val128 get_heap_val128_def
let update_heap32_def (ptr:int) (v:nat32) (mem:machine_heap) : machine_heap =
let v = nat_to_four 8 v in
let mem = mem.[ptr] <- v.lo0 in
let mem = mem.[ptr + 1] <- v.lo1 in
let mem = mem.[ptr + 2] <- v.hi2 in
let mem = mem.[ptr + 3] <- v.hi3 in
mem
[@"opaque_to_smt"] let update_heap32 = opaque_make update_heap32_def
irreducible let update_heap32_reveal = opaque_revealer (`%update_heap32) update_heap32 update_heap32_def
let update_heap64_def (ptr:int) (v:nat64) (mem:machine_heap) : machine_heap =
let v = nat_to_two 32 v in
let lo = nat_to_four 8 v.lo in
let hi = nat_to_four 8 v.hi in
let mem = mem.[ptr] <- lo.lo0 in
let mem = mem.[ptr + 1] <- lo.lo1 in
let mem = mem.[ptr + 2] <- lo.hi2 in
let mem = mem.[ptr + 3] <- lo.hi3 in
let mem = mem.[ptr + 4] <- hi.lo0 in
let mem = mem.[ptr + 5] <- hi.lo1 in
let mem = mem.[ptr + 6] <- hi.hi2 in
let mem = mem.[ptr + 7] <- hi.hi3 in
mem
[@"opaque_to_smt"] let update_heap64 = opaque_make update_heap64_def
irreducible let update_heap64_reveal = opaque_revealer (`%update_heap64) update_heap64 update_heap64_def
let update_heap128_def (ptr:int) (v:quad32) (mem:machine_heap) =
let mem = update_heap32 ptr v.lo0 mem in
let mem = update_heap32 (ptr + 4) v.lo1 mem in
let mem = update_heap32 (ptr + 8) v.hi2 mem in
let mem = update_heap32 (ptr + 12) v.hi3 mem in
mem
[@"opaque_to_smt"] let update_heap128 = opaque_make update_heap128_def
irreducible let update_heap128_reveal = opaque_revealer (`%update_heap128) update_heap128 update_heap128_def
let valid_addr (ptr:int) (mem:machine_heap) : bool =
Map.contains mem ptr
[@"opaque_to_smt"]
let valid_addr64 (ptr:int) (mem:machine_heap) =
valid_addr ptr mem &&
valid_addr (ptr + 1) mem &&
valid_addr (ptr + 2) mem &&
valid_addr (ptr + 3) mem &&
valid_addr (ptr + 4) mem &&
valid_addr (ptr + 5) mem &&
valid_addr (ptr + 6) mem &&
valid_addr (ptr + 7) mem | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ptr: Prims.int -> mem: Vale.Arch.MachineHeap_s.machine_heap -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.op_AmpAmp",
"Vale.Arch.MachineHeap_s.valid_addr",
"Prims.op_Addition",
"Prims.bool"
] | [] | false | false | false | true | false | let valid_addr128 (ptr: int) (mem: machine_heap) =
| valid_addr ptr mem && valid_addr (ptr + 1) mem && valid_addr (ptr + 2) mem &&
valid_addr (ptr + 3) mem &&
valid_addr (ptr + 4) mem &&
valid_addr (ptr + 5) mem &&
valid_addr (ptr + 6) mem &&
valid_addr (ptr + 7) mem &&
valid_addr (ptr + 8) mem &&
valid_addr (ptr + 9) mem &&
valid_addr (ptr + 10) mem &&
valid_addr (ptr + 11) mem &&
valid_addr (ptr + 12) mem &&
valid_addr (ptr + 13) mem &&
valid_addr (ptr + 14) mem &&
valid_addr (ptr + 15) mem | false |
|
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.valid_addr | val valid_addr (ptr: int) (mem: machine_heap) : bool | val valid_addr (ptr: int) (mem: machine_heap) : bool | let valid_addr (ptr:int) (mem:machine_heap) : bool =
Map.contains mem ptr | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 84,
"start_col": 0,
"start_line": 83
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
)
[@"opaque_to_smt"] let get_heap_val64 = opaque_make get_heap_val64_def
irreducible let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def
let get_heap_val128_def (ptr:int) (mem:machine_heap) : quad32 = Mkfour
(get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem)
(get_heap_val32 (ptr + 12) mem)
[@"opaque_to_smt"] let get_heap_val128 = opaque_make get_heap_val128_def
irreducible let get_heap_val128_reveal = opaque_revealer (`%get_heap_val128) get_heap_val128 get_heap_val128_def
let update_heap32_def (ptr:int) (v:nat32) (mem:machine_heap) : machine_heap =
let v = nat_to_four 8 v in
let mem = mem.[ptr] <- v.lo0 in
let mem = mem.[ptr + 1] <- v.lo1 in
let mem = mem.[ptr + 2] <- v.hi2 in
let mem = mem.[ptr + 3] <- v.hi3 in
mem
[@"opaque_to_smt"] let update_heap32 = opaque_make update_heap32_def
irreducible let update_heap32_reveal = opaque_revealer (`%update_heap32) update_heap32 update_heap32_def
let update_heap64_def (ptr:int) (v:nat64) (mem:machine_heap) : machine_heap =
let v = nat_to_two 32 v in
let lo = nat_to_four 8 v.lo in
let hi = nat_to_four 8 v.hi in
let mem = mem.[ptr] <- lo.lo0 in
let mem = mem.[ptr + 1] <- lo.lo1 in
let mem = mem.[ptr + 2] <- lo.hi2 in
let mem = mem.[ptr + 3] <- lo.hi3 in
let mem = mem.[ptr + 4] <- hi.lo0 in
let mem = mem.[ptr + 5] <- hi.lo1 in
let mem = mem.[ptr + 6] <- hi.hi2 in
let mem = mem.[ptr + 7] <- hi.hi3 in
mem
[@"opaque_to_smt"] let update_heap64 = opaque_make update_heap64_def
irreducible let update_heap64_reveal = opaque_revealer (`%update_heap64) update_heap64 update_heap64_def
let update_heap128_def (ptr:int) (v:quad32) (mem:machine_heap) =
let mem = update_heap32 ptr v.lo0 mem in
let mem = update_heap32 (ptr + 4) v.lo1 mem in
let mem = update_heap32 (ptr + 8) v.hi2 mem in
let mem = update_heap32 (ptr + 12) v.hi3 mem in
mem
[@"opaque_to_smt"] let update_heap128 = opaque_make update_heap128_def
irreducible let update_heap128_reveal = opaque_revealer (`%update_heap128) update_heap128 update_heap128_def | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ptr: Prims.int -> mem: Vale.Arch.MachineHeap_s.machine_heap -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.Arch.MachineHeap_s.machine_heap",
"FStar.Map.contains",
"Vale.Def.Types_s.nat8",
"Prims.bool"
] | [] | false | false | false | true | false | let valid_addr (ptr: int) (mem: machine_heap) : bool =
| Map.contains mem ptr | false |
FStar.DM4F.StExnC.fst | FStar.DM4F.StExnC.bind | val bind : (a:Type) -> (b:Type) ->
(m:stexnc a) -> (f:a -> stexnc b) -> stexnc b | val bind : (a:Type) -> (b:Type) ->
(m:stexnc a) -> (f:a -> stexnc b) -> stexnc b | let bind a b m f =
fun s0 ->
let r0 = m s0 in
match r0 with
| None, (s1, c1) -> None, (s1, c1)
| Some r, (s1, c1) -> let res, (s, c2) = f r s1
in res, (s, c1 + c2) | {
"file_name": "examples/dm4free/FStar.DM4F.StExnC.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 47,
"end_line": 45,
"start_col": 0,
"start_line": 39
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.StExnC
(**********************************************************
* Dijkstra Monads for Free : State with exceptions
*
* State over exceptions (state kept when raising).
*
* We don't define a get and put, but instead use the state
* for counting the amount of exceptions thrown.
*
**********************************************************)
(* The underlying representation type. The two ints are
* resulting state and exception count, respectively. *)
let stexnc a =
int -> M (option a * (int * int))
(* Monad definition *)
val return : (a:Type) -> (x:a) -> stexnc a
let return a x = fun s -> Some x, (s, 0)
val bind : (a:Type) -> (b:Type) -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.StExnC.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type -> b: Type -> m: FStar.DM4F.StExnC.stexnc a -> f: (f: a -> FStar.DM4F.StExnC.stexnc b)
-> FStar.DM4F.StExnC.stexnc b | Prims.Tot | [
"total"
] | [] | [
"FStar.DM4F.StExnC.stexnc",
"Prims.int",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.None",
"Prims.op_Addition"
] | [] | false | false | false | true | false | let bind a b m f =
| fun s0 ->
let r0 = m s0 in
match r0 with
| None, (s1, c1) -> None, (s1, c1)
| Some r, (s1, c1) ->
let res, (s, c2) = f r s1 in
res, (s, c1 + c2) | false |
CQueue.fst | CQueue.intro_vdep2 | val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
)) | val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
)) | let intro_vdep2
v q x p
=
intro_vdep v q p | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 18,
"end_line": 159,
"start_col": 0,
"start_line": 156
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
)) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
v: Steel.Effect.Common.vprop ->
q: Steel.Effect.Common.vprop ->
x: Steel.Effect.Common.t_of v ->
p: (_: Steel.Effect.Common.t_of v -> Steel.Effect.Common.vprop)
-> Steel.Effect.Atomic.SteelGhost Prims.unit | Steel.Effect.Atomic.SteelGhost | [] | [] | [
"Steel.Memory.inames",
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.t_of",
"Steel.Effect.Atomic.intro_vdep",
"Prims.unit"
] | [] | false | true | false | false | false | let intro_vdep2 v q x p =
| intro_vdep v q p | false |
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.get_heap_val64_def | val get_heap_val64_def (ptr: int) (mem: machine_heap) : nat64 | val get_heap_val64_def (ptr: int) (mem: machine_heap) : nat64 | let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
) | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 36,
"start_col": 0,
"start_line": 31
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ptr: Prims.int -> mem: Vale.Arch.MachineHeap_s.machine_heap -> Vale.Def.Types_s.nat64 | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Def.Words.Two_s.two_to_nat",
"Vale.Def.Words_s.Mktwo",
"Vale.Def.Words_s.natN",
"Prims.pow2",
"Vale.Def.Words.Four_s.four_to_nat",
"Vale.Def.Words_s.Mkfour",
"Vale.Arch.MachineHeap_s.op_String_Access",
"Vale.Def.Types_s.nat8",
"Prims.op_Addition",
"Vale.Def.Types_s.nat64"
] | [] | false | false | false | true | false | let get_heap_val64_def (ptr: int) (mem: machine_heap) : nat64 =
| two_to_nat 32
(Mktwo (four_to_nat 8 (Mkfour mem.[ ptr ] mem.[ ptr + 1 ] mem.[ ptr + 2 ] mem.[ ptr + 3 ]))
(four_to_nat 8 (Mkfour mem.[ ptr + 4 ] mem.[ ptr + 5 ] mem.[ ptr + 6 ] mem.[ ptr + 7 ]))) | false |
CQueue.fst | CQueue.llist_fragment_head_eq_cons | val llist_fragment_head_eq_cons
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: Lemma (requires (Cons? (Ghost.reveal l)))
(ensures
(llist_fragment_head l phead head ==
vbind ((ccell_is_lvalue head)
`star`
((ccell head) `vrefine` (llist_fragment_head_data_refine (L.hd (Ghost.reveal l)))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head
(L.hd (Ghost.reveal l))
(llist_fragment_head (L.tl (Ghost.reveal l)))))) | val llist_fragment_head_eq_cons
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: Lemma (requires (Cons? (Ghost.reveal l)))
(ensures
(llist_fragment_head l phead head ==
vbind ((ccell_is_lvalue head)
`star`
((ccell head) `vrefine` (llist_fragment_head_data_refine (L.hd (Ghost.reveal l)))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head
(L.hd (Ghost.reveal l))
(llist_fragment_head (L.tl (Ghost.reveal l)))))) | let llist_fragment_head_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(requires (Cons? (Ghost.reveal l)))
(ensures (
llist_fragment_head l phead head ==
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
))
= assert_norm
(llist_fragment_head l phead head == (
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
)) | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 6,
"end_line": 844,
"start_col": 0,
"start_line": 824
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end
let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2
[@@__steel_reduce__]
let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop
= vptr tail2 `vrefine` queue_tail_refine tail1 tail2
[@@__steel_reduce__]
let queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop
= vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1
[@@__steel_reduce__; __reduce__]
let queue_tail
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
=
llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l
val intro_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun _ -> queue_tail x l)
(fun h ->
sel_llist_fragment_tail l (cllist_head x) h == tail /\
sel (cllist_tail x) h == tail /\
ccell_ptrvalue_is_null (sel tail h)
)
(fun _ _ _ -> True)
let intro_queue_tail
x l tail
=
intro_vrefine (vptr tail) (queue_tail_refine tail tail);
intro_vdep2
(vptr (cllist_tail x))
(vptr tail `vrefine` queue_tail_refine tail tail)
tail
(queue_tail_dep2 x l tail);
intro_vdep2
(llist_fragment_tail l (cllist_head x))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail)
tail
(queue_tail_dep1 x l)
val elim_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(queue_tail x l)
(fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun h -> True)
(fun _ tail h ->
sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\
sel (cllist_tail x) h == Ghost.reveal tail /\
ccell_ptrvalue_is_null (h (vptr tail))
)
let elim_queue_tail
#_ #a x l
=
let tail0 = elim_vdep
(llist_fragment_tail l (cllist_head x))
(queue_tail_dep1 x l)
in
let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in
change_equal_slprop
(queue_tail_dep1 x l (Ghost.reveal tail0))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0);
let tail2 = elim_vdep
(vptr (cllist_tail x))
(queue_tail_dep2 x l tail0)
in
let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in
change_equal_slprop
(queue_tail_dep2 x l tail0 (Ghost.reveal tail2))
(vptr tail3 `vrefine` queue_tail_refine tail0 tail3);
elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3);
change_equal_slprop
(vptr tail3)
(vptr tail);
tail
(* view from the head *)
let llist_fragment_head_data_refine
(#a: Type)
(d: a)
(c: vcell a)
: Tot prop
= c.vcell_data == d
let llist_fragment_head_payload
(#a: Type)
(head: ccell_ptrvalue a)
(d: a)
(llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop))
(x: t_of (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine d)))
: Tot vprop
=
llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next
let rec llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Tot vprop
(decreases (Ghost.reveal l))
=
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
let t_of_llist_fragment_head
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(t_of (llist_fragment_head l phead head) == ref (ccell_ptrvalue a) & ccell_ptrvalue a)
= ()
unfold
let sel_llist_fragment_head
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_head l phead head) /\ True) })
: GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
=
coerce (h (llist_fragment_head l phead head)) (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
val intro_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_head l phead head)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_head l phead head h' == (phead, head))
let intro_llist_fragment_head_nil
l phead head
=
intro_vconst (phead, head);
change_equal_slprop
(vconst (phead, head))
(llist_fragment_head l phead head)
val elim_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_head l phead head h == (phead, head))
let elim_llist_fragment_head_nil
l phead head
=
change_equal_slprop
(llist_fragment_head l phead head)
(vconst (phead, head));
elim_vconst (phead, head) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
l: FStar.Ghost.erased (Prims.list a) ->
phead: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) ->
head: CQueue.Cell.ccell_ptrvalue a
-> FStar.Pervasives.Lemma (requires Cons? (FStar.Ghost.reveal l))
(ensures
CQueue.llist_fragment_head l phead head ==
CQueue.vbind (Steel.Effect.Common.star (CQueue.Cell.ccell_is_lvalue head)
(Steel.Effect.Common.vrefine (CQueue.Cell.ccell head)
(CQueue.llist_fragment_head_data_refine (FStar.List.Tot.Base.hd (FStar.Ghost.reveal
l)))))
(Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) * CQueue.Cell.ccell_ptrvalue a)
(CQueue.llist_fragment_head_payload head
(FStar.List.Tot.Base.hd (FStar.Ghost.reveal l))
(CQueue.llist_fragment_head (FStar.Ghost.hide (FStar.List.Tot.Base.tl (FStar.Ghost.reveal
l)))))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Ghost.erased",
"Prims.list",
"Steel.Reference.ref",
"CQueue.Cell.ccell_ptrvalue",
"FStar.Pervasives.assert_norm",
"CQueue.op_Equals_Equals",
"Steel.Effect.Common.vprop",
"CQueue.llist_fragment_head",
"Prims.uu___is_Nil",
"FStar.Ghost.reveal",
"CQueue.vconst",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"CQueue.vbind",
"Steel.Effect.Common.star",
"CQueue.Cell.ccell_is_lvalue",
"Steel.Effect.Common.vrefine",
"CQueue.Cell.ccell",
"CQueue.llist_fragment_head_data_refine",
"FStar.List.Tot.Base.hd",
"CQueue.llist_fragment_head_payload",
"FStar.Ghost.hide",
"FStar.List.Tot.Base.tl",
"Prims.unit",
"Prims.b2t",
"Prims.uu___is_Cons",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let llist_fragment_head_eq_cons
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: Lemma (requires (Cons? (Ghost.reveal l)))
(ensures
(llist_fragment_head l phead head ==
vbind ((ccell_is_lvalue head)
`star`
((ccell head) `vrefine` (llist_fragment_head_data_refine (L.hd (Ghost.reveal l)))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head
(L.hd (Ghost.reveal l))
(llist_fragment_head (L.tl (Ghost.reveal l)))))) =
| assert_norm (llist_fragment_head l phead head ==
(if Nil? l
then vconst (phead, head)
else
vbind ((ccell_is_lvalue head)
`star`
((ccell head) `vrefine` (llist_fragment_head_data_refine (L.hd (Ghost.reveal l)))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head
(L.hd (Ghost.reveal l))
(llist_fragment_head (L.tl (Ghost.reveal l)))))) | false |
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.update_heap32_def | val update_heap32_def (ptr: int) (v: nat32) (mem: machine_heap) : machine_heap | val update_heap32_def (ptr: int) (v: nat32) (mem: machine_heap) : machine_heap | let update_heap32_def (ptr:int) (v:nat32) (mem:machine_heap) : machine_heap =
let v = nat_to_four 8 v in
let mem = mem.[ptr] <- v.lo0 in
let mem = mem.[ptr + 1] <- v.lo1 in
let mem = mem.[ptr + 2] <- v.hi2 in
let mem = mem.[ptr + 3] <- v.hi3 in
mem | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 54,
"start_col": 0,
"start_line": 48
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
)
[@"opaque_to_smt"] let get_heap_val64 = opaque_make get_heap_val64_def
irreducible let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def
let get_heap_val128_def (ptr:int) (mem:machine_heap) : quad32 = Mkfour
(get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem)
(get_heap_val32 (ptr + 12) mem)
[@"opaque_to_smt"] let get_heap_val128 = opaque_make get_heap_val128_def
irreducible let get_heap_val128_reveal = opaque_revealer (`%get_heap_val128) get_heap_val128 get_heap_val128_def | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ptr: Prims.int -> v: Vale.Def.Types_s.nat32 -> mem: Vale.Arch.MachineHeap_s.machine_heap
-> Vale.Arch.MachineHeap_s.machine_heap | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.Def.Types_s.nat32",
"Vale.Arch.MachineHeap_s.machine_heap",
"FStar.Map.t",
"Vale.Def.Words_s.nat8",
"Vale.Arch.MachineHeap_s.op_String_Assignment",
"Vale.Def.Types_s.nat8",
"Prims.op_Addition",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Words_s.natN",
"Prims.pow2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Words_s.four",
"Vale.Def.Words.Four_s.nat_to_four"
] | [] | false | false | false | true | false | let update_heap32_def (ptr: int) (v: nat32) (mem: machine_heap) : machine_heap =
| let v = nat_to_four 8 v in
let mem = mem.[ ptr ] <- v.lo0 in
let mem = mem.[ ptr + 1 ] <- v.lo1 in
let mem = mem.[ ptr + 2 ] <- v.hi2 in
let mem = mem.[ ptr + 3 ] <- v.hi3 in
mem | false |
Vale.Arch.MachineHeap_s.fst | Vale.Arch.MachineHeap_s.update_heap64_def | val update_heap64_def (ptr: int) (v: nat64) (mem: machine_heap) : machine_heap | val update_heap64_def (ptr: int) (v: nat64) (mem: machine_heap) : machine_heap | let update_heap64_def (ptr:int) (v:nat64) (mem:machine_heap) : machine_heap =
let v = nat_to_two 32 v in
let lo = nat_to_four 8 v.lo in
let hi = nat_to_four 8 v.hi in
let mem = mem.[ptr] <- lo.lo0 in
let mem = mem.[ptr + 1] <- lo.lo1 in
let mem = mem.[ptr + 2] <- lo.hi2 in
let mem = mem.[ptr + 3] <- lo.hi3 in
let mem = mem.[ptr + 4] <- hi.lo0 in
let mem = mem.[ptr + 5] <- hi.lo1 in
let mem = mem.[ptr + 6] <- hi.hi2 in
let mem = mem.[ptr + 7] <- hi.hi3 in
mem | {
"file_name": "vale/specs/hardware/Vale.Arch.MachineHeap_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 70,
"start_col": 0,
"start_line": 58
} | module Vale.Arch.MachineHeap_s
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let machine_heap = Map.t int nat8
let is_machine_heap_update (mh mh':machine_heap) =
Set.equal (Map.domain mh) (Map.domain mh') /\
(forall (i:int).{:pattern Map.sel mh i \/ Map.sel mh' i}
not (Map.contains mh i) ==> Map.sel mh i == Map.sel mh' i)
let get_heap_val32_def (ptr:int) (mem:machine_heap) : nat32 =
four_to_nat 8
(Mkfour
mem.[ptr]
mem.[ptr + 1]
mem.[ptr + 2]
mem.[ptr + 3])
[@"opaque_to_smt"] let get_heap_val32 = opaque_make get_heap_val32_def
irreducible let get_heap_val32_reveal = opaque_revealer (`%get_heap_val32) get_heap_val32 get_heap_val32_def
let get_heap_val64_def (ptr:int) (mem:machine_heap) : nat64 =
two_to_nat 32
(Mktwo
(four_to_nat 8 (Mkfour mem.[ptr] mem.[ptr + 1] mem.[ptr + 2] mem.[ptr + 3]))
(four_to_nat 8 (Mkfour mem.[ptr + 4] mem.[ptr + 5] mem.[ptr + 6] mem.[ptr + 7]))
)
[@"opaque_to_smt"] let get_heap_val64 = opaque_make get_heap_val64_def
irreducible let get_heap_val64_reveal = opaque_revealer (`%get_heap_val64) get_heap_val64 get_heap_val64_def
let get_heap_val128_def (ptr:int) (mem:machine_heap) : quad32 = Mkfour
(get_heap_val32 ptr mem)
(get_heap_val32 (ptr + 4) mem)
(get_heap_val32 (ptr + 8) mem)
(get_heap_val32 (ptr + 12) mem)
[@"opaque_to_smt"] let get_heap_val128 = opaque_make get_heap_val128_def
irreducible let get_heap_val128_reveal = opaque_revealer (`%get_heap_val128) get_heap_val128 get_heap_val128_def
let update_heap32_def (ptr:int) (v:nat32) (mem:machine_heap) : machine_heap =
let v = nat_to_four 8 v in
let mem = mem.[ptr] <- v.lo0 in
let mem = mem.[ptr + 1] <- v.lo1 in
let mem = mem.[ptr + 2] <- v.hi2 in
let mem = mem.[ptr + 3] <- v.hi3 in
mem
[@"opaque_to_smt"] let update_heap32 = opaque_make update_heap32_def
irreducible let update_heap32_reveal = opaque_revealer (`%update_heap32) update_heap32 update_heap32_def | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.MachineHeap_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ptr: Prims.int -> v: Vale.Def.Types_s.nat64 -> mem: Vale.Arch.MachineHeap_s.machine_heap
-> Vale.Arch.MachineHeap_s.machine_heap | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.Def.Types_s.nat64",
"Vale.Arch.MachineHeap_s.machine_heap",
"FStar.Map.t",
"Vale.Def.Words_s.nat8",
"Vale.Arch.MachineHeap_s.op_String_Assignment",
"Vale.Def.Types_s.nat8",
"Prims.op_Addition",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Words_s.natN",
"Prims.pow2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Words_s.four",
"Vale.Def.Words.Four_s.nat_to_four",
"Vale.Def.Words_s.__proj__Mktwo__item__hi",
"Vale.Def.Words_s.__proj__Mktwo__item__lo",
"Vale.Def.Words_s.two",
"Vale.Def.Words.Two_s.nat_to_two"
] | [] | false | false | false | true | false | let update_heap64_def (ptr: int) (v: nat64) (mem: machine_heap) : machine_heap =
| let v = nat_to_two 32 v in
let lo = nat_to_four 8 v.lo in
let hi = nat_to_four 8 v.hi in
let mem = mem.[ ptr ] <- lo.lo0 in
let mem = mem.[ ptr + 1 ] <- lo.lo1 in
let mem = mem.[ ptr + 2 ] <- lo.hi2 in
let mem = mem.[ ptr + 3 ] <- lo.hi3 in
let mem = mem.[ ptr + 4 ] <- hi.lo0 in
let mem = mem.[ ptr + 5 ] <- hi.lo1 in
let mem = mem.[ ptr + 6 ] <- hi.hi2 in
let mem = mem.[ ptr + 7 ] <- hi.hi3 in
mem | false |
Steel.MonotonicReference.fsti | Steel.MonotonicReference.property | val property : a: Type -> Type | let property (a:Type)
= a -> prop | {
"file_name": "lib/steel/Steel.MonotonicReference.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 13,
"end_line": 70,
"start_col": 0,
"start_line": 69
} | (*
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.MonotonicReference
open FStar.PCM
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module Preorder = FStar.Preorder
/// A library for Steel references that are monotonic with respect to a user-specified preorder.
/// This library builds on top of Steel.HigherReference, and is specialized to values at universe 1.
/// An abstract datatype for monotonic references
val ref (a:Type u#0) (p:Preorder.preorder a)
: Type u#0
/// The standard points to separation logic predicate
val pts_to_sl (#a:Type)
(#p:Preorder.preorder a)
(r:ref a p)
(f:perm)
(v:a)
: slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector
[@@ __steel_reduce__]
unfold
let pts_to (#a:Type)
(#p:Preorder.preorder a)
(r:ref a p)
(f:perm)
(v:a)
: vprop
= to_vprop (pts_to_sl r f v)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc (#a:Type) (p:Preorder.preorder a) (v:a)
: SteelT (ref a p) emp (fun r -> pts_to r full_perm v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write (#a:Type) (#p:Preorder.preorder a) (#v:erased a)
(r:ref a p) (x:a)
: Steel unit (pts_to r full_perm v)
(fun v -> pts_to r full_perm x)
(requires fun _ -> p v x /\ True)
(ensures fun _ _ _ -> True) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.MonotonicReference.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type -> Type | Prims.Tot | [
"total"
] | [] | [
"Prims.prop"
] | [] | false | false | false | true | true | let property (a: Type) =
| a -> prop | false |
|
Steel.MonotonicReference.fsti | Steel.MonotonicReference.stable_property | val stable_property : p: FStar.Preorder.preorder a -> Type | let stable_property (#a:Type) (p:Preorder.preorder a)
= fact:property a { Preorder.stable fact p } | {
"file_name": "lib/steel/Steel.MonotonicReference.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 46,
"end_line": 80,
"start_col": 0,
"start_line": 79
} | (*
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.MonotonicReference
open FStar.PCM
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module Preorder = FStar.Preorder
/// A library for Steel references that are monotonic with respect to a user-specified preorder.
/// This library builds on top of Steel.HigherReference, and is specialized to values at universe 1.
/// An abstract datatype for monotonic references
val ref (a:Type u#0) (p:Preorder.preorder a)
: Type u#0
/// The standard points to separation logic predicate
val pts_to_sl (#a:Type)
(#p:Preorder.preorder a)
(r:ref a p)
(f:perm)
(v:a)
: slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector
[@@ __steel_reduce__]
unfold
let pts_to (#a:Type)
(#p:Preorder.preorder a)
(r:ref a p)
(f:perm)
(v:a)
: vprop
= to_vprop (pts_to_sl r f v)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc (#a:Type) (p:Preorder.preorder a) (v:a)
: SteelT (ref a p) emp (fun r -> pts_to r full_perm v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write (#a:Type) (#p:Preorder.preorder a) (#v:erased a)
(r:ref a p) (x:a)
: Steel unit (pts_to r full_perm v)
(fun v -> pts_to r full_perm x)
(requires fun _ -> p v x /\ True)
(ensures fun _ _ _ -> True)
/// A wrapper around a predicate that depends on a value of type [a]
let property (a:Type)
= a -> prop
/// A wrapper around a property [fact] that has been witnessed to be true and stable
/// with respect to preorder [p]
val witnessed (#a:Type u#0) (#p:Preorder.preorder a) (r:ref a p) (fact:property a)
: Type0
/// The type of properties depending on values of type [a], and that | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.MonotonicReference.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: FStar.Preorder.preorder a -> Type | Prims.Tot | [
"total"
] | [] | [
"FStar.Preorder.preorder",
"Steel.MonotonicReference.property",
"FStar.Preorder.stable"
] | [] | false | false | false | true | true | let stable_property (#a: Type) (p: Preorder.preorder a) =
| fact: property a {Preorder.stable fact p} | false |
|
CQueue.fst | CQueue.llist_fragment_tail_cons_rewrite | val llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) {Cons? (Ghost.reveal l)})
(llist_fragment_tail: vprop{t_of llist_fragment_tail == ref (ccell_ptrvalue a)})
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a)) | val llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) {Cons? (Ghost.reveal l)})
(llist_fragment_tail: vprop{t_of llist_fragment_tail == ref (ccell_ptrvalue a)})
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a)) | let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 14,
"end_line": 384,
"start_col": 0,
"start_line": 377
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
l: FStar.Ghost.erased (Prims.list a) {Cons? (FStar.Ghost.reveal l)} ->
llist_fragment_tail:
Steel.Effect.Common.vprop
{ Steel.Effect.Common.t_of llist_fragment_tail ==
Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) } ->
x:
Steel.Effect.Common.normal (Steel.Effect.Common.t_of (Steel.Effect.Common.vdep llist_fragment_tail
(CQueue.llist_fragment_tail_cons_next_payload l)))
-> Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) | Prims.Tot | [
"total"
] | [] | [
"FStar.Ghost.erased",
"Prims.list",
"Prims.b2t",
"Prims.uu___is_Cons",
"FStar.Ghost.reveal",
"Steel.Effect.Common.vprop",
"CQueue.op_Equals_Equals",
"Steel.Effect.Common.t_of",
"Steel.Reference.ref",
"CQueue.Cell.ccell_ptrvalue",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.vdep",
"CQueue.llist_fragment_tail_cons_next_payload",
"Steel.Effect.Common.VUnit",
"Steel.Effect.Common.Mkvprop'",
"Steel.Effect.Common.vrefine_hp",
"Steel.Reference.ptrp",
"Steel.FractionalPermission.full_perm",
"Steel.Reference.ptrp_sel",
"CQueue.ccell_is_lvalue_refine",
"Steel.Effect.Common.vrefine_sel",
"Steel.Effect.Common.vdep_payload",
"CQueue.Cell.ccell_lvalue",
"CQueue.Cell.ccell_data",
"CQueue.llist_fragment_tail_cons_data_refine",
"CQueue.Cell.ccell_next",
"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"
] | [] | false | false | false | false | false | let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) {Cons? (Ghost.reveal l)})
(llist_fragment_tail: vprop{t_of llist_fragment_tail == ref (ccell_ptrvalue a)})
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a)) =
| let (| _ , (| c , _ |) |) = x in
ccell_next c | false |
Steel.MonotonicReference.fsti | Steel.MonotonicReference.pts_to | val pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: a) : vprop | val pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: a) : vprop | let pts_to (#a:Type)
(#p:Preorder.preorder a)
(r:ref a p)
(f:perm)
(v:a)
: vprop
= to_vprop (pts_to_sl r f v) | {
"file_name": "lib/steel/Steel.MonotonicReference.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 31,
"end_line": 53,
"start_col": 0,
"start_line": 47
} | (*
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.MonotonicReference
open FStar.PCM
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module Preorder = FStar.Preorder
/// A library for Steel references that are monotonic with respect to a user-specified preorder.
/// This library builds on top of Steel.HigherReference, and is specialized to values at universe 1.
/// An abstract datatype for monotonic references
val ref (a:Type u#0) (p:Preorder.preorder a)
: Type u#0
/// The standard points to separation logic predicate
val pts_to_sl (#a:Type)
(#p:Preorder.preorder a)
(r:ref a p)
(f:perm)
(v:a)
: slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector
[@@ __steel_reduce__] | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.MonotonicReference.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r: Steel.MonotonicReference.ref a p -> f: Steel.FractionalPermission.perm -> v: a
-> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"FStar.Preorder.preorder",
"Steel.MonotonicReference.ref",
"Steel.FractionalPermission.perm",
"Steel.Effect.Common.to_vprop",
"Steel.MonotonicReference.pts_to_sl",
"Steel.Effect.Common.vprop"
] | [] | false | false | false | false | false | let pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: a) : vprop =
| to_vprop (pts_to_sl r f v) | false |
Hacl.Impl.Blake2.Core.fsti | Hacl.Impl.Blake2.Core.row_len | val row_len (a: Spec.alg) (m: m_spec) : size_t | val row_len (a: Spec.alg) (m: m_spec) : size_t | let row_len (a:Spec.alg) (m:m_spec) : size_t =
match a,m with
| Spec.Blake2S,M128 -> 1ul
| Spec.Blake2S,M256 -> 1ul
| Spec.Blake2B,M256 -> 1ul
| _ -> 4ul | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 12,
"end_line": 41,
"start_col": 0,
"start_line": 36
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
type m_spec =
| M32
| M128
| M256
noextract inline_for_extraction
type word_t (a:Spec.alg) = Spec.word_t a
noextract inline_for_extraction
let element_t (a:Spec.alg) (m:m_spec) =
match a,m with
| Spec.Blake2S,M128 -> (vec_t U32 4)
| Spec.Blake2S,M256 -> (vec_t U32 4)
| Spec.Blake2B,M256 -> (vec_t U64 4)
| _ -> (word_t a)
noextract inline_for_extraction
val zero_element: a:Spec.alg -> m:m_spec -> element_t a m | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Blake2.Core.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec -> Lib.IntTypes.size_t | Prims.Tot | [
"total"
] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"FStar.Pervasives.Native.Mktuple2",
"FStar.UInt32.__uint_to_t",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.size_t"
] | [] | false | false | false | true | false | let row_len (a: Spec.alg) (m: m_spec) : size_t =
| match a, m with
| Spec.Blake2S, M128 -> 1ul
| Spec.Blake2S, M256 -> 1ul
| Spec.Blake2B, M256 -> 1ul
| _ -> 4ul | false |
Hacl.Impl.Blake2.Core.fsti | Hacl.Impl.Blake2.Core.row_p | val row_p : a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec -> Type0 | let row_p (a:Spec.alg) (m:m_spec) =
lbuffer (element_t a m) (row_len a m) | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 39,
"end_line": 45,
"start_col": 7,
"start_line": 44
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
type m_spec =
| M32
| M128
| M256
noextract inline_for_extraction
type word_t (a:Spec.alg) = Spec.word_t a
noextract inline_for_extraction
let element_t (a:Spec.alg) (m:m_spec) =
match a,m with
| Spec.Blake2S,M128 -> (vec_t U32 4)
| Spec.Blake2S,M256 -> (vec_t U32 4)
| Spec.Blake2B,M256 -> (vec_t U64 4)
| _ -> (word_t a)
noextract inline_for_extraction
val zero_element: a:Spec.alg -> m:m_spec -> element_t a m
noextract inline_for_extraction
let row_len (a:Spec.alg) (m:m_spec) : size_t =
match a,m with
| Spec.Blake2S,M128 -> 1ul
| Spec.Blake2S,M256 -> 1ul
| Spec.Blake2B,M256 -> 1ul
| _ -> 4ul | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Blake2.Core.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Lib.Buffer.lbuffer",
"Hacl.Impl.Blake2.Core.element_t",
"Hacl.Impl.Blake2.Core.row_len"
] | [] | false | false | false | true | true | let row_p (a: Spec.alg) (m: m_spec) =
| lbuffer (element_t a m) (row_len a m) | false |
|
Hacl.Impl.Blake2.Core.fsti | Hacl.Impl.Blake2.Core.get_blake2s_salt | val get_blake2s_salt : p: Hacl.Impl.Blake2.Core.blake2s_params
-> Lib.Buffer.lbuffer_t Lib.Buffer.MUT
(Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
(8ul <: FStar.UInt32.t) | let get_blake2s_salt (p: blake2s_params) = p.salt | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 49,
"end_line": 84,
"start_col": 0,
"start_line": 84
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
type m_spec =
| M32
| M128
| M256
noextract inline_for_extraction
type word_t (a:Spec.alg) = Spec.word_t a
noextract inline_for_extraction
let element_t (a:Spec.alg) (m:m_spec) =
match a,m with
| Spec.Blake2S,M128 -> (vec_t U32 4)
| Spec.Blake2S,M256 -> (vec_t U32 4)
| Spec.Blake2B,M256 -> (vec_t U64 4)
| _ -> (word_t a)
noextract inline_for_extraction
val zero_element: a:Spec.alg -> m:m_spec -> element_t a m
noextract inline_for_extraction
let row_len (a:Spec.alg) (m:m_spec) : size_t =
match a,m with
| Spec.Blake2S,M128 -> 1ul
| Spec.Blake2S,M256 -> 1ul
| Spec.Blake2B,M256 -> 1ul
| _ -> 4ul
noextract inline_for_extraction
unfold let row_p (a:Spec.alg) (m:m_spec) =
lbuffer (element_t a m) (row_len a m)
noextract inline_for_extraction
val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a)
noextract
val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m ->
Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==>
row_v h0 r1 == row_v h1 r2))
[SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)]
noextract inline_for_extraction
let salt_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noextract inline_for_extraction
let personal_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lbuffer uint8 8ul;
personal: lbuffer uint8 8ul;
} | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Blake2.Core.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.Blake2.Core.blake2s_params
-> Lib.Buffer.lbuffer_t Lib.Buffer.MUT
(Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
(8ul <: FStar.UInt32.t) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.Blake2.Core.blake2s_params",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__salt",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t"
] | [] | false | false | false | false | false | let get_blake2s_salt (p: blake2s_params) =
| p.salt | false |
|
CQueue.fst | CQueue.queue_head_refine | val queue_head_refine
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
(tl: ref (ccell_ptrvalue a))
: Tot prop | val queue_head_refine
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
(tl: ref (ccell_ptrvalue a))
: Tot prop | let queue_head_refine
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
(tl: ref (ccell_ptrvalue a))
: Tot prop
= let ptl : (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = ptl in
tl == fst ptl /\ ccell_ptrvalue_is_null (snd ptl) == true | {
"file_name": "share/steel/examples/steel/CQueue.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 59,
"end_line": 1166,
"start_col": 0,
"start_line": 1157
} | module CQueue
open CQueue.LList
#set-options "--ide_id_info_off"
//Re-define squash, since this module explicitly
//replies on proving equalities of the form `t_of v == squash p`
//which are delicate in the presence of optimizations that
//unfold `Prims.squash (p /\ q)`to _:unit{p /\ q}
//See Issue #2496
let squash (p:Type u#a) : Type0 = squash p
(* BEGIN library *)
let intro_vrewrite_no_norm (#opened:inames)
(v: vprop) (#t: Type) (f: (t_of v) -> GTot t)
: SteelGhost unit opened v (fun _ -> vrewrite v f)
(fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v))
=
intro_vrewrite v f
let elim_vrewrite_no_norm (#opened:inames)
(v: vprop)
(#t: Type)
(f: ((t_of v) -> GTot t))
: SteelGhost unit opened (vrewrite v f) (fun _ -> v)
(fun _ -> True)
(fun h _ h' -> h (vrewrite v f) == f (h' v))
=
elim_vrewrite v f
let vconst_sel
(#a: Type)
(x: a)
: Tot (selector a (hp_of emp))
= fun _ -> x
[@@ __steel_reduce__]
let vconst'
(#a: Type)
(x: a)
: GTot vprop'
= {
hp = hp_of emp;
t = a;
sel = vconst_sel x;
}
[@@ __steel_reduce__]
let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x)
let intro_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
emp
(fun _ -> vconst x)
(fun _ -> True)
(fun _ _ h' -> h' (vconst x) == x)
=
change_slprop_rel
emp
(vconst x)
(fun _ y -> y == x)
(fun _ -> ())
let elim_vconst
(#opened: _)
(#a: Type)
(x: a)
: SteelGhost unit opened
(vconst x)
(fun _ -> emp)
(fun _ -> True)
(fun h _ _ -> h (vconst x) == x)
=
change_slprop_rel
(vconst x)
emp
(fun y _ -> y == x)
(fun _ -> ())
let vpure_sel'
(p: prop)
: Tot (selector' (squash p) (Steel.Memory.pure p))
= fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m
let vpure_sel
(p: prop)
: Tot (selector (squash p) (Steel.Memory.pure p))
= vpure_sel' p
[@@ __steel_reduce__]
let vpure'
(p: prop)
: GTot vprop'
= {
hp = Steel.Memory.pure p;
t = squash p;
sel = vpure_sel p;
}
[@@ __steel_reduce__]
let vpure (p: prop) : Tot vprop = VUnit (vpure' p)
let intro_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
emp
(fun _ -> vpure p)
(fun _ -> p)
(fun _ _ h' -> p)
=
change_slprop_rel
emp
(vpure p)
(fun _ _ -> p)
(fun m -> pure_interp p m)
let elim_vpure
(#opened: _)
(p: prop)
: SteelGhost unit opened
(vpure p)
(fun _ -> emp)
(fun _ -> True)
(fun _ _ _ -> p)
=
change_slprop_rel
(vpure p)
emp
(fun _ _ -> p)
(fun m -> pure_interp p m; reveal_emp (); intro_emp m)
val intro_vdep2 (#opened:inames)
(v: vprop)
(q: vprop)
(x: t_of v)
(p: (t_of v -> Tot vprop))
: SteelGhost unit opened
(v `star` q)
(fun _ -> vdep v p)
(requires (fun h ->
q == p x /\
x == h v
))
(ensures (fun h _ h' ->
let x2 = h' (vdep v p) in
q == p (h v) /\
dfst x2 == (h v) /\
dsnd x2 == (h q)
))
let intro_vdep2
v q x p
=
intro_vdep v q p
let vbind0_payload
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: t_of a)
: Tot vprop
= vpure (t == t_of (b x)) `star` b x
let vbind0_rewrite
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
(x: normal (t_of (vdep a (vbind0_payload a t b))))
: Tot t
= snd (dsnd x)
[@@__steel_reduce__; __reduce__]
let vbind0
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b
let vbind_hp // necessary to hide the attribute on hp_of
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot (slprop u#1)
= hp_of (vbind0 a t b)
let vbind_sel // same for hp_sel
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot (selector t (vbind_hp a t b))
= sel_of (vbind0 a t b)
[@@__steel_reduce__]
let vbind'
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: GTot vprop'
= {
hp = vbind_hp a t b;
t = t;
sel = vbind_sel a t b;
}
[@@__steel_reduce__]
let vbind
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: Tot vprop
= VUnit (vbind' a t b)
let intro_vbind
(#opened: _)
(a: vprop)
(b' : vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost unit opened
(a `star` b')
(fun _ -> vbind a t b)
(fun h -> t_of b' == t /\ b' == b (h a))
(fun h _ h' ->
t_of b' == t /\
b' == b (h a) /\
h' (vbind a t b) == h b'
)
=
intro_vpure (t == t_of b');
intro_vdep
a
(vpure (t == t_of b') `star` b')
(vbind0_payload a t b);
intro_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
change_slprop_rel
(vbind0 a t b)
(vbind a t b)
(fun x y -> x == y)
(fun _ -> ())
let elim_vbind
(#opened: _)
(a: vprop)
(t: Type0)
(b: (t_of a -> Tot vprop))
: SteelGhost (Ghost.erased (t_of a)) opened
(vbind a t b)
(fun res -> a `star` b (Ghost.reveal res))
(fun h -> True)
(fun h res h' ->
h' a == Ghost.reveal res /\
t == t_of (b (Ghost.reveal res)) /\
h' (b (Ghost.reveal res)) == h (vbind a t b)
)
=
change_slprop_rel
(vbind a t b)
(vbind0 a t b)
(fun x y -> x == y)
(fun _ -> ());
elim_vrewrite
(a `vdep` vbind0_payload a t b)
(vbind0_rewrite a t b);
let res = elim_vdep a (vbind0_payload a t b) in
change_equal_slprop
(vbind0_payload a t b (Ghost.reveal res))
(vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res));
elim_vpure (t == t_of (b (Ghost.reveal res)));
res
let (==) (#a:_) (x y: a) : prop = x == y
let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma
(requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2]))
(ensures (hd1 == hd2 /\ tl1 == tl2))
[SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])]
= L.lemma_snoc_unsnoc (hd1, tl1);
L.lemma_snoc_unsnoc (hd2, tl2)
[@"opaque_to_smt"]
let unsnoc (#a: Type) (l: list a) : Pure (list a & a)
(requires (Cons? l))
(ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l))
=
L.lemma_unsnoc_snoc l;
L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)];
L.unsnoc l
let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' <
L.length l)) = fst (unsnoc l)
let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l)
[@@"opaque_to_smt"]
let snoc (#a: Type) (l: list a) (x: a) : Pure (list a)
(requires True)
(ensures (fun l' ->
Cons? l' /\
unsnoc_hd l' == l /\
unsnoc_tl l' == x
))
=
let l' = L.snoc (l, x) in
L.append_length l [x];
snoc_inj l (unsnoc_hd l') x (unsnoc_tl l');
l'
let snoc_unsnoc
(#a: Type)
(l: list a)
: Lemma
(requires (Cons? l))
(ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l))
= ()
unfold
let coerce
(#a: Type)
(x: a)
(b: Type)
: Pure b
(requires (a == b))
(ensures (fun y -> a == b /\ x == y))
= x
(* END library *)
let t a = cllist_lvalue a
let v (a: Type0) = list a
let datas
(#a: Type0)
(l: v a)
: Tot (list a)
= l
(* view from the tail *)
let llist_fragment_tail_cons_data_refine
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(d: a)
: Tot prop
= d == unsnoc_tl (Ghost.reveal l)
[@@ __steel_reduce__]
let llist_fragment_tail_cons_lvalue_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(c: ccell_lvalue a)
: Tot vprop
= vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l
let ccell_is_lvalue_refine
(a: Type)
(c: ccell_ptrvalue a)
: Tot prop
= ccell_ptrvalue_is_null c == false
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_next_payload
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(ptail: ref (ccell_ptrvalue a))
: Tot vprop
= vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l
[@@ __steel_reduce__ ]
let llist_fragment_tail_cons_rewrite
(#a: Type)
(l: Ghost.erased (list a) { Cons? (Ghost.reveal l) })
(llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) })
(x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l))))
: Tot (ref (ccell_ptrvalue a))
= let (| _, (| c, _ |) |) = x in
ccell_next c
let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop
(requires True)
(ensures (fun v -> t_of v == ref (ccell_ptrvalue a)))
(decreases (Ghost.reveal (L.length l)))
= if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
let llist_fragment_tail_eq
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
= assert_norm
(llist_fragment_tail l phead == (
if Nil? l
then vconst phead
else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
))
let llist_fragment_tail_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
: Lemma
(requires (Cons? l))
(ensures (Cons? l /\
llist_fragment_tail l phead == (
llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead)
)))
= llist_fragment_tail_eq l phead
unfold
let sel_llist_fragment_tail
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a))
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) })
: GTot (ref (ccell_ptrvalue a))
=
coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a))
val intro_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_tail l phead)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead)
let intro_llist_fragment_tail_nil
l phead
=
intro_vconst phead;
change_equal_slprop
(vconst phead)
(llist_fragment_tail l phead)
val elim_llist_fragment_tail_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l phead)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_tail l phead h == phead)
let elim_llist_fragment_tail_nil
l phead
=
change_equal_slprop
(llist_fragment_tail l phead)
(vconst phead);
elim_vconst phead
val intro_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: Ghost.erased (ref (ccell_ptrvalue a)))
(tail: Ghost.erased (ccell_lvalue a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail))
(fun res -> llist_fragment_tail res phead)
(fun h ->
sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\
sel ptail h == Ghost.reveal tail
)
(fun h res h' ->
Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\
sel_llist_fragment_tail res phead h' == ccell_next tail
)
#push-options "--z3rlimit 16"
let intro_llist_fragment_tail_snoc
#_ #a l phead ptail tail
=
let d = gget (vptr (ccell_data tail)) in
let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in
intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l');
intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a);
intro_vdep
(vptr ptail `vrefine` ccell_is_lvalue_refine a)
(vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l')
(llist_fragment_tail_cons_lvalue_payload l');
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead);
intro_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)
(vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l')
(llist_fragment_tail_cons_next_payload l');
intro_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l')
(llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead));
llist_fragment_tail_eq_cons l' phead;
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead))
(llist_fragment_tail l' phead);
let g' = gget (llist_fragment_tail l' phead) in
assert (Ghost.reveal g' == ccell_next tail);
noop ();
l'
#pop-options
[@@erasable]
noeq
type ll_unsnoc_t (a: Type) = {
ll_unsnoc_l: list a;
ll_unsnoc_ptail: ref (ccell_ptrvalue a);
ll_unsnoc_tail: ccell_lvalue a;
}
val elim_llist_fragment_tail_snoc
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
: SteelGhost (ll_unsnoc_t a) opened
(llist_fragment_tail l phead)
(fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail))
(fun _ -> Cons? l)
(fun h res h' ->
Cons? l /\
Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\
sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\
sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\
sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\
sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail)
)
#push-options "--z3rlimit 32"
#restart-solver
let elim_llist_fragment_tail_snoc
#_ #a l phead
=
let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in
llist_fragment_tail_eq_cons l0 phead;
change_equal_slprop
(llist_fragment_tail l phead)
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
elim_vrewrite_no_norm
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0)
(llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead));
let ptail = elim_vdep
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail_cons_next_payload l0)
in
let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in
change_equal_slprop
(llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail))
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0);
let tail = elim_vdep
(vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a)
(llist_fragment_tail_cons_lvalue_payload l0)
in
elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a);
let res = {
ll_unsnoc_l = unsnoc_hd l0;
ll_unsnoc_ptail = Ghost.reveal ptail0;
ll_unsnoc_tail = Ghost.reveal tail;
} in
change_equal_slprop
(vptr (Ghost.reveal ptail0))
(vptr res.ll_unsnoc_ptail);
change_equal_slprop
(llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail))
(vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0);
elim_vrefine
(vptr (ccell_data res.ll_unsnoc_tail))
(llist_fragment_tail_cons_data_refine l0);
change_equal_slprop
(llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)
(llist_fragment_tail res.ll_unsnoc_l phead);
res
#pop-options
let rec llist_fragment_tail_append
(#opened: _)
(#a: Type)
(phead0: ref (ccell_ptrvalue a))
(l1: Ghost.erased (list a))
(phead1: Ghost.erased (ref (ccell_ptrvalue a)))
(l2: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1)
(fun res -> llist_fragment_tail res phead0)
(fun h ->
Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h
)
(fun h res h' ->
Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
(sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h
)
(decreases (L.length (Ghost.reveal l2)))
=
let g1 = gget (llist_fragment_tail l1 phead0) in
assert (Ghost.reveal phead1 == Ghost.reveal g1);
if Nil? l2
then begin
L.append_l_nil (Ghost.reveal l1);
elim_llist_fragment_tail_nil l2 phead1;
l1
end else begin
let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in
let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in
L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d];
let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in
intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
end
let queue_tail_refine
(#a: Type)
(tail1: ref (ccell_ptrvalue a))
(tail2: ref (ccell_ptrvalue a))
(tl: normal (t_of (vptr tail2)))
: Tot prop
= ccell_ptrvalue_is_null tl == true /\ tail1 == tail2
[@@__steel_reduce__]
let queue_tail_dep2
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
(tail2: ref (ccell_ptrvalue a))
: Tot vprop
= vptr tail2 `vrefine` queue_tail_refine tail1 tail2
[@@__steel_reduce__]
let queue_tail_dep1
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail1: t_of (llist_fragment_tail l (cllist_head x)))
: Tot vprop
= vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1
[@@__steel_reduce__; __reduce__]
let queue_tail
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: Tot vprop
=
llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l
val intro_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(tail: ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun _ -> queue_tail x l)
(fun h ->
sel_llist_fragment_tail l (cllist_head x) h == tail /\
sel (cllist_tail x) h == tail /\
ccell_ptrvalue_is_null (sel tail h)
)
(fun _ _ _ -> True)
let intro_queue_tail
x l tail
=
intro_vrefine (vptr tail) (queue_tail_refine tail tail);
intro_vdep2
(vptr (cllist_tail x))
(vptr tail `vrefine` queue_tail_refine tail tail)
tail
(queue_tail_dep2 x l tail);
intro_vdep2
(llist_fragment_tail l (cllist_head x))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail)
tail
(queue_tail_dep1 x l)
val elim_queue_tail
(#opened: _)
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(queue_tail x l)
(fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail)
(fun h -> True)
(fun _ tail h ->
sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\
sel (cllist_tail x) h == Ghost.reveal tail /\
ccell_ptrvalue_is_null (h (vptr tail))
)
let elim_queue_tail
#_ #a x l
=
let tail0 = elim_vdep
(llist_fragment_tail l (cllist_head x))
(queue_tail_dep1 x l)
in
let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in
change_equal_slprop
(queue_tail_dep1 x l (Ghost.reveal tail0))
(vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0);
let tail2 = elim_vdep
(vptr (cllist_tail x))
(queue_tail_dep2 x l tail0)
in
let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in
change_equal_slprop
(queue_tail_dep2 x l tail0 (Ghost.reveal tail2))
(vptr tail3 `vrefine` queue_tail_refine tail0 tail3);
elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3);
change_equal_slprop
(vptr tail3)
(vptr tail);
tail
(* view from the head *)
let llist_fragment_head_data_refine
(#a: Type)
(d: a)
(c: vcell a)
: Tot prop
= c.vcell_data == d
let llist_fragment_head_payload
(#a: Type)
(head: ccell_ptrvalue a)
(d: a)
(llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop))
(x: t_of (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine d)))
: Tot vprop
=
llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next
let rec llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Tot vprop
(decreases (Ghost.reveal l))
=
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
let t_of_llist_fragment_head
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(t_of (llist_fragment_head l phead head) == ref (ccell_ptrvalue a) & ccell_ptrvalue a)
= ()
unfold
let sel_llist_fragment_head
(#a:Type) (#p:vprop)
(l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
(h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_head l phead head) /\ True) })
: GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
=
coerce (h (llist_fragment_head l phead head)) (ref (ccell_ptrvalue a) & ccell_ptrvalue a)
val intro_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
emp
(fun _ -> llist_fragment_head l phead head)
(fun _ -> Nil? l)
(fun _ _ h' -> sel_llist_fragment_head l phead head h' == (phead, head))
let intro_llist_fragment_head_nil
l phead head
=
intro_vconst (phead, head);
change_equal_slprop
(vconst (phead, head))
(llist_fragment_head l phead head)
val elim_llist_fragment_head_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> emp)
(fun _ -> Nil? l)
(fun h _ _ -> sel_llist_fragment_head l phead head h == (phead, head))
let elim_llist_fragment_head_nil
l phead head
=
change_equal_slprop
(llist_fragment_head l phead head)
(vconst (phead, head));
elim_vconst (phead, head)
let llist_fragment_head_eq_cons
(#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a)
: Lemma
(requires (Cons? (Ghost.reveal l)))
(ensures (
llist_fragment_head l phead head ==
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
))
= assert_norm
(llist_fragment_head l phead head == (
if Nil? l
then vconst (phead, head)
else
vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l))))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l))))
))
val intro_llist_fragment_head_cons
(#opened: _)
(#a: Type) (phead: ref (ccell_ptrvalue a)) (head: ccell_lvalue a) (next: (ccell_ptrvalue a)) (tl: Ghost.erased (list a))
: SteelGhost (Ghost.erased (list a)) opened
(ccell head `star` llist_fragment_head tl (ccell_next head) next)
(fun res -> llist_fragment_head res phead head)
(fun h -> (h (ccell head)).vcell_next == next)
(fun h res h' ->
Ghost.reveal res == (h (ccell head)).vcell_data :: Ghost.reveal tl /\
h' (llist_fragment_head res phead head) == h (llist_fragment_head tl (ccell_next head) next)
)
let intro_llist_fragment_head_cons
#_ #a phead head next tl
=
let vc = gget (ccell head) in
let l' : (l' : Ghost.erased (list a) { Cons? l' }) = Ghost.hide (vc.vcell_data :: tl) in
intro_ccell_is_lvalue head;
intro_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l'));
intro_vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l')))
(llist_fragment_head tl (ccell_next head) next)
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l')));
llist_fragment_head_eq_cons l' phead head;
change_equal_slprop
(vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l')))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l'))))
(llist_fragment_head l' phead head);
l'
[@@erasable]
noeq
type ll_uncons_t
(a: Type)
= {
ll_uncons_pnext: Ghost.erased (ref (ccell_ptrvalue a));
ll_uncons_next: Ghost.erased (ccell_ptrvalue a);
ll_uncons_tl: Ghost.erased (list a);
}
val elim_llist_fragment_head_cons
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost (ll_uncons_t a) opened
(llist_fragment_head l phead head)
(fun res -> ccell head `star` llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next)
(fun _ -> Cons? (Ghost.reveal l))
(fun h res h' ->
ccell_ptrvalue_is_null head == false /\
Ghost.reveal l == (h' (ccell head)).vcell_data :: Ghost.reveal res.ll_uncons_tl /\
Ghost.reveal res.ll_uncons_pnext == ccell_next head /\
Ghost.reveal res.ll_uncons_next == (h' (ccell head)).vcell_next /\
h' (llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next) == h (llist_fragment_head l phead head)
)
let elim_llist_fragment_head_cons
#_ #a l0 phead head
=
let l : (l : Ghost.erased (list a) { Cons? l }) = l0 in
change_equal_slprop
(llist_fragment_head l0 phead head)
(llist_fragment_head l phead head);
llist_fragment_head_eq_cons l phead head;
change_equal_slprop
(llist_fragment_head l phead head)
(vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l)))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l))));
let x = elim_vbind
(ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l)))
(ref (ccell_ptrvalue a) & ccell_ptrvalue a)
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)))
in
let head2 = gget (ccell_is_lvalue head) in
elim_ccell_is_lvalue head;
elim_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l));
let vhead2 = gget (ccell head) in
let res = {
ll_uncons_pnext = ccell_next head2;
ll_uncons_next = vhead2.vcell_next;
ll_uncons_tl = L.tl l;
} in
change_equal_slprop
(llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)) (Ghost.reveal x))
(llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next);
res
let rec llist_fragment_head_append
(#opened: _)
(#a: Type)
(l1: Ghost.erased (list a))
(phead1: ref (ccell_ptrvalue a))
(head1: ccell_ptrvalue a)
(l2: Ghost.erased (list a))
(phead2: ref (ccell_ptrvalue a))
(head2: ccell_ptrvalue a)
: SteelGhost (Ghost.erased (list a)) opened
(llist_fragment_head l1 phead1 head1 `star` llist_fragment_head l2 phead2 head2)
(fun l -> llist_fragment_head l phead1 head1)
(fun h -> sel_llist_fragment_head l1 phead1 head1 h == (Ghost.reveal phead2, Ghost.reveal head2))
(fun h l h' ->
Ghost.reveal l == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\
h' (llist_fragment_head l phead1 head1) == h (llist_fragment_head l2 phead2 head2)
)
(decreases (Ghost.reveal l1))
=
if Nil? l1
then begin
elim_llist_fragment_head_nil l1 phead1 head1;
change_equal_slprop
(llist_fragment_head l2 phead2 head2)
(llist_fragment_head l2 phead1 head1);
l2
end else begin
let u = elim_llist_fragment_head_cons l1 phead1 head1 in
let head1' : Ghost.erased (ccell_lvalue a) = head1 in
let l3 = llist_fragment_head_append u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next l2 phead2 head2 in
change_equal_slprop
(llist_fragment_head l3 u.ll_uncons_pnext u.ll_uncons_next)
(llist_fragment_head l3 (ccell_next head1') u.ll_uncons_next);
change_equal_slprop
(ccell head1)
(ccell head1');
let l4 = intro_llist_fragment_head_cons phead1 head1' u.ll_uncons_next l3 in
change_equal_slprop
(llist_fragment_head l4 phead1 head1')
(llist_fragment_head l4 phead1 head1);
l4
end
let rec llist_fragment_head_to_tail
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened
(vptr phead `star` llist_fragment_head l phead head)
(fun res -> llist_fragment_tail l phead `star` vptr res)
(fun h -> h (vptr phead) == head)
(fun h res h' ->
let v = sel_llist_fragment_head l phead head h in
fst v == Ghost.reveal res /\
fst v == sel_llist_fragment_tail l phead h' /\
snd v == h' (vptr res)
)
(decreases (L.length (Ghost.reveal l)))
=
if Nil? l
then begin
let ptail = Ghost.hide phead in
let gh = gget (vptr phead) in
assert (Ghost.reveal gh == head);
elim_llist_fragment_head_nil l phead head;
intro_llist_fragment_tail_nil l phead;
change_equal_slprop
(vptr phead)
(vptr ptail);
ptail
end else begin
intro_llist_fragment_tail_nil [] phead;
change_equal_slprop
(vptr phead)
(vptr (Ghost.reveal (Ghost.hide phead)));
let uc = elim_llist_fragment_head_cons l phead head in
let head' = elim_ccell_ghost head in
change_equal_slprop
(vptr (ccell_next head'))
(vptr uc.ll_uncons_pnext);
let lc = intro_llist_fragment_tail_snoc [] phead phead head' in
let ptail = llist_fragment_head_to_tail
uc.ll_uncons_tl
uc.ll_uncons_pnext
uc.ll_uncons_next
in
let l' = llist_fragment_tail_append phead lc uc.ll_uncons_pnext uc.ll_uncons_tl in
change_equal_slprop
(llist_fragment_tail l' phead)
(llist_fragment_tail l phead);
ptail
end
#push-options "--z3rlimit 16"
#restart-solver
let rec llist_fragment_tail_to_head
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(ptail: ref (ccell_ptrvalue a))
: SteelGhost (Ghost.erased (ccell_ptrvalue a)) opened
(llist_fragment_tail l phead `star` vptr ptail)
(fun head -> vptr phead `star` llist_fragment_head l phead (Ghost.reveal head))
(fun h -> Ghost.reveal ptail == sel_llist_fragment_tail l phead h)
(fun h head h' ->
let v = sel_llist_fragment_head l phead head h' in
fst v == ptail /\
snd v == h (vptr ptail) /\
h' (vptr phead) == Ghost.reveal head
)
(decreases (L.length (Ghost.reveal l)))
=
if Nil? l
then begin
let g = gget (llist_fragment_tail l phead) in
assert (Ghost.reveal g == ptail);
elim_llist_fragment_tail_nil l phead;
change_equal_slprop
(vptr ptail)
(vptr phead);
let head = gget (vptr phead) in
intro_llist_fragment_head_nil l phead head;
head
end else begin
let us = elim_llist_fragment_tail_snoc l phead in
let tail = gget (vptr ptail) in
assert (ccell_next us.ll_unsnoc_tail == ptail);
intro_llist_fragment_head_nil [] (ccell_next us.ll_unsnoc_tail) tail;
change_equal_slprop
(vptr ptail)
(vptr (ccell_next us.ll_unsnoc_tail));
intro_ccell us.ll_unsnoc_tail;
let lc = intro_llist_fragment_head_cons us.ll_unsnoc_ptail us.ll_unsnoc_tail tail [] in
let head = llist_fragment_tail_to_head us.ll_unsnoc_l phead us.ll_unsnoc_ptail in
let g = gget (llist_fragment_head us.ll_unsnoc_l phead head) in
let g : Ghost.erased (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = Ghost.hide (Ghost.reveal g) in
assert (Ghost.reveal g == (Ghost.reveal us.ll_unsnoc_ptail, Ghost.reveal us.ll_unsnoc_tail));
let l' = llist_fragment_head_append us.ll_unsnoc_l phead head lc us.ll_unsnoc_ptail us.ll_unsnoc_tail in
change_equal_slprop
(llist_fragment_head l' phead head)
(llist_fragment_head l phead head);
head
end
#pop-options
val llist_fragment_head_is_nil
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> llist_fragment_head l phead head)
(fun h -> ccell_ptrvalue_is_null (snd (sel_llist_fragment_head l phead head h)) == true)
(fun h _ h' ->
Nil? l == ccell_ptrvalue_is_null head /\
h' (llist_fragment_head l phead head) == h (llist_fragment_head l phead head)
)
let llist_fragment_head_is_nil
l phead head
=
if Nil? l
then begin
elim_llist_fragment_head_nil l phead head;
assert (ccell_ptrvalue_is_null head == true);
intro_llist_fragment_head_nil l phead head
end else begin
let r = elim_llist_fragment_head_cons l phead head in
let head2 : ccell_lvalue _ = head in
change_equal_slprop
(llist_fragment_head r.ll_uncons_tl r.ll_uncons_pnext r.ll_uncons_next)
(llist_fragment_head r.ll_uncons_tl (ccell_next head2) r.ll_uncons_next);
change_equal_slprop
(ccell head)
(ccell head2);
let l' = intro_llist_fragment_head_cons phead head2 r.ll_uncons_next r.ll_uncons_tl in
change_equal_slprop
(llist_fragment_head l' phead head2)
(llist_fragment_head l phead head)
end
val llist_fragment_head_cons_change_phead
(#opened: _)
(#a: Type)
(l: Ghost.erased (list a))
(phead: ref (ccell_ptrvalue a))
(head: ccell_ptrvalue a)
(phead' : ref (ccell_ptrvalue a))
: SteelGhost unit opened
(llist_fragment_head l phead head)
(fun _ -> llist_fragment_head l phead' head)
(fun _ -> Cons? l)
(fun h _ h' -> h' (llist_fragment_head l phead' head) == h (llist_fragment_head l phead head))
let llist_fragment_head_cons_change_phead
l phead head phead'
=
let u = elim_llist_fragment_head_cons l phead head in
let head2 : ccell_lvalue _ = head in
change_equal_slprop
(ccell head)
(ccell head2);
change_equal_slprop
(llist_fragment_head u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next)
(llist_fragment_head u.ll_uncons_tl (ccell_next head2) u.ll_uncons_next);
let l' = intro_llist_fragment_head_cons phead' head2 u.ll_uncons_next u.ll_uncons_tl in
change_equal_slprop
(llist_fragment_head l' phead' head2)
(llist_fragment_head l phead' head) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.LList.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.fst"
} | [
{
"abbrev": false,
"full_module": "CQueue.LList",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
x: CQueue.t a ->
l: FStar.Ghost.erased (Prims.list a) ->
hd: CQueue.Cell.ccell_ptrvalue a ->
ptl: Steel.Effect.Common.t_of (CQueue.llist_fragment_head l (CQueue.LList.cllist_head x) hd) ->
tl: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a)
-> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"CQueue.t",
"FStar.Ghost.erased",
"Prims.list",
"CQueue.Cell.ccell_ptrvalue",
"Steel.Effect.Common.t_of",
"CQueue.llist_fragment_head",
"CQueue.LList.cllist_head",
"Steel.Reference.ref",
"Prims.l_and",
"CQueue.op_Equals_Equals",
"FStar.Pervasives.Native.fst",
"Prims.bool",
"CQueue.Cell.ccell_ptrvalue_is_null",
"FStar.Pervasives.Native.snd",
"FStar.Pervasives.Native.tuple2",
"Prims.prop"
] | [] | false | false | false | false | true | let queue_head_refine
(#a: Type)
(x: t a)
(l: Ghost.erased (list a))
(hd: ccell_ptrvalue a)
(ptl: t_of (llist_fragment_head l (cllist_head x) hd))
(tl: ref (ccell_ptrvalue a))
: Tot prop =
| let ptl:(ref (ccell_ptrvalue a) & ccell_ptrvalue a) = ptl in
tl == fst ptl /\ ccell_ptrvalue_is_null (snd ptl) == true | false |
Hacl.Impl.Blake2.Core.fsti | Hacl.Impl.Blake2.Core.get_blake2s_personal | val get_blake2s_personal : p: Hacl.Impl.Blake2.Core.blake2s_params
-> Lib.Buffer.lbuffer_t Lib.Buffer.MUT
(Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
(8ul <: FStar.UInt32.t) | let get_blake2s_personal (p: blake2s_params) = p.personal | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 57,
"end_line": 87,
"start_col": 0,
"start_line": 87
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
type m_spec =
| M32
| M128
| M256
noextract inline_for_extraction
type word_t (a:Spec.alg) = Spec.word_t a
noextract inline_for_extraction
let element_t (a:Spec.alg) (m:m_spec) =
match a,m with
| Spec.Blake2S,M128 -> (vec_t U32 4)
| Spec.Blake2S,M256 -> (vec_t U32 4)
| Spec.Blake2B,M256 -> (vec_t U64 4)
| _ -> (word_t a)
noextract inline_for_extraction
val zero_element: a:Spec.alg -> m:m_spec -> element_t a m
noextract inline_for_extraction
let row_len (a:Spec.alg) (m:m_spec) : size_t =
match a,m with
| Spec.Blake2S,M128 -> 1ul
| Spec.Blake2S,M256 -> 1ul
| Spec.Blake2B,M256 -> 1ul
| _ -> 4ul
noextract inline_for_extraction
unfold let row_p (a:Spec.alg) (m:m_spec) =
lbuffer (element_t a m) (row_len a m)
noextract inline_for_extraction
val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a)
noextract
val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m ->
Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==>
row_v h0 r1 == row_v h1 r2))
[SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)]
noextract inline_for_extraction
let salt_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noextract inline_for_extraction
let personal_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lbuffer uint8 8ul;
personal: lbuffer uint8 8ul;
}
inline_for_extraction noextract
let get_blake2s_salt (p: blake2s_params) = p.salt | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Blake2.Core.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.Blake2.Core.blake2s_params
-> Lib.Buffer.lbuffer_t Lib.Buffer.MUT
(Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
(8ul <: FStar.UInt32.t) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.Blake2.Core.blake2s_params",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__personal",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t"
] | [] | false | false | false | false | false | let get_blake2s_personal (p: blake2s_params) =
| p.personal | false |
|
Hacl.Impl.Blake2.Core.fsti | Hacl.Impl.Blake2.Core.blake2s_params_loc | val blake2s_params_loc : p: Hacl.Impl.Blake2.Core.blake2s_params -> Prims.GTot LowStar.Monotonic.Buffer.loc | let blake2s_params_loc (p: blake2s_params) =
loc p.salt `union` loc p.personal | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 35,
"end_line": 107,
"start_col": 0,
"start_line": 106
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
type m_spec =
| M32
| M128
| M256
noextract inline_for_extraction
type word_t (a:Spec.alg) = Spec.word_t a
noextract inline_for_extraction
let element_t (a:Spec.alg) (m:m_spec) =
match a,m with
| Spec.Blake2S,M128 -> (vec_t U32 4)
| Spec.Blake2S,M256 -> (vec_t U32 4)
| Spec.Blake2B,M256 -> (vec_t U64 4)
| _ -> (word_t a)
noextract inline_for_extraction
val zero_element: a:Spec.alg -> m:m_spec -> element_t a m
noextract inline_for_extraction
let row_len (a:Spec.alg) (m:m_spec) : size_t =
match a,m with
| Spec.Blake2S,M128 -> 1ul
| Spec.Blake2S,M256 -> 1ul
| Spec.Blake2B,M256 -> 1ul
| _ -> 4ul
noextract inline_for_extraction
unfold let row_p (a:Spec.alg) (m:m_spec) =
lbuffer (element_t a m) (row_len a m)
noextract inline_for_extraction
val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a)
noextract
val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m ->
Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==>
row_v h0 r1 == row_v h1 r2))
[SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)]
noextract inline_for_extraction
let salt_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noextract inline_for_extraction
let personal_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lbuffer uint8 8ul;
personal: lbuffer uint8 8ul;
}
inline_for_extraction noextract
let get_blake2s_salt (p: blake2s_params) = p.salt
inline_for_extraction noextract
let get_blake2s_personal (p: blake2s_params) = p.personal
inline_for_extraction noextract
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S})
: blake2s_params =
{p with digest_length = to_u8 nn}
inline_for_extraction noextract
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_t{v kk <= Spec.max_key Spec.Blake2S})
: blake2s_params =
{p with key_length = to_u8 kk}
let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop =
live h p.salt /\ live h p.personal | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Blake2.Core.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.Blake2.Core.blake2s_params -> Prims.GTot LowStar.Monotonic.Buffer.loc | Prims.GTot | [
"sometrivial"
] | [] | [
"Hacl.Impl.Blake2.Core.blake2s_params",
"Lib.Buffer.union",
"Lib.Buffer.loc",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__salt",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__personal",
"LowStar.Monotonic.Buffer.loc"
] | [] | false | false | false | false | false | let blake2s_params_loc (p: blake2s_params) =
| (loc p.salt) `union` (loc p.personal) | false |
|
Hacl.Impl.Blake2.Core.fsti | Hacl.Impl.Blake2.Core.blake2b_params_loc | val blake2b_params_loc : p: Hacl.Impl.Blake2.Core.blake2b_params -> Prims.GTot LowStar.Monotonic.Buffer.loc | let blake2b_params_loc (p: blake2b_params) =
loc p.salt `union` loc p.personal | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 35,
"end_line": 144,
"start_col": 0,
"start_line": 143
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
type m_spec =
| M32
| M128
| M256
noextract inline_for_extraction
type word_t (a:Spec.alg) = Spec.word_t a
noextract inline_for_extraction
let element_t (a:Spec.alg) (m:m_spec) =
match a,m with
| Spec.Blake2S,M128 -> (vec_t U32 4)
| Spec.Blake2S,M256 -> (vec_t U32 4)
| Spec.Blake2B,M256 -> (vec_t U64 4)
| _ -> (word_t a)
noextract inline_for_extraction
val zero_element: a:Spec.alg -> m:m_spec -> element_t a m
noextract inline_for_extraction
let row_len (a:Spec.alg) (m:m_spec) : size_t =
match a,m with
| Spec.Blake2S,M128 -> 1ul
| Spec.Blake2S,M256 -> 1ul
| Spec.Blake2B,M256 -> 1ul
| _ -> 4ul
noextract inline_for_extraction
unfold let row_p (a:Spec.alg) (m:m_spec) =
lbuffer (element_t a m) (row_len a m)
noextract inline_for_extraction
val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a)
noextract
val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m ->
Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==>
row_v h0 r1 == row_v h1 r2))
[SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)]
noextract inline_for_extraction
let salt_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noextract inline_for_extraction
let personal_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lbuffer uint8 8ul;
personal: lbuffer uint8 8ul;
}
inline_for_extraction noextract
let get_blake2s_salt (p: blake2s_params) = p.salt
inline_for_extraction noextract
let get_blake2s_personal (p: blake2s_params) = p.personal
inline_for_extraction noextract
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S})
: blake2s_params =
{p with digest_length = to_u8 nn}
inline_for_extraction noextract
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_t{v kk <= Spec.max_key Spec.Blake2S})
: blake2s_params =
{p with key_length = to_u8 kk}
let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop =
live h p.salt /\ live h p.personal
let blake2s_params_loc (p: blake2s_params) =
loc p.salt `union` loc p.personal
let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params =
Spec.Mkblake2s_params
p.digest_length
p.key_length
p.fanout
p.depth
p.leaf_length
p.node_offset
p.xof_length
p.node_depth
p.inner_length
(as_seq h p.salt)
(as_seq h p.personal)
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lbuffer uint8 16ul;
personal: lbuffer uint8 16ul;
}
let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop =
live h p.salt /\ live h p.personal | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Blake2.Core.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.Blake2.Core.blake2b_params -> Prims.GTot LowStar.Monotonic.Buffer.loc | Prims.GTot | [
"sometrivial"
] | [] | [
"Hacl.Impl.Blake2.Core.blake2b_params",
"Lib.Buffer.union",
"Lib.Buffer.loc",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__salt",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__personal",
"LowStar.Monotonic.Buffer.loc"
] | [] | false | false | false | false | false | let blake2b_params_loc (p: blake2b_params) =
| (loc p.salt) `union` (loc p.personal) | false |
|
Hacl.Impl.Blake2.Core.fsti | Hacl.Impl.Blake2.Core.set_blake2s_key_length | val set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S})
: blake2s_params | val set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S})
: blake2s_params | let set_blake2s_key_length
(p: blake2s_params)
(kk: size_t{v kk <= Spec.max_key Spec.Blake2S})
: blake2s_params =
{p with key_length = to_u8 kk} | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 101,
"start_col": 0,
"start_line": 97
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
type m_spec =
| M32
| M128
| M256
noextract inline_for_extraction
type word_t (a:Spec.alg) = Spec.word_t a
noextract inline_for_extraction
let element_t (a:Spec.alg) (m:m_spec) =
match a,m with
| Spec.Blake2S,M128 -> (vec_t U32 4)
| Spec.Blake2S,M256 -> (vec_t U32 4)
| Spec.Blake2B,M256 -> (vec_t U64 4)
| _ -> (word_t a)
noextract inline_for_extraction
val zero_element: a:Spec.alg -> m:m_spec -> element_t a m
noextract inline_for_extraction
let row_len (a:Spec.alg) (m:m_spec) : size_t =
match a,m with
| Spec.Blake2S,M128 -> 1ul
| Spec.Blake2S,M256 -> 1ul
| Spec.Blake2B,M256 -> 1ul
| _ -> 4ul
noextract inline_for_extraction
unfold let row_p (a:Spec.alg) (m:m_spec) =
lbuffer (element_t a m) (row_len a m)
noextract inline_for_extraction
val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a)
noextract
val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m ->
Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==>
row_v h0 r1 == row_v h1 r2))
[SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)]
noextract inline_for_extraction
let salt_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noextract inline_for_extraction
let personal_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lbuffer uint8 8ul;
personal: lbuffer uint8 8ul;
}
inline_for_extraction noextract
let get_blake2s_salt (p: blake2s_params) = p.salt
inline_for_extraction noextract
let get_blake2s_personal (p: blake2s_params) = p.personal
inline_for_extraction noextract
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S})
: blake2s_params =
{p with digest_length = to_u8 nn} | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Blake2.Core.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p: Hacl.Impl.Blake2.Core.blake2s_params ->
kk:
Lib.IntTypes.size_t
{Lib.IntTypes.v kk <= Spec.Blake2.Definitions.max_key Spec.Blake2.Definitions.Blake2S}
-> Hacl.Impl.Blake2.Core.blake2s_params | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.Blake2.Core.blake2s_params",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Spec.Blake2.Definitions.max_key",
"Spec.Blake2.Definitions.Blake2S",
"Hacl.Impl.Blake2.Core.Mkblake2s_params",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__digest_length",
"Lib.IntTypes.to_u8",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__fanout",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__depth",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__leaf_length",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__node_offset",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__xof_length",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__node_depth",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__inner_length",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__salt",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__personal"
] | [] | false | false | false | false | false | let set_blake2s_key_length (p: blake2s_params) (kk: size_t{v kk <= Spec.max_key Spec.Blake2S})
: blake2s_params =
| { p with key_length = to_u8 kk } | false |
Hacl.Impl.Blake2.Core.fsti | Hacl.Impl.Blake2.Core.blake2s_params_inv | val blake2s_params_inv (h: mem) (p: blake2s_params) : GTot prop | val blake2s_params_inv (h: mem) (p: blake2s_params) : GTot prop | let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop =
live h p.salt /\ live h p.personal | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 36,
"end_line": 104,
"start_col": 0,
"start_line": 103
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
type m_spec =
| M32
| M128
| M256
noextract inline_for_extraction
type word_t (a:Spec.alg) = Spec.word_t a
noextract inline_for_extraction
let element_t (a:Spec.alg) (m:m_spec) =
match a,m with
| Spec.Blake2S,M128 -> (vec_t U32 4)
| Spec.Blake2S,M256 -> (vec_t U32 4)
| Spec.Blake2B,M256 -> (vec_t U64 4)
| _ -> (word_t a)
noextract inline_for_extraction
val zero_element: a:Spec.alg -> m:m_spec -> element_t a m
noextract inline_for_extraction
let row_len (a:Spec.alg) (m:m_spec) : size_t =
match a,m with
| Spec.Blake2S,M128 -> 1ul
| Spec.Blake2S,M256 -> 1ul
| Spec.Blake2B,M256 -> 1ul
| _ -> 4ul
noextract inline_for_extraction
unfold let row_p (a:Spec.alg) (m:m_spec) =
lbuffer (element_t a m) (row_len a m)
noextract inline_for_extraction
val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a)
noextract
val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m ->
Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==>
row_v h0 r1 == row_v h1 r2))
[SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)]
noextract inline_for_extraction
let salt_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noextract inline_for_extraction
let personal_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lbuffer uint8 8ul;
personal: lbuffer uint8 8ul;
}
inline_for_extraction noextract
let get_blake2s_salt (p: blake2s_params) = p.salt
inline_for_extraction noextract
let get_blake2s_personal (p: blake2s_params) = p.personal
inline_for_extraction noextract
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S})
: blake2s_params =
{p with digest_length = to_u8 nn}
inline_for_extraction noextract
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_t{v kk <= Spec.max_key Spec.Blake2S})
: blake2s_params =
{p with key_length = to_u8 kk} | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Blake2.Core.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.Blake2.Core.blake2s_params
-> Prims.GTot Prims.prop | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Blake2.Core.blake2s_params",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__salt",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__personal",
"Prims.prop"
] | [] | false | false | false | false | true | let blake2s_params_inv (h: mem) (p: blake2s_params) : GTot prop =
| live h p.salt /\ live h p.personal | false |
Hacl.Impl.Blake2.Core.fsti | Hacl.Impl.Blake2.Core.set_blake2s_digest_length | val set_blake2s_digest_length
(p: blake2s_params)
(nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S})
: blake2s_params | val set_blake2s_digest_length
(p: blake2s_params)
(nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S})
: blake2s_params | let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S})
: blake2s_params =
{p with digest_length = to_u8 nn} | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 35,
"end_line": 94,
"start_col": 0,
"start_line": 90
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
type m_spec =
| M32
| M128
| M256
noextract inline_for_extraction
type word_t (a:Spec.alg) = Spec.word_t a
noextract inline_for_extraction
let element_t (a:Spec.alg) (m:m_spec) =
match a,m with
| Spec.Blake2S,M128 -> (vec_t U32 4)
| Spec.Blake2S,M256 -> (vec_t U32 4)
| Spec.Blake2B,M256 -> (vec_t U64 4)
| _ -> (word_t a)
noextract inline_for_extraction
val zero_element: a:Spec.alg -> m:m_spec -> element_t a m
noextract inline_for_extraction
let row_len (a:Spec.alg) (m:m_spec) : size_t =
match a,m with
| Spec.Blake2S,M128 -> 1ul
| Spec.Blake2S,M256 -> 1ul
| Spec.Blake2B,M256 -> 1ul
| _ -> 4ul
noextract inline_for_extraction
unfold let row_p (a:Spec.alg) (m:m_spec) =
lbuffer (element_t a m) (row_len a m)
noextract inline_for_extraction
val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a)
noextract
val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m ->
Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==>
row_v h0 r1 == row_v h1 r2))
[SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)]
noextract inline_for_extraction
let salt_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noextract inline_for_extraction
let personal_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lbuffer uint8 8ul;
personal: lbuffer uint8 8ul;
}
inline_for_extraction noextract
let get_blake2s_salt (p: blake2s_params) = p.salt
inline_for_extraction noextract
let get_blake2s_personal (p: blake2s_params) = p.personal | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Blake2.Core.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p: Hacl.Impl.Blake2.Core.blake2s_params ->
nn:
Lib.IntTypes.size_t
{ 1 <= Lib.IntTypes.v nn /\
Lib.IntTypes.v nn <= Spec.Blake2.Definitions.max_output Spec.Blake2.Definitions.Blake2S }
-> Hacl.Impl.Blake2.Core.blake2s_params | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.Blake2.Core.blake2s_params",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Spec.Blake2.Definitions.max_output",
"Spec.Blake2.Definitions.Blake2S",
"Hacl.Impl.Blake2.Core.Mkblake2s_params",
"Lib.IntTypes.to_u8",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__key_length",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__fanout",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__depth",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__leaf_length",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__node_offset",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__xof_length",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__node_depth",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__inner_length",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__salt",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__personal"
] | [] | false | false | false | false | false | let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S})
: blake2s_params =
| { p with digest_length = to_u8 nn } | false |
Hacl.Impl.Blake2.Core.fsti | Hacl.Impl.Blake2.Core.blake2b_params_v | val blake2b_params_v (h: mem) (p: blake2b_params) : GTot Spec.blake2b_params | val blake2b_params_v (h: mem) (p: blake2b_params) : GTot Spec.blake2b_params | let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params =
Spec.Mkblake2b_params
p.digest_length
p.key_length
p.fanout
p.depth
p.leaf_length
p.node_offset
p.xof_length
p.node_depth
p.inner_length
(as_seq h p.salt)
(as_seq h p.personal) | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 158,
"start_col": 0,
"start_line": 146
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
type m_spec =
| M32
| M128
| M256
noextract inline_for_extraction
type word_t (a:Spec.alg) = Spec.word_t a
noextract inline_for_extraction
let element_t (a:Spec.alg) (m:m_spec) =
match a,m with
| Spec.Blake2S,M128 -> (vec_t U32 4)
| Spec.Blake2S,M256 -> (vec_t U32 4)
| Spec.Blake2B,M256 -> (vec_t U64 4)
| _ -> (word_t a)
noextract inline_for_extraction
val zero_element: a:Spec.alg -> m:m_spec -> element_t a m
noextract inline_for_extraction
let row_len (a:Spec.alg) (m:m_spec) : size_t =
match a,m with
| Spec.Blake2S,M128 -> 1ul
| Spec.Blake2S,M256 -> 1ul
| Spec.Blake2B,M256 -> 1ul
| _ -> 4ul
noextract inline_for_extraction
unfold let row_p (a:Spec.alg) (m:m_spec) =
lbuffer (element_t a m) (row_len a m)
noextract inline_for_extraction
val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a)
noextract
val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m ->
Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==>
row_v h0 r1 == row_v h1 r2))
[SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)]
noextract inline_for_extraction
let salt_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noextract inline_for_extraction
let personal_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lbuffer uint8 8ul;
personal: lbuffer uint8 8ul;
}
inline_for_extraction noextract
let get_blake2s_salt (p: blake2s_params) = p.salt
inline_for_extraction noextract
let get_blake2s_personal (p: blake2s_params) = p.personal
inline_for_extraction noextract
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S})
: blake2s_params =
{p with digest_length = to_u8 nn}
inline_for_extraction noextract
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_t{v kk <= Spec.max_key Spec.Blake2S})
: blake2s_params =
{p with key_length = to_u8 kk}
let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop =
live h p.salt /\ live h p.personal
let blake2s_params_loc (p: blake2s_params) =
loc p.salt `union` loc p.personal
let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params =
Spec.Mkblake2s_params
p.digest_length
p.key_length
p.fanout
p.depth
p.leaf_length
p.node_offset
p.xof_length
p.node_depth
p.inner_length
(as_seq h p.salt)
(as_seq h p.personal)
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lbuffer uint8 16ul;
personal: lbuffer uint8 16ul;
}
let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop =
live h p.salt /\ live h p.personal
let blake2b_params_loc (p: blake2b_params) =
loc p.salt `union` loc p.personal | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Blake2.Core.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.Blake2.Core.blake2b_params
-> Prims.GTot Spec.Blake2.Definitions.blake2b_params | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Blake2.Core.blake2b_params",
"Spec.Blake2.Definitions.Mkblake2b_params",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__digest_length",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__key_length",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__fanout",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__depth",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__leaf_length",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__node_offset",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__xof_length",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__node_depth",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__inner_length",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__salt",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__personal",
"Spec.Blake2.Definitions.blake2b_params"
] | [] | false | false | false | false | false | let blake2b_params_v (h: mem) (p: blake2b_params) : GTot Spec.blake2b_params =
| Spec.Mkblake2b_params p.digest_length
p.key_length
p.fanout
p.depth
p.leaf_length
p.node_offset
p.xof_length
p.node_depth
p.inner_length
(as_seq h p.salt)
(as_seq h p.personal) | false |
Hacl.Impl.Blake2.Core.fsti | Hacl.Impl.Blake2.Core.blake2b_params_inv | val blake2b_params_inv (h: mem) (p: blake2b_params) : GTot prop | val blake2b_params_inv (h: mem) (p: blake2b_params) : GTot prop | let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop =
live h p.salt /\ live h p.personal | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 36,
"end_line": 141,
"start_col": 0,
"start_line": 140
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
type m_spec =
| M32
| M128
| M256
noextract inline_for_extraction
type word_t (a:Spec.alg) = Spec.word_t a
noextract inline_for_extraction
let element_t (a:Spec.alg) (m:m_spec) =
match a,m with
| Spec.Blake2S,M128 -> (vec_t U32 4)
| Spec.Blake2S,M256 -> (vec_t U32 4)
| Spec.Blake2B,M256 -> (vec_t U64 4)
| _ -> (word_t a)
noextract inline_for_extraction
val zero_element: a:Spec.alg -> m:m_spec -> element_t a m
noextract inline_for_extraction
let row_len (a:Spec.alg) (m:m_spec) : size_t =
match a,m with
| Spec.Blake2S,M128 -> 1ul
| Spec.Blake2S,M256 -> 1ul
| Spec.Blake2B,M256 -> 1ul
| _ -> 4ul
noextract inline_for_extraction
unfold let row_p (a:Spec.alg) (m:m_spec) =
lbuffer (element_t a m) (row_len a m)
noextract inline_for_extraction
val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a)
noextract
val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m ->
Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==>
row_v h0 r1 == row_v h1 r2))
[SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)]
noextract inline_for_extraction
let salt_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noextract inline_for_extraction
let personal_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lbuffer uint8 8ul;
personal: lbuffer uint8 8ul;
}
inline_for_extraction noextract
let get_blake2s_salt (p: blake2s_params) = p.salt
inline_for_extraction noextract
let get_blake2s_personal (p: blake2s_params) = p.personal
inline_for_extraction noextract
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S})
: blake2s_params =
{p with digest_length = to_u8 nn}
inline_for_extraction noextract
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_t{v kk <= Spec.max_key Spec.Blake2S})
: blake2s_params =
{p with key_length = to_u8 kk}
let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop =
live h p.salt /\ live h p.personal
let blake2s_params_loc (p: blake2s_params) =
loc p.salt `union` loc p.personal
let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params =
Spec.Mkblake2s_params
p.digest_length
p.key_length
p.fanout
p.depth
p.leaf_length
p.node_offset
p.xof_length
p.node_depth
p.inner_length
(as_seq h p.salt)
(as_seq h p.personal)
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lbuffer uint8 16ul;
personal: lbuffer uint8 16ul;
} | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Blake2.Core.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.Blake2.Core.blake2b_params
-> Prims.GTot Prims.prop | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Blake2.Core.blake2b_params",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__salt",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2b_params__item__personal",
"Prims.prop"
] | [] | false | false | false | false | true | let blake2b_params_inv (h: mem) (p: blake2b_params) : GTot prop =
| live h p.salt /\ live h p.personal | false |
Hacl.Impl.Blake2.Core.fsti | Hacl.Impl.Blake2.Core.blake2s_params_v | val blake2s_params_v (h: mem) (p: blake2s_params) : GTot Spec.blake2s_params | val blake2s_params_v (h: mem) (p: blake2s_params) : GTot Spec.blake2s_params | let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params =
Spec.Mkblake2s_params
p.digest_length
p.key_length
p.fanout
p.depth
p.leaf_length
p.node_offset
p.xof_length
p.node_depth
p.inner_length
(as_seq h p.salt)
(as_seq h p.personal) | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 121,
"start_col": 0,
"start_line": 109
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
type m_spec =
| M32
| M128
| M256
noextract inline_for_extraction
type word_t (a:Spec.alg) = Spec.word_t a
noextract inline_for_extraction
let element_t (a:Spec.alg) (m:m_spec) =
match a,m with
| Spec.Blake2S,M128 -> (vec_t U32 4)
| Spec.Blake2S,M256 -> (vec_t U32 4)
| Spec.Blake2B,M256 -> (vec_t U64 4)
| _ -> (word_t a)
noextract inline_for_extraction
val zero_element: a:Spec.alg -> m:m_spec -> element_t a m
noextract inline_for_extraction
let row_len (a:Spec.alg) (m:m_spec) : size_t =
match a,m with
| Spec.Blake2S,M128 -> 1ul
| Spec.Blake2S,M256 -> 1ul
| Spec.Blake2B,M256 -> 1ul
| _ -> 4ul
noextract inline_for_extraction
unfold let row_p (a:Spec.alg) (m:m_spec) =
lbuffer (element_t a m) (row_len a m)
noextract inline_for_extraction
val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a)
noextract
val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m ->
Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==>
row_v h0 r1 == row_v h1 r2))
[SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)]
noextract inline_for_extraction
let salt_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noextract inline_for_extraction
let personal_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lbuffer uint8 8ul;
personal: lbuffer uint8 8ul;
}
inline_for_extraction noextract
let get_blake2s_salt (p: blake2s_params) = p.salt
inline_for_extraction noextract
let get_blake2s_personal (p: blake2s_params) = p.personal
inline_for_extraction noextract
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S})
: blake2s_params =
{p with digest_length = to_u8 nn}
inline_for_extraction noextract
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_t{v kk <= Spec.max_key Spec.Blake2S})
: blake2s_params =
{p with key_length = to_u8 kk}
let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop =
live h p.salt /\ live h p.personal
let blake2s_params_loc (p: blake2s_params) =
loc p.salt `union` loc p.personal | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Blake2.Core.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.Blake2.Core.blake2s_params
-> Prims.GTot Spec.Blake2.Definitions.blake2s_params | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Blake2.Core.blake2s_params",
"Spec.Blake2.Definitions.Mkblake2s_params",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__digest_length",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__key_length",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__fanout",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__depth",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__leaf_length",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__node_offset",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__xof_length",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__node_depth",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__inner_length",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__salt",
"Hacl.Impl.Blake2.Core.__proj__Mkblake2s_params__item__personal",
"Spec.Blake2.Definitions.blake2s_params"
] | [] | false | false | false | false | false | let blake2s_params_v (h: mem) (p: blake2s_params) : GTot Spec.blake2s_params =
| Spec.Mkblake2s_params p.digest_length
p.key_length
p.fanout
p.depth
p.leaf_length
p.node_offset
p.xof_length
p.node_depth
p.inner_length
(as_seq h p.salt)
(as_seq h p.personal) | false |
Hacl.Impl.Blake2.Core.fsti | Hacl.Impl.Blake2.Core.index_t | val index_t : Type0 | let index_t = n:size_t{v n < 4} | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 234,
"start_col": 7,
"start_line": 234
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
type m_spec =
| M32
| M128
| M256
noextract inline_for_extraction
type word_t (a:Spec.alg) = Spec.word_t a
noextract inline_for_extraction
let element_t (a:Spec.alg) (m:m_spec) =
match a,m with
| Spec.Blake2S,M128 -> (vec_t U32 4)
| Spec.Blake2S,M256 -> (vec_t U32 4)
| Spec.Blake2B,M256 -> (vec_t U64 4)
| _ -> (word_t a)
noextract inline_for_extraction
val zero_element: a:Spec.alg -> m:m_spec -> element_t a m
noextract inline_for_extraction
let row_len (a:Spec.alg) (m:m_spec) : size_t =
match a,m with
| Spec.Blake2S,M128 -> 1ul
| Spec.Blake2S,M256 -> 1ul
| Spec.Blake2B,M256 -> 1ul
| _ -> 4ul
noextract inline_for_extraction
unfold let row_p (a:Spec.alg) (m:m_spec) =
lbuffer (element_t a m) (row_len a m)
noextract inline_for_extraction
val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a)
noextract
val row_v_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> r1:row_p a m -> r2:row_p a m ->
Lemma (ensures (as_seq h0 r1 == as_seq h1 r2 ==>
row_v h0 r1 == row_v h1 r2))
[SMTPat (row_v h0 r1); SMTPat (row_v h1 r2)]
noextract inline_for_extraction
let salt_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noextract inline_for_extraction
let personal_len (a:Spec.alg) : size_t =
match a with
| Spec.Blake2S -> 8ul
| Spec.Blake2B -> 16ul
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lbuffer uint8 8ul;
personal: lbuffer uint8 8ul;
}
inline_for_extraction noextract
let get_blake2s_salt (p: blake2s_params) = p.salt
inline_for_extraction noextract
let get_blake2s_personal (p: blake2s_params) = p.personal
inline_for_extraction noextract
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_t{1 <= v nn /\ v nn <= Spec.max_output Spec.Blake2S})
: blake2s_params =
{p with digest_length = to_u8 nn}
inline_for_extraction noextract
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_t{v kk <= Spec.max_key Spec.Blake2S})
: blake2s_params =
{p with key_length = to_u8 kk}
let blake2s_params_inv (h: mem) (p: blake2s_params): GTot prop =
live h p.salt /\ live h p.personal
let blake2s_params_loc (p: blake2s_params) =
loc p.salt `union` loc p.personal
let blake2s_params_v (h: mem) (p: blake2s_params): GTot Spec.blake2s_params =
Spec.Mkblake2s_params
p.digest_length
p.key_length
p.fanout
p.depth
p.leaf_length
p.node_offset
p.xof_length
p.node_depth
p.inner_length
(as_seq h p.salt)
(as_seq h p.personal)
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lbuffer uint8 16ul;
personal: lbuffer uint8 16ul;
}
let blake2b_params_inv (h: mem) (p: blake2b_params): GTot prop =
live h p.salt /\ live h p.personal
let blake2b_params_loc (p: blake2b_params) =
loc p.salt `union` loc p.personal
let blake2b_params_v (h: mem) (p: blake2b_params): GTot Spec.blake2b_params =
Spec.Mkblake2b_params
p.digest_length
p.key_length
p.fanout
p.depth
p.leaf_length
p.node_offset
p.xof_length
p.node_depth
p.inner_length
(as_seq h p.salt)
(as_seq h p.personal)
noextract inline_for_extraction
let blake2_params (a:Spec.alg) =
match a with
| Spec.Blake2S -> blake2s_params
| Spec.Blake2B -> blake2b_params
inline_for_extraction noextract
let set_digest_length (#a: Spec.alg)
(p: blake2_params a)
(nn: size_t{1 <= v nn /\ v nn <= Spec.max_output a})
: blake2_params a =
match a with
| Spec.Blake2S -> set_blake2s_digest_length p nn
| Spec.Blake2B -> {p with digest_length = to_u8 nn}
inline_for_extraction noextract
let set_key_length (#a: Spec.alg)
(p: blake2_params a)
(kk: size_t{v kk <= Spec.max_key a})
: blake2_params a =
match a with
| Spec.Blake2S -> set_blake2s_key_length p kk
| Spec.Blake2B -> {p with key_length = to_u8 kk}
inline_for_extraction noextract
let get_salt (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (salt_len a) =
match a with
| Spec.Blake2S -> get_blake2s_salt p
| Spec.Blake2B -> p.salt
inline_for_extraction noextract
let get_personal (#a: Spec.alg) (p: blake2_params a) : lbuffer uint8 (personal_len a) =
match a with
| Spec.Blake2S -> get_blake2s_personal p
| Spec.Blake2B -> p.personal
noextract inline_for_extraction
let blake2_params_inv (#a:Spec.alg) (h: mem) (p: blake2_params a) =
match a with
| Spec.Blake2S -> blake2s_params_inv h p
| Spec.Blake2B -> blake2b_params_inv h p
noextract inline_for_extraction
let blake2_params_loc (#a:Spec.alg) (p: blake2_params a) =
match a with
| Spec.Blake2S -> blake2s_params_loc p
| Spec.Blake2B -> blake2b_params_loc p
noextract inline_for_extraction
let blake2_params_v (#a:Spec.alg) (h: mem) (p: blake2_params a) : GTot (Spec.blake2_params a) =
match a with
| Spec.Blake2S -> blake2s_params_v h p
| Spec.Blake2B -> blake2b_params_v h p
noextract inline_for_extraction
val create_default_params: a:Spec.alg ->
salt: lbuffer uint8 (salt_len a) ->
personal: lbuffer uint8 (personal_len a) ->
Stack (blake2_params a)
(requires fun h -> live h salt /\ live h personal /\
as_seq h salt == Seq.create (Spec.salt_length a) (u8 0) /\
as_seq h personal == Seq.create (Spec.personal_length a) (u8 0)
)
(ensures (fun h0 p h1 ->
h0 == h1 /\
blake2_params_loc p == loc salt `union` loc personal /\
blake2_params_inv h1 p /\
blake2_params_v h1 p == Spec.blake2_default_params a))
noextract inline_for_extraction
unfold let state_p (a:Spec.alg) (m:m_spec) =
lbuffer (element_t a m) (4ul *. row_len a m) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Blake2.Core.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB"
] | [] | false | false | false | true | true | let index_t =
| n: size_t{v n < 4} | false |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.