file_name
stringlengths 5
52
| name
stringlengths 4
95
| original_source_type
stringlengths 0
23k
| source_type
stringlengths 9
23k
| source_definition
stringlengths 9
57.9k
| source
dict | source_range
dict | file_context
stringlengths 0
721k
| dependencies
dict | opens_and_abbrevs
listlengths 2
94
| vconfig
dict | interleaved
bool 1
class | verbose_type
stringlengths 1
7.42k
| effect
stringclasses 118
values | effect_flags
sequencelengths 0
2
| mutual_with
sequencelengths 0
11
| ideal_premises
sequencelengths 0
236
| proof_features
sequencelengths 0
1
| is_simple_lemma
bool 2
classes | is_div
bool 2
classes | is_proof
bool 2
classes | is_simply_typed
bool 2
classes | is_type
bool 2
classes | partial_definition
stringlengths 5
3.99k
| completed_definiton
stringlengths 1
1.63M
| isa_cross_project_example
bool 1
class |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.wp_While_inv | val wp_While_inv
(#a #d: Type)
(#c: code)
(qc: (a -> quickCode a c))
(mods: mods_t)
(inv: (va_state -> a -> Type0))
(dec: (va_state -> a -> d))
(s1: va_state)
(g1: a)
(s2: va_state)
(g2: a)
: Type0 | val wp_While_inv
(#a #d: Type)
(#c: code)
(qc: (a -> quickCode a c))
(mods: mods_t)
(inv: (va_state -> a -> Type0))
(dec: (va_state -> a -> d))
(s1: va_state)
(g1: a)
(s2: va_state)
(g2: a)
: Type0 | let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 81,
"end_line": 270,
"start_col": 0,
"start_line": 266
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
qc: (_: a -> Vale.PPC64LE.QuickCode.quickCode a c) ->
mods: Vale.PPC64LE.QuickCode.mods_t ->
inv: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0) ->
dec: (_: Vale.PPC64LE.Decls.va_state -> _: a -> d) ->
s1: Vale.PPC64LE.Decls.va_state ->
g1: a ->
s2: Vale.PPC64LE.Decls.va_state ->
g2: a
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.Decls.va_state",
"Prims.l_and",
"Prims.b2t",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ok",
"Vale.PPC64LE.QuickCodes.mods_contains",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Prims.precedes"
] | [] | false | false | false | false | true | let wp_While_inv
(#a #d: Type)
(#c: code)
(qc: (a -> quickCode a c))
(mods: mods_t)
(inv: (va_state -> a -> Type0))
(dec: (va_state -> a -> d))
(s1: va_state)
(g1: a)
(s2: va_state)
(g2: a)
: Type0 =
| s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1 | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.tAssertLemma | val tAssertLemma : p: Type0 -> Type0 | let tAssertLemma (p:Type0) = unit -> Lemma (requires p) (ensures p) | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 67,
"end_line": 310,
"start_col": 0,
"start_line": 310
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1
[@va_qattr]
let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1))
[@va_qattr]
let wp_While
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Type0 =
inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
// REVIEW: we could get a better WP with forall (...state components...) instead of forall (s1:va_state)
(forall (s1:va_state) (g1:a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k)
val qWhile_proof
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k)
(ensures fun (sM, f0, g) ->
eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qWhile
(#a #d:Type) (#c:code) (mods:mods_t) (b:cmp) (qc:a -> quickCode a c) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a)
: quickCode a (While (cmp_to_ocmp b) c) =
QProc (While (cmp_to_ocmp b) c) mods (wp_While b qc mods inv dec g0)
(qWhile_proof b qc mods inv dec g0)
///// Assert, Assume, AssertBy | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Type0 -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | false | true | true | let tAssertLemma (p: Type0) =
| unit -> Lemma (requires p) (ensures p) | false |
|
Arith.fst | Arith.tau1 | val tau1: Prims.unit -> Tac unit | val tau1: Prims.unit -> Tac unit | let tau1 () : Tac unit =
prune "";
FStar.Tactics.split ();
(* rev part *)
addns "FStar.List";
addns "Prims";
smt ();
(* arithmetic part *)
addns "Prims";
smt () | {
"file_name": "examples/tactics/Arith.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 12,
"end_line": 39,
"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 Arith
//
open FStar.Tactics.V2
open FStar.Tactics.Arith
open FStar.List
open FStar.Mul
let lem0 (x:int) =
assert (op_Multiply 2 (x + 3) == 6 + (op_Multiply 3 x) - x)
by (prune ""; addns "Prims") | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Arith.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Arith.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Arith",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | [] | [] | [
"Prims.unit",
"FStar.Tactics.V2.Derived.smt",
"FStar.Stubs.Tactics.V2.Builtins.addns",
"FStar.Tactics.V1.Logic.split",
"FStar.Stubs.Tactics.V2.Builtins.prune"
] | [] | false | true | false | false | false | let tau1 () : Tac unit =
| prune "";
FStar.Tactics.split ();
addns "FStar.List";
addns "Prims";
smt ();
addns "Prims";
smt () | false |
Vale.AES.GCM_BE_s.fst | Vale.AES.GCM_BE_s.compute_iv_BE | val compute_iv_BE : _: Vale.Def.Types_s.quad32 -> _: Vale.AES.GCM_BE_s.supported_iv_BE -> Vale.Def.Types_s.quad32 | let compute_iv_BE = opaque_make compute_iv_BE_def | {
"file_name": "vale/specs/crypto/Vale.AES.GCM_BE_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 68,
"end_line": 33,
"start_col": 19,
"start_line": 33
} | module Vale.AES.GCM_BE_s
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.AES.AES_BE_s
open Vale.AES.GCTR_BE_s
open Vale.AES.GHash_BE_s
open FStar.Seq
open FStar.Mul
#reset-options "--z3rlimit 30"
type supported_iv_BE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 }
let compute_iv_BE_def (h_BE:quad32) (iv:supported_iv_BE) : quad32
=
if 8 * (length iv) = 96 then (
let iv_BE = be_bytes_to_quad32 (pad_to_128_bits iv) in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE
) else (
let padded_iv_quads = be_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = two_two_to_four (Mktwo (nat_to_two 32 0) (nat_to_two 32 (8 * length iv))) in
let hash_input_BE = append padded_iv_quads (create 1 length_BE) in
let hash_output_BE = ghash_BE h_BE hash_input_BE in
hash_output_BE | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash_BE_s.fst.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GCM_BE_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"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.Seq_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.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Vale.Def.Types_s.quad32 -> _: Vale.AES.GCM_BE_s.supported_iv_BE -> Vale.Def.Types_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Vale.Def.Types_s.quad32",
"Vale.AES.GCM_BE_s.supported_iv_BE",
"Vale.AES.GCM_BE_s.compute_iv_BE_def"
] | [] | false | false | false | true | false | let compute_iv_BE =
| opaque_make compute_iv_BE_def | false |
|
Vale.AES.GCM_BE_s.fst | Vale.AES.GCM_BE_s.compute_iv_BE_reveal | val compute_iv_BE_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.AES.GCM_BE_s.compute_iv_BE == Vale.AES.GCM_BE_s.compute_iv_BE_def) | let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def | {
"file_name": "vale/specs/crypto/Vale.AES.GCM_BE_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 104,
"end_line": 34,
"start_col": 12,
"start_line": 34
} | module Vale.AES.GCM_BE_s
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.AES.AES_BE_s
open Vale.AES.GCTR_BE_s
open Vale.AES.GHash_BE_s
open FStar.Seq
open FStar.Mul
#reset-options "--z3rlimit 30"
type supported_iv_BE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 }
let compute_iv_BE_def (h_BE:quad32) (iv:supported_iv_BE) : quad32
=
if 8 * (length iv) = 96 then (
let iv_BE = be_bytes_to_quad32 (pad_to_128_bits iv) in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE
) else (
let padded_iv_quads = be_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = two_two_to_four (Mktwo (nat_to_two 32 0) (nat_to_two 32 (8 * length iv))) in
let hash_input_BE = append padded_iv_quads (create 1 length_BE) in
let hash_output_BE = ghash_BE h_BE hash_input_BE in
hash_output_BE
) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash_BE_s.fst.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GCM_BE_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"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.Seq_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.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.AES.GCM_BE_s.compute_iv_BE == Vale.AES.GCM_BE_s.compute_iv_BE_def) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Vale.Def.Types_s.quad32",
"Vale.AES.GCM_BE_s.supported_iv_BE",
"Vale.AES.GCM_BE_s.compute_iv_BE",
"Vale.AES.GCM_BE_s.compute_iv_BE_def"
] | [] | true | false | true | false | false | let compute_iv_BE_reveal =
| opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def | false |
|
Vale.AES.GCM_BE_s.fst | Vale.AES.GCM_BE_s.gcm_encrypt_BE | val gcm_encrypt_BE : alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
iv: Vale.AES.GCM_BE_s.supported_iv_BE ->
plain: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8
-> Prims.Pure
(FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * FStar.Seq.Base.seq Vale.Def.Types_s.nat8) | let gcm_encrypt_BE = opaque_make gcm_encrypt_BE_def | {
"file_name": "vale/specs/crypto/Vale.AES.GCM_BE_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 70,
"end_line": 62,
"start_col": 19,
"start_line": 62
} | module Vale.AES.GCM_BE_s
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.AES.AES_BE_s
open Vale.AES.GCTR_BE_s
open Vale.AES.GHash_BE_s
open FStar.Seq
open FStar.Mul
#reset-options "--z3rlimit 30"
type supported_iv_BE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 }
let compute_iv_BE_def (h_BE:quad32) (iv:supported_iv_BE) : quad32
=
if 8 * (length iv) = 96 then (
let iv_BE = be_bytes_to_quad32 (pad_to_128_bits iv) in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE
) else (
let padded_iv_quads = be_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = two_two_to_four (Mktwo (nat_to_two 32 0) (nat_to_two 32 (8 * length iv))) in
let hash_input_BE = append padded_iv_quads (create 1 length_BE) in
let hash_output_BE = ghash_BE h_BE hash_input_BE in
hash_output_BE
)
[@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def
irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def
let gcm_encrypt_BE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_BE) (plain:seq nat8) (auth:seq nat8) :
Pure (seq nat8 & seq nat8)
(requires
is_aes_key alg key /\
length plain < pow2_32 /\
length auth < pow2_32
)
(ensures fun (c, t) -> True)
=
let key_BE = seq_nat8_to_seq_nat32_BE key in
let h_BE = aes_encrypt_word alg key_BE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_BE iv in
let c = gctr_encrypt (inc32 j0_BE 1) plain alg key_BE in
// Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth
let lengths_BE = two_two_to_four (Mktwo (nat_to_two 32 (8 * length auth)) (nat_to_two 32 (8 * length plain))) in
let zero_padded_c_BE = be_bytes_to_seq_quad32 (pad_to_128_bits c) in
let zero_padded_a_BE = be_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_BE = append zero_padded_a_BE (append zero_padded_c_BE (create 1 lengths_BE)) in
let s_BE = ghash_BE h_BE hash_input_BE in
let t = gctr_encrypt j0_BE (be_quad32_to_bytes s_BE) alg key_BE in | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash_BE_s.fst.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GCM_BE_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"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.Seq_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.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
iv: Vale.AES.GCM_BE_s.supported_iv_BE ->
plain: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8
-> Prims.Pure
(FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * FStar.Seq.Base.seq Vale.Def.Types_s.nat8) | Prims.Pure | [] | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Vale.AES.GCM_BE_s.supported_iv_BE",
"FStar.Pervasives.Native.tuple2",
"Prims.l_and",
"Vale.AES.AES_common_s.is_aes_key",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Vale.Def.Words_s.pow2_32",
"Prims.l_True",
"Vale.AES.GCM_BE_s.gcm_encrypt_BE_def"
] | [] | false | false | false | false | false | let gcm_encrypt_BE =
| opaque_make gcm_encrypt_BE_def | false |
|
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.va_qAssert | val va_qAssert (#a: Type) (#cs: codes) (r: range) (msg: string) (e: Type0) (qcs: quickCodes a cs)
: quickCodes a cs | val va_qAssert (#a: Type) (#cs: codes) (r: range) (msg: string) (e: Type0) (qcs: quickCodes a cs)
: quickCodes a cs | let va_qAssert (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg e (fun () -> e) (qAssertLemma e) qcs | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 51,
"end_line": 315,
"start_col": 0,
"start_line": 314
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1
[@va_qattr]
let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1))
[@va_qattr]
let wp_While
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Type0 =
inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
// REVIEW: we could get a better WP with forall (...state components...) instead of forall (s1:va_state)
(forall (s1:va_state) (g1:a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k)
val qWhile_proof
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k)
(ensures fun (sM, f0, g) ->
eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qWhile
(#a #d:Type) (#c:code) (mods:mods_t) (b:cmp) (qc:a -> quickCode a c) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a)
: quickCode a (While (cmp_to_ocmp b) c) =
QProc (While (cmp_to_ocmp b) c) mods (wp_While b qc mods inv dec g0)
(qWhile_proof b qc mods inv dec g0)
///// Assert, Assume, AssertBy
let tAssertLemma (p:Type0) = unit -> Lemma (requires p) (ensures p)
val qAssertLemma (p:Type0) : tAssertLemma p | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
r: FStar.Range.range ->
msg: Prims.string ->
e: Type0 ->
qcs: Vale.PPC64LE.QuickCodes.quickCodes a cs
-> Vale.PPC64LE.QuickCodes.quickCodes a cs | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.codes",
"FStar.Range.range",
"Prims.string",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.QuickCodes.QLemma",
"Prims.unit",
"Vale.PPC64LE.QuickCodes.qAssertLemma"
] | [] | false | false | false | false | false | let va_qAssert (#a: Type) (#cs: codes) (r: range) (msg: string) (e: Type0) (qcs: quickCodes a cs)
: quickCodes a cs =
| QLemma r msg e (fun () -> e) (qAssertLemma e) qcs | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.tAssertSquashLemma | val tAssertSquashLemma : p: Type0 -> Type0 | let tAssertSquashLemma (p:Type0) = unit -> Ghost (squash p) (requires p) (ensures fun () -> p) | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 94,
"end_line": 324,
"start_col": 0,
"start_line": 324
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1
[@va_qattr]
let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1))
[@va_qattr]
let wp_While
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Type0 =
inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
// REVIEW: we could get a better WP with forall (...state components...) instead of forall (s1:va_state)
(forall (s1:va_state) (g1:a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k)
val qWhile_proof
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k)
(ensures fun (sM, f0, g) ->
eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qWhile
(#a #d:Type) (#c:code) (mods:mods_t) (b:cmp) (qc:a -> quickCode a c) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a)
: quickCode a (While (cmp_to_ocmp b) c) =
QProc (While (cmp_to_ocmp b) c) mods (wp_While b qc mods inv dec g0)
(qWhile_proof b qc mods inv dec g0)
///// Assert, Assume, AssertBy
let tAssertLemma (p:Type0) = unit -> Lemma (requires p) (ensures p)
val qAssertLemma (p:Type0) : tAssertLemma p
[@va_qattr]
let va_qAssert (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg e (fun () -> e) (qAssertLemma e) qcs
let tAssumeLemma (p:Type0) = unit -> Lemma (requires True) (ensures p)
val qAssumeLemma (p:Type0) : tAssumeLemma p
[@va_qattr]
let va_qAssume (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg True (fun () -> e) (qAssumeLemma e) qcs | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Type0 -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"Prims.squash"
] | [] | false | false | false | true | true | let tAssertSquashLemma (p: Type0) =
| unit -> Ghost (squash p) (requires p) (ensures fun () -> p) | false |
|
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.tAssumeLemma | val tAssumeLemma : p: Type0 -> Type0 | let tAssumeLemma (p:Type0) = unit -> Lemma (requires True) (ensures p) | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 70,
"end_line": 317,
"start_col": 0,
"start_line": 317
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1
[@va_qattr]
let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1))
[@va_qattr]
let wp_While
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Type0 =
inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
// REVIEW: we could get a better WP with forall (...state components...) instead of forall (s1:va_state)
(forall (s1:va_state) (g1:a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k)
val qWhile_proof
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k)
(ensures fun (sM, f0, g) ->
eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qWhile
(#a #d:Type) (#c:code) (mods:mods_t) (b:cmp) (qc:a -> quickCode a c) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a)
: quickCode a (While (cmp_to_ocmp b) c) =
QProc (While (cmp_to_ocmp b) c) mods (wp_While b qc mods inv dec g0)
(qWhile_proof b qc mods inv dec g0)
///// Assert, Assume, AssertBy
let tAssertLemma (p:Type0) = unit -> Lemma (requires p) (ensures p)
val qAssertLemma (p:Type0) : tAssertLemma p
[@va_qattr]
let va_qAssert (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg e (fun () -> e) (qAssertLemma e) qcs | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Type0 -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | false | true | true | let tAssumeLemma (p: Type0) =
| unit -> Lemma (requires True) (ensures p) | false |
|
Arith.fst | Arith.lem0 | val lem0 : x: Prims.int -> Prims.unit | let lem0 (x:int) =
assert (op_Multiply 2 (x + 3) == 6 + (op_Multiply 3 x) - x)
by (prune ""; addns "Prims") | {
"file_name": "examples/tactics/Arith.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 36,
"end_line": 27,
"start_col": 0,
"start_line": 25
} | (*
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 Arith
//
open FStar.Tactics.V2
open FStar.Tactics.Arith
open FStar.List
open FStar.Mul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Arith.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Arith.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Arith",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.int -> Prims.unit | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"FStar.Tactics.Effect.assert_by_tactic",
"Prims.eq2",
"Prims.op_Multiply",
"Prims.op_Addition",
"Prims.op_Subtraction",
"Prims.unit",
"FStar.Stubs.Tactics.V2.Builtins.addns",
"FStar.Stubs.Tactics.V2.Builtins.prune"
] | [] | false | false | false | true | false | let lem0 (x: int) =
| FStar.Tactics.Effect.assert_by_tactic (op_Multiply 2 (x + 3) == 6 + (op_Multiply 3 x) - x)
(fun _ ->
();
(prune "";
addns "Prims")) | false |
|
Vale.AES.GCM_BE_s.fst | Vale.AES.GCM_BE_s.gcm_encrypt_BE_reveal | val gcm_encrypt_BE_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.AES.GCM_BE_s.gcm_encrypt_BE == Vale.AES.GCM_BE_s.gcm_encrypt_BE_def) | let gcm_encrypt_BE_reveal = opaque_revealer (`%gcm_encrypt_BE) gcm_encrypt_BE gcm_encrypt_BE_def | {
"file_name": "vale/specs/crypto/Vale.AES.GCM_BE_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 108,
"end_line": 63,
"start_col": 12,
"start_line": 63
} | module Vale.AES.GCM_BE_s
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.AES.AES_BE_s
open Vale.AES.GCTR_BE_s
open Vale.AES.GHash_BE_s
open FStar.Seq
open FStar.Mul
#reset-options "--z3rlimit 30"
type supported_iv_BE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 }
let compute_iv_BE_def (h_BE:quad32) (iv:supported_iv_BE) : quad32
=
if 8 * (length iv) = 96 then (
let iv_BE = be_bytes_to_quad32 (pad_to_128_bits iv) in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE
) else (
let padded_iv_quads = be_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = two_two_to_four (Mktwo (nat_to_two 32 0) (nat_to_two 32 (8 * length iv))) in
let hash_input_BE = append padded_iv_quads (create 1 length_BE) in
let hash_output_BE = ghash_BE h_BE hash_input_BE in
hash_output_BE
)
[@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def
irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def
let gcm_encrypt_BE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_BE) (plain:seq nat8) (auth:seq nat8) :
Pure (seq nat8 & seq nat8)
(requires
is_aes_key alg key /\
length plain < pow2_32 /\
length auth < pow2_32
)
(ensures fun (c, t) -> True)
=
let key_BE = seq_nat8_to_seq_nat32_BE key in
let h_BE = aes_encrypt_word alg key_BE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_BE iv in
let c = gctr_encrypt (inc32 j0_BE 1) plain alg key_BE in
// Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth
let lengths_BE = two_two_to_four (Mktwo (nat_to_two 32 (8 * length auth)) (nat_to_two 32 (8 * length plain))) in
let zero_padded_c_BE = be_bytes_to_seq_quad32 (pad_to_128_bits c) in
let zero_padded_a_BE = be_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_BE = append zero_padded_a_BE (append zero_padded_c_BE (create 1 lengths_BE)) in
let s_BE = ghash_BE h_BE hash_input_BE in
let t = gctr_encrypt j0_BE (be_quad32_to_bytes s_BE) alg key_BE in
(c, t) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash_BE_s.fst.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GCM_BE_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"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.Seq_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.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.AES.GCM_BE_s.gcm_encrypt_BE == Vale.AES.GCM_BE_s.gcm_encrypt_BE_def) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Vale.AES.GCM_BE_s.supported_iv_BE",
"FStar.Pervasives.Native.tuple2",
"Prims.l_and",
"Vale.AES.AES_common_s.is_aes_key",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Vale.Def.Words_s.pow2_32",
"Prims.l_True",
"Vale.AES.GCM_BE_s.gcm_encrypt_BE",
"Vale.AES.GCM_BE_s.gcm_encrypt_BE_def"
] | [] | true | false | true | false | false | let gcm_encrypt_BE_reveal =
| opaque_revealer (`%gcm_encrypt_BE) gcm_encrypt_BE gcm_encrypt_BE_def | false |
|
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.va_qAssertSquash | val va_qAssertSquash
(#a: Type)
(#cs: codes)
(r: range)
(msg: string)
(e: Type0)
(qcs: (squash e -> GTot (quickCodes a cs)))
: quickCodes a ((Block []) :: cs) | val va_qAssertSquash
(#a: Type)
(#cs: codes)
(r: range)
(msg: string)
(e: Type0)
(qcs: (squash e -> GTot (quickCodes a cs)))
: quickCodes a ((Block []) :: cs) | let va_qAssertSquash
(#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:squash e -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QGhost (squash e) r msg e (fun () -> e) (qAssertSquashLemma e) qcs | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 68,
"end_line": 331,
"start_col": 0,
"start_line": 328
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1
[@va_qattr]
let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1))
[@va_qattr]
let wp_While
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Type0 =
inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
// REVIEW: we could get a better WP with forall (...state components...) instead of forall (s1:va_state)
(forall (s1:va_state) (g1:a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k)
val qWhile_proof
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k)
(ensures fun (sM, f0, g) ->
eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qWhile
(#a #d:Type) (#c:code) (mods:mods_t) (b:cmp) (qc:a -> quickCode a c) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a)
: quickCode a (While (cmp_to_ocmp b) c) =
QProc (While (cmp_to_ocmp b) c) mods (wp_While b qc mods inv dec g0)
(qWhile_proof b qc mods inv dec g0)
///// Assert, Assume, AssertBy
let tAssertLemma (p:Type0) = unit -> Lemma (requires p) (ensures p)
val qAssertLemma (p:Type0) : tAssertLemma p
[@va_qattr]
let va_qAssert (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg e (fun () -> e) (qAssertLemma e) qcs
let tAssumeLemma (p:Type0) = unit -> Lemma (requires True) (ensures p)
val qAssumeLemma (p:Type0) : tAssumeLemma p
[@va_qattr]
let va_qAssume (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg True (fun () -> e) (qAssumeLemma e) qcs
let tAssertSquashLemma (p:Type0) = unit -> Ghost (squash p) (requires p) (ensures fun () -> p)
val qAssertSquashLemma (p:Type0) : tAssertSquashLemma p | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
r: FStar.Range.range ->
msg: Prims.string ->
e: Type0 ->
qcs: (_: Prims.squash e -> Prims.GTot (Vale.PPC64LE.QuickCodes.quickCodes a cs))
-> Vale.PPC64LE.QuickCodes.quickCodes a (Vale.PPC64LE.Machine_s.Block [] :: cs) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.codes",
"FStar.Range.range",
"Prims.string",
"Prims.squash",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.QuickCodes.QGhost",
"Prims.unit",
"Vale.PPC64LE.QuickCodes.qAssertSquashLemma",
"Prims.Cons",
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.Machine_s.Block",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Prims.Nil",
"Vale.PPC64LE.Machine_s.precode"
] | [] | false | false | false | false | false | let va_qAssertSquash
(#a: Type)
(#cs: codes)
(r: range)
(msg: string)
(e: Type0)
(qcs: (squash e -> GTot (quickCodes a cs)))
: quickCodes a ((Block []) :: cs) =
| QGhost (squash e) r msg e (fun () -> e) (qAssertSquashLemma e) qcs | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.va_qAssertBy | val va_qAssertBy
(#a: Type)
(#cs: codes)
(r: range)
(msg: string)
(p: Type0)
(qcsBy: quickCodes unit [])
(qcsTail: quickCodes a cs)
: quickCodes a cs | val va_qAssertBy
(#a: Type)
(#cs: codes)
(r: range)
(msg: string)
(p: Type0)
(qcsBy: quickCodes unit [])
(qcsTail: quickCodes a cs)
: quickCodes a cs | let va_qAssertBy (#a:Type) (#cs:codes) (r:range) (msg:string) (p:Type0) (qcsBy:quickCodes unit []) (qcsTail:quickCodes a cs) : quickCodes a cs =
QAssertBy r msg p qcsBy qcsTail | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 343,
"start_col": 0,
"start_line": 342
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1
[@va_qattr]
let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1))
[@va_qattr]
let wp_While
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Type0 =
inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
// REVIEW: we could get a better WP with forall (...state components...) instead of forall (s1:va_state)
(forall (s1:va_state) (g1:a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k)
val qWhile_proof
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k)
(ensures fun (sM, f0, g) ->
eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qWhile
(#a #d:Type) (#c:code) (mods:mods_t) (b:cmp) (qc:a -> quickCode a c) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a)
: quickCode a (While (cmp_to_ocmp b) c) =
QProc (While (cmp_to_ocmp b) c) mods (wp_While b qc mods inv dec g0)
(qWhile_proof b qc mods inv dec g0)
///// Assert, Assume, AssertBy
let tAssertLemma (p:Type0) = unit -> Lemma (requires p) (ensures p)
val qAssertLemma (p:Type0) : tAssertLemma p
[@va_qattr]
let va_qAssert (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg e (fun () -> e) (qAssertLemma e) qcs
let tAssumeLemma (p:Type0) = unit -> Lemma (requires True) (ensures p)
val qAssumeLemma (p:Type0) : tAssumeLemma p
[@va_qattr]
let va_qAssume (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg True (fun () -> e) (qAssumeLemma e) qcs
let tAssertSquashLemma (p:Type0) = unit -> Ghost (squash p) (requires p) (ensures fun () -> p)
val qAssertSquashLemma (p:Type0) : tAssertSquashLemma p
[@va_qattr]
let va_qAssertSquash
(#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:squash e -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QGhost (squash e) r msg e (fun () -> e) (qAssertSquashLemma e) qcs
//let tAssertByLemma (#a:Type) (p:Type0) (qcs:quickCodes a []) (mods:mods_t) (s0:state) =
// unit -> Lemma (requires t_require s0 /\ wp [] qcs mods (fun _ _ -> p) s0) (ensures p)
//val qAssertByLemma (#a:Type) (p:Type0) (qcs:quickCodes a []) (mods:mods_t) (s0:state) : tAssertByLemma p qcs mods s0
//
//[@va_qattr]
//let va_qAssertBy (#a:Type) (#cs:codes) (mods:mods_t) (r:range) (msg:string) (p:Type0) (qcsBy:quickCodes unit []) (s0:state) (qcsTail:quickCodes a cs) : quickCodes a cs =
// QLemma r msg (t_require s0 /\ wp [] qcsBy mods (fun _ _ -> p) s0) (fun () -> p) (qAssertByLemma p qcsBy mods s0) qcsTail | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
r: FStar.Range.range ->
msg: Prims.string ->
p: Type0 ->
qcsBy: Vale.PPC64LE.QuickCodes.quickCodes Prims.unit [] ->
qcsTail: Vale.PPC64LE.QuickCodes.quickCodes a cs
-> Vale.PPC64LE.QuickCodes.quickCodes a cs | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.codes",
"FStar.Range.range",
"Prims.string",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Prims.unit",
"Prims.Nil",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.QuickCodes.QAssertBy"
] | [] | false | false | false | false | false | let va_qAssertBy
(#a: Type)
(#cs: codes)
(r: range)
(msg: string)
(p: Type0)
(qcsBy: quickCodes unit [])
(qcsTail: quickCodes a cs)
: quickCodes a cs =
| QAssertBy r msg p qcsBy qcsTail | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.va_qAssume | val va_qAssume (#a: Type) (#cs: codes) (r: range) (msg: string) (e: Type0) (qcs: quickCodes a cs)
: quickCodes a cs | val va_qAssume (#a: Type) (#cs: codes) (r: range) (msg: string) (e: Type0) (qcs: quickCodes a cs)
: quickCodes a cs | let va_qAssume (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg True (fun () -> e) (qAssumeLemma e) qcs | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 54,
"end_line": 322,
"start_col": 0,
"start_line": 321
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1
[@va_qattr]
let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1))
[@va_qattr]
let wp_While
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Type0 =
inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
// REVIEW: we could get a better WP with forall (...state components...) instead of forall (s1:va_state)
(forall (s1:va_state) (g1:a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k)
val qWhile_proof
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k)
(ensures fun (sM, f0, g) ->
eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qWhile
(#a #d:Type) (#c:code) (mods:mods_t) (b:cmp) (qc:a -> quickCode a c) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a)
: quickCode a (While (cmp_to_ocmp b) c) =
QProc (While (cmp_to_ocmp b) c) mods (wp_While b qc mods inv dec g0)
(qWhile_proof b qc mods inv dec g0)
///// Assert, Assume, AssertBy
let tAssertLemma (p:Type0) = unit -> Lemma (requires p) (ensures p)
val qAssertLemma (p:Type0) : tAssertLemma p
[@va_qattr]
let va_qAssert (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg e (fun () -> e) (qAssertLemma e) qcs
let tAssumeLemma (p:Type0) = unit -> Lemma (requires True) (ensures p)
val qAssumeLemma (p:Type0) : tAssumeLemma p | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
r: FStar.Range.range ->
msg: Prims.string ->
e: Type0 ->
qcs: Vale.PPC64LE.QuickCodes.quickCodes a cs
-> Vale.PPC64LE.QuickCodes.quickCodes a cs | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.codes",
"FStar.Range.range",
"Prims.string",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.QuickCodes.QLemma",
"Prims.l_True",
"Prims.unit",
"Vale.PPC64LE.QuickCodes.qAssumeLemma"
] | [] | false | false | false | false | false | let va_qAssume (#a: Type) (#cs: codes) (r: range) (msg: string) (e: Type0) (qcs: quickCodes a cs)
: quickCodes a cs =
| QLemma r msg True (fun () -> e) (qAssumeLemma e) qcs | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.state_match | val state_match (s0 s1: va_state) : Type0 | val state_match (s0 s1: va_state) : Type0 | let state_match (s0:va_state) (s1:va_state) : Type0 =
s0.ok == s1.ok /\
Regs.equal s0.regs s1.regs /\
Vecs.equal s0.vecs s1.vecs /\
s0.cr0 == s1.cr0 /\
s0.xer == s1.xer /\
s0.ms_heap == s1.ms_heap /\
s0.ms_stack == s1.ms_stack /\
s0.ms_stackTaint == s1.ms_stackTaint | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 361,
"start_col": 0,
"start_line": 353
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1
[@va_qattr]
let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1))
[@va_qattr]
let wp_While
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Type0 =
inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
// REVIEW: we could get a better WP with forall (...state components...) instead of forall (s1:va_state)
(forall (s1:va_state) (g1:a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k)
val qWhile_proof
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k)
(ensures fun (sM, f0, g) ->
eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qWhile
(#a #d:Type) (#c:code) (mods:mods_t) (b:cmp) (qc:a -> quickCode a c) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a)
: quickCode a (While (cmp_to_ocmp b) c) =
QProc (While (cmp_to_ocmp b) c) mods (wp_While b qc mods inv dec g0)
(qWhile_proof b qc mods inv dec g0)
///// Assert, Assume, AssertBy
let tAssertLemma (p:Type0) = unit -> Lemma (requires p) (ensures p)
val qAssertLemma (p:Type0) : tAssertLemma p
[@va_qattr]
let va_qAssert (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg e (fun () -> e) (qAssertLemma e) qcs
let tAssumeLemma (p:Type0) = unit -> Lemma (requires True) (ensures p)
val qAssumeLemma (p:Type0) : tAssumeLemma p
[@va_qattr]
let va_qAssume (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg True (fun () -> e) (qAssumeLemma e) qcs
let tAssertSquashLemma (p:Type0) = unit -> Ghost (squash p) (requires p) (ensures fun () -> p)
val qAssertSquashLemma (p:Type0) : tAssertSquashLemma p
[@va_qattr]
let va_qAssertSquash
(#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:squash e -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QGhost (squash e) r msg e (fun () -> e) (qAssertSquashLemma e) qcs
//let tAssertByLemma (#a:Type) (p:Type0) (qcs:quickCodes a []) (mods:mods_t) (s0:state) =
// unit -> Lemma (requires t_require s0 /\ wp [] qcs mods (fun _ _ -> p) s0) (ensures p)
//val qAssertByLemma (#a:Type) (p:Type0) (qcs:quickCodes a []) (mods:mods_t) (s0:state) : tAssertByLemma p qcs mods s0
//
//[@va_qattr]
//let va_qAssertBy (#a:Type) (#cs:codes) (mods:mods_t) (r:range) (msg:string) (p:Type0) (qcsBy:quickCodes unit []) (s0:state) (qcsTail:quickCodes a cs) : quickCodes a cs =
// QLemma r msg (t_require s0 /\ wp [] qcsBy mods (fun _ _ -> p) s0) (fun () -> p) (qAssertByLemma p qcsBy mods s0) qcsTail
[@va_qattr]
let va_qAssertBy (#a:Type) (#cs:codes) (r:range) (msg:string) (p:Type0) (qcsBy:quickCodes unit []) (qcsTail:quickCodes a cs) : quickCodes a cs =
QAssertBy r msg p qcsBy qcsTail
///// Code
val wp_sound_code (#a:Type0) (c:code) (qc:quickCode a c) (k:va_state -> a -> Type0) (s0:va_state) :
Ghost (va_state & fuel & a)
(requires t_require s0 /\ QProc?.wp qc s0 k)
(ensures fun (sN, fN, gN) -> eval_code c s0 fN sN /\ update_state_mods qc.mods sN s0 == sN /\ state_inv sN /\ k sN gN) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s0: Vale.PPC64LE.Decls.va_state -> s1: Vale.PPC64LE.Decls.va_state -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_state",
"Prims.l_and",
"Prims.eq2",
"Prims.bool",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ok",
"Vale.PPC64LE.Regs.equal",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__regs",
"Vale.PPC64LE.Vecs.equal",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__vecs",
"Vale.PPC64LE.Machine_s.cr0_t",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__cr0",
"Vale.PPC64LE.Machine_s.xer_t",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__xer",
"Vale.Arch.Heap.heap_impl",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_heap",
"Vale.PPC64LE.Machine_s.machine_stack",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_stack",
"Vale.Arch.HeapTypes_s.memTaint_t",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_stackTaint"
] | [] | false | false | false | true | true | let state_match (s0 s1: va_state) : Type0 =
| s0.ok == s1.ok /\ Regs.equal s0.regs s1.regs /\ Vecs.equal s0.vecs s1.vecs /\ s0.cr0 == s1.cr0 /\
s0.xer == s1.xer /\ s0.ms_heap == s1.ms_heap /\ s0.ms_stack == s1.ms_stack /\
s0.ms_stackTaint == s1.ms_stackTaint | false |
FStar.Seq.Permutation.fsti | FStar.Seq.Permutation.index_fun | val index_fun : s: FStar.Seq.Base.seq a -> Type0 | let index_fun #a (s:seq a) = under (Seq.length s) -> under (Seq.length s) | {
"file_name": "ulib/FStar.Seq.Permutation.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 73,
"end_line": 39,
"start_col": 0,
"start_line": 39
} | (*
Copyright 2021-2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Authors: N. Swamy, A. Rastogi, A. Rozanov
*)
module FStar.Seq.Permutation
open FStar.Seq
open FStar.IntegerIntervals
(* This module defines a permutation on sequences as a bijection among
the sequence indices relating equal elements.
It defines a few utilities to work with such permutations.
Notably:
1. Given two sequence with equal element counts, it constructs a
permutation.
2. Folding the multiplication of a commutative monoid over a
sequence and its permutation produces the equivalent results
*) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.Equiv.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IntegerIntervals.fst.checked",
"FStar.Algebra.CommMonoid.Equiv.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Seq.Permutation.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.IntegerIntervals",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Seq.Base.seq a -> Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"FStar.IntegerIntervals.under",
"FStar.Seq.Base.length"
] | [] | false | false | false | true | true | let index_fun #a (s: seq a) =
| under (Seq.length s) -> under (Seq.length s) | false |
|
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.wp_sound_code_post | val wp_sound_code_post : qc: Vale.PPC64LE.QuickCode.quickCode a c ->
s0: Vale.PPC64LE.Decls.va_state ->
k:
(s0': Vale.PPC64LE.Decls.va_state{s0 == s0'} -> _: Vale.PPC64LE.Decls.va_state -> _: a
-> Type0) ->
_: ((Vale.PPC64LE.State.state * Vale.PPC64LE.Decls.va_fuel) * a)
-> Type0 | let wp_sound_code_post (#a:Type0) (#c:code) (qc:quickCode a c) (s0:va_state) (k:(s0':va_state{s0 == s0'}) -> va_state -> a -> Type0) ((sN:va_state), (fN:fuel), (gN:a)) : Type0 =
eval c s0 fN sN /\
update_state_mods qc.mods sN s0 == sN /\
state_inv sN /\
k s0 sN gN | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 12,
"end_line": 411,
"start_col": 7,
"start_line": 407
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1
[@va_qattr]
let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1))
[@va_qattr]
let wp_While
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Type0 =
inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
// REVIEW: we could get a better WP with forall (...state components...) instead of forall (s1:va_state)
(forall (s1:va_state) (g1:a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k)
val qWhile_proof
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k)
(ensures fun (sM, f0, g) ->
eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qWhile
(#a #d:Type) (#c:code) (mods:mods_t) (b:cmp) (qc:a -> quickCode a c) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a)
: quickCode a (While (cmp_to_ocmp b) c) =
QProc (While (cmp_to_ocmp b) c) mods (wp_While b qc mods inv dec g0)
(qWhile_proof b qc mods inv dec g0)
///// Assert, Assume, AssertBy
let tAssertLemma (p:Type0) = unit -> Lemma (requires p) (ensures p)
val qAssertLemma (p:Type0) : tAssertLemma p
[@va_qattr]
let va_qAssert (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg e (fun () -> e) (qAssertLemma e) qcs
let tAssumeLemma (p:Type0) = unit -> Lemma (requires True) (ensures p)
val qAssumeLemma (p:Type0) : tAssumeLemma p
[@va_qattr]
let va_qAssume (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg True (fun () -> e) (qAssumeLemma e) qcs
let tAssertSquashLemma (p:Type0) = unit -> Ghost (squash p) (requires p) (ensures fun () -> p)
val qAssertSquashLemma (p:Type0) : tAssertSquashLemma p
[@va_qattr]
let va_qAssertSquash
(#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:squash e -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QGhost (squash e) r msg e (fun () -> e) (qAssertSquashLemma e) qcs
//let tAssertByLemma (#a:Type) (p:Type0) (qcs:quickCodes a []) (mods:mods_t) (s0:state) =
// unit -> Lemma (requires t_require s0 /\ wp [] qcs mods (fun _ _ -> p) s0) (ensures p)
//val qAssertByLemma (#a:Type) (p:Type0) (qcs:quickCodes a []) (mods:mods_t) (s0:state) : tAssertByLemma p qcs mods s0
//
//[@va_qattr]
//let va_qAssertBy (#a:Type) (#cs:codes) (mods:mods_t) (r:range) (msg:string) (p:Type0) (qcsBy:quickCodes unit []) (s0:state) (qcsTail:quickCodes a cs) : quickCodes a cs =
// QLemma r msg (t_require s0 /\ wp [] qcsBy mods (fun _ _ -> p) s0) (fun () -> p) (qAssertByLemma p qcsBy mods s0) qcsTail
[@va_qattr]
let va_qAssertBy (#a:Type) (#cs:codes) (r:range) (msg:string) (p:Type0) (qcsBy:quickCodes unit []) (qcsTail:quickCodes a cs) : quickCodes a cs =
QAssertBy r msg p qcsBy qcsTail
///// Code
val wp_sound_code (#a:Type0) (c:code) (qc:quickCode a c) (k:va_state -> a -> Type0) (s0:va_state) :
Ghost (va_state & fuel & a)
(requires t_require s0 /\ QProc?.wp qc s0 k)
(ensures fun (sN, fN, gN) -> eval_code c s0 fN sN /\ update_state_mods qc.mods sN s0 == sN /\ state_inv sN /\ k sN gN)
[@va_qattr]
let state_match (s0:va_state) (s1:va_state) : Type0 =
s0.ok == s1.ok /\
Regs.equal s0.regs s1.regs /\
Vecs.equal s0.vecs s1.vecs /\
s0.cr0 == s1.cr0 /\
s0.xer == s1.xer /\
s0.ms_heap == s1.ms_heap /\
s0.ms_stack == s1.ms_stack /\
s0.ms_stackTaint == s1.ms_stackTaint
val lemma_state_match (s0:va_state) (s1:va_state) : Lemma
(requires state_match s0 s1)
(ensures state_eq s0 s1)
[@va_qattr]
let va_state_match (s0:va_state) (s1:va_state) : Pure Type0
(requires True)
(ensures fun b -> b ==> state_eq s0 s1)
=
FStar.Classical.move_requires (lemma_state_match s0) s1;
state_match s0 s1
[@va_qattr]
unfold let wp_sound_code_pre (#a:Type0) (#c:code) (qc:quickCode a c) (s0:va_state) (k:(s0':va_state{s0 == s0'}) -> va_state -> a -> Type0) : Type0 =
forall
(ok:bool)
(regs:Regs.t)
(vecs:Vecs.t)
(cr0:cr0_t)
(xer:xer_t)
//(mem:vale_full_heap) // splitting mem into its components makes the VCs slightly cleaner:
(mem_layout:vale_heap_layout)
(mem_heap:vale_heap)
(mem_heaplets:vale_heaplets)
(stack:machine_stack)
(stackTaint:memtaint)
.
let mem = {
vf_layout = mem_layout;
vf_heap = mem_heap;
vf_heaplets = mem_heaplets;
} in
let s0' = {
ok = ok;
regs = regs;
vecs = vecs;
cr0 = cr0;
xer = xer;
ms_heap = coerce mem;
ms_stack = stack;
ms_stackTaint = stackTaint
} in
s0 == s0' ==> QProc?.wp qc (state_eta s0') (k (state_eta s0')) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
qc: Vale.PPC64LE.QuickCode.quickCode a c ->
s0: Vale.PPC64LE.Decls.va_state ->
k:
(s0': Vale.PPC64LE.Decls.va_state{s0 == s0'} -> _: Vale.PPC64LE.Decls.va_state -> _: a
-> Type0) ->
_: ((Vale.PPC64LE.State.state * Vale.PPC64LE.Decls.va_fuel) * a)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.Decls.va_state",
"Prims.eq2",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.State.state",
"Vale.PPC64LE.Decls.va_fuel",
"Prims.l_and",
"Vale.PPC64LE.QuickCodes.eval",
"Vale.PPC64LE.QuickCode.update_state_mods",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.PPC64LE.Decls.state_inv"
] | [] | false | false | false | false | true | let wp_sound_code_post
(#a: Type0)
(#c: code)
(qc: quickCode a c)
(s0: va_state)
(k: (s0': va_state{s0 == s0'} -> va_state -> a -> Type0))
((sN: va_state), (fN: fuel), (gN: a))
: Type0 =
| eval c s0 fN sN /\ update_state_mods qc.mods sN s0 == sN /\ state_inv sN /\ k s0 sN gN | false |
|
Arith.fst | Arith.lem1 | val lem1 : x: Prims.int -> Prims.unit | let lem1 (x:int) =
assert (List.rev [1;2;3;4] == [4;3;2;1] /\ op_Multiply 2 (x + 3) == 6 + (op_Multiply 3 x) - x)
by tau1 () | {
"file_name": "examples/tactics/Arith.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 18,
"end_line": 43,
"start_col": 0,
"start_line": 41
} | (*
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 Arith
//
open FStar.Tactics.V2
open FStar.Tactics.Arith
open FStar.List
open FStar.Mul
let lem0 (x:int) =
assert (op_Multiply 2 (x + 3) == 6 + (op_Multiply 3 x) - x)
by (prune ""; addns "Prims")
// Can't locally define tactics
let tau1 () : Tac unit =
prune "";
FStar.Tactics.split ();
(* rev part *)
addns "FStar.List";
addns "Prims";
smt ();
(* arithmetic part *)
addns "Prims";
smt () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Arith.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Arith.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Arith",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.int -> Prims.unit | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"FStar.Tactics.Effect.assert_by_tactic",
"Prims.l_and",
"Prims.eq2",
"Prims.list",
"FStar.List.Tot.Base.rev",
"Prims.Cons",
"Prims.Nil",
"Prims.op_Multiply",
"Prims.op_Addition",
"Prims.op_Subtraction",
"Prims.unit",
"Arith.tau1"
] | [] | false | false | false | true | false | let lem1 (x: int) =
| FStar.Tactics.Effect.assert_by_tactic (List.rev [1; 2; 3; 4] == [4; 3; 2; 1] /\
op_Multiply 2 (x + 3) == 6 + (op_Multiply 3 x) - x)
(fun _ ->
();
tau1 ()) | false |
|
FStar.Seq.Permutation.fsti | FStar.Seq.Permutation.seqperm | val seqperm : s0: FStar.Seq.Base.seq a -> s1: FStar.Seq.Base.seq a -> Type0 | let seqperm (#a:Type) (s0:seq a) (s1:seq a) =
f:index_fun s0 { is_permutation s0 s1 f } | {
"file_name": "ulib/FStar.Seq.Permutation.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 43,
"end_line": 58,
"start_col": 0,
"start_line": 57
} | (*
Copyright 2021-2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Authors: N. Swamy, A. Rastogi, A. Rozanov
*)
module FStar.Seq.Permutation
open FStar.Seq
open FStar.IntegerIntervals
(* This module defines a permutation on sequences as a bijection among
the sequence indices relating equal elements.
It defines a few utilities to work with such permutations.
Notably:
1. Given two sequence with equal element counts, it constructs a
permutation.
2. Folding the multiplication of a commutative monoid over a
sequence and its permutation produces the equivalent results
*)
(* A function from the indices of `s` to itself *)
let index_fun #a (s:seq a) = under (Seq.length s) -> under (Seq.length s)
(* An abstract predicate defining when an index_fun is a permutation *)
val is_permutation (#a:Type) (s0:seq a) (s1:seq a) (f:index_fun s0) : prop
(* Revealing the interpretation of is_permutation *)
val reveal_is_permutation (#a:Type) (s0 s1:seq a) (f:index_fun s0)
: Lemma (is_permutation s0 s1 f <==>
(* lengths of the sequences are the same *)
Seq.length s0 == Seq.length s1 /\
(* f is injective *)
(forall x y. {:pattern f x; f y}
x <> y ==> f x <> f y) /\
(* and f relates equal items in s0 and s1 *)
(forall (i:nat{i < Seq.length s0}).{:pattern (Seq.index s1 (f i))}
Seq.index s0 i == Seq.index s1 (f i))) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.Equiv.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IntegerIntervals.fst.checked",
"FStar.Algebra.CommMonoid.Equiv.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Seq.Permutation.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.IntegerIntervals",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s0: FStar.Seq.Base.seq a -> s1: FStar.Seq.Base.seq a -> Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"FStar.Seq.Permutation.index_fun",
"FStar.Seq.Permutation.is_permutation"
] | [] | false | false | false | true | true | let seqperm (#a: Type) (s0 s1: seq a) =
| f: index_fun s0 {is_permutation s0 s1 f} | false |
|
FStar.Seq.Permutation.fsti | FStar.Seq.Permutation.func_sum | val func_sum (#a #c #eq: _) (cm: CE.cm c eq) (f g: (a -> c))
: t: (a -> c){forall (x: a). t x == (f x) `cm.mult` (g x)} | val func_sum (#a #c #eq: _) (cm: CE.cm c eq) (f g: (a -> c))
: t: (a -> c){forall (x: a). t x == (f x) `cm.mult` (g x)} | let func_sum #a #c #eq (cm: CE.cm c eq) (f g: a -> c)
: t:(a -> c){ forall (x:a). t x == f x `cm.mult` g x }
= fun (x:a) -> cm.mult (f x) (g x) | {
"file_name": "ulib/FStar.Seq.Permutation.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 36,
"end_line": 124,
"start_col": 0,
"start_line": 122
} | (*
Copyright 2021-2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Authors: N. Swamy, A. Rastogi, A. Rozanov
*)
module FStar.Seq.Permutation
open FStar.Seq
open FStar.IntegerIntervals
(* This module defines a permutation on sequences as a bijection among
the sequence indices relating equal elements.
It defines a few utilities to work with such permutations.
Notably:
1. Given two sequence with equal element counts, it constructs a
permutation.
2. Folding the multiplication of a commutative monoid over a
sequence and its permutation produces the equivalent results
*)
(* A function from the indices of `s` to itself *)
let index_fun #a (s:seq a) = under (Seq.length s) -> under (Seq.length s)
(* An abstract predicate defining when an index_fun is a permutation *)
val is_permutation (#a:Type) (s0:seq a) (s1:seq a) (f:index_fun s0) : prop
(* Revealing the interpretation of is_permutation *)
val reveal_is_permutation (#a:Type) (s0 s1:seq a) (f:index_fun s0)
: Lemma (is_permutation s0 s1 f <==>
(* lengths of the sequences are the same *)
Seq.length s0 == Seq.length s1 /\
(* f is injective *)
(forall x y. {:pattern f x; f y}
x <> y ==> f x <> f y) /\
(* and f relates equal items in s0 and s1 *)
(forall (i:nat{i < Seq.length s0}).{:pattern (Seq.index s1 (f i))}
Seq.index s0 i == Seq.index s1 (f i)))
(* A seqperm is an index_fun that is also a permutation *)
let seqperm (#a:Type) (s0:seq a) (s1:seq a) =
f:index_fun s0 { is_permutation s0 s1 f }
(* We can construct a permutation from
sequences whose element counts are the same *)
val permutation_from_equal_counts
(#a:eqtype)
(s0:seq a) (s1:seq a{(forall x. count x s0 == count x s1)})
: Tot (seqperm s0 s1)
(** Now, some utilities related to commutative monoids and permutations *)
module CE = FStar.Algebra.CommMonoid.Equiv
(* folding a m.mult over a sequence *)
let foldm_snoc (#a:Type) (#eq:CE.equiv a) (m:CE.cm a eq) (s:seq a) =
foldr_snoc m.mult s m.unit
(* folding over a sequence of units is unit *)
val foldm_snoc_unit_seq (#a:Type) (#eq:CE.equiv a) (m:CE.cm a eq) (s:Seq.seq a)
: Lemma (requires Seq.equal s (Seq.create (Seq.length s) m.unit))
(ensures eq.eq (foldm_snoc m s) m.unit)
(* folding over a singleton sequence is the sequence element *)
val foldm_snoc_singleton (#a:_) (#eq:_) (m:CE.cm a eq) (x:a)
: Lemma (eq.eq (foldm_snoc m (Seq.create 1 x)) x)
(* folding m over the concatenation of s1 and s2
can be decomposed into a fold over s1 and a fold over s2 *)
val foldm_snoc_append (#a:Type) (#eq:CE.equiv a) (m:CE.cm a eq) (s1 s2: seq a)
: Lemma
(ensures eq.eq (foldm_snoc m (append s1 s2))
(m.mult (foldm_snoc m s1) (foldm_snoc m s2)))
(* folds over concatenated lists can is symmetric *)
val foldm_snoc_sym (#a:Type) (#eq:CE.equiv a) (m:CE.cm a eq) (s1 s2: seq a)
: Lemma
(ensures eq.eq (foldm_snoc m (append s1 s2))
(foldm_snoc m (append s2 s1)))
(* And, finally, if s0 and s1 are permutations,
then folding m over them is identical *)
val foldm_snoc_perm (#a:_) (#eq:_)
(m:CE.cm a eq)
(s0:seq a)
(s1:seq a)
(p:seqperm s0 s1)
: Lemma
(ensures eq.eq (foldm_snoc m s0) (foldm_snoc m s1))
/// foldm_snoc_split: This next bit is for a lemma that proves that if
/// if the fold is taken over a sequence of sums, it is equal
/// to a sum of folds of the summand sequences
(* This constructs a sequence init function to be used to create
a sequence of function values in a given finite integer range *)
let init_func_from_expr #c (#n0: int) (#nk: not_less_than n0)
(expr: ifrom_ito n0 nk -> c)
(a: ifrom_ito n0 nk)
(b: ifrom_ito a nk)
(i: under (closed_interval_size a b))
: c
= expr (n0+i) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.Equiv.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IntegerIntervals.fst.checked",
"FStar.Algebra.CommMonoid.Equiv.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Seq.Permutation.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.IntegerIntervals",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": 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 | cm: FStar.Algebra.CommMonoid.Equiv.cm c eq -> f: (_: a -> c) -> g: (_: a -> c)
-> t: (_: a -> c){forall (x: a). t x == CM?.mult cm (f x) (g x)} | Prims.Tot | [
"total"
] | [] | [
"FStar.Algebra.CommMonoid.Equiv.equiv",
"FStar.Algebra.CommMonoid.Equiv.cm",
"FStar.Algebra.CommMonoid.Equiv.__proj__CM__item__mult",
"Prims.l_Forall",
"Prims.eq2"
] | [] | false | false | false | false | false | let func_sum #a #c #eq (cm: CE.cm c eq) (f: (a -> c)) (g: (a -> c))
: t: (a -> c){forall (x: a). t x == (f x) `cm.mult` (g x)} =
| fun (x: a) -> cm.mult (f x) (g x) | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.normal_steps | val normal_steps:list string | val normal_steps:list string | let normal_steps : list string =
[
`%Mkstate?.ok;
`%Mkstate?.regs;
`%Mkstate?.vecs;
`%Mkstate?.cr0;
`%Mkstate?.xer;
`%Mkstate?.ms_heap;
`%Mkstate?.ms_stack;
`%Mkstate?.ms_stackTaint;
`%Mkvale_full_heap?.vf_layout;
`%Mkvale_full_heap?.vf_heap;
`%Mkvale_full_heap?.vf_heaplets;
`%QProc?.wp;
`%QProc?.mods;
`%FStar.FunctionalExtensionality.on_dom;
] | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 429,
"start_col": 7,
"start_line": 413
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1
[@va_qattr]
let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1))
[@va_qattr]
let wp_While
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Type0 =
inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
// REVIEW: we could get a better WP with forall (...state components...) instead of forall (s1:va_state)
(forall (s1:va_state) (g1:a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k)
val qWhile_proof
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k)
(ensures fun (sM, f0, g) ->
eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qWhile
(#a #d:Type) (#c:code) (mods:mods_t) (b:cmp) (qc:a -> quickCode a c) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a)
: quickCode a (While (cmp_to_ocmp b) c) =
QProc (While (cmp_to_ocmp b) c) mods (wp_While b qc mods inv dec g0)
(qWhile_proof b qc mods inv dec g0)
///// Assert, Assume, AssertBy
let tAssertLemma (p:Type0) = unit -> Lemma (requires p) (ensures p)
val qAssertLemma (p:Type0) : tAssertLemma p
[@va_qattr]
let va_qAssert (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg e (fun () -> e) (qAssertLemma e) qcs
let tAssumeLemma (p:Type0) = unit -> Lemma (requires True) (ensures p)
val qAssumeLemma (p:Type0) : tAssumeLemma p
[@va_qattr]
let va_qAssume (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg True (fun () -> e) (qAssumeLemma e) qcs
let tAssertSquashLemma (p:Type0) = unit -> Ghost (squash p) (requires p) (ensures fun () -> p)
val qAssertSquashLemma (p:Type0) : tAssertSquashLemma p
[@va_qattr]
let va_qAssertSquash
(#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:squash e -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QGhost (squash e) r msg e (fun () -> e) (qAssertSquashLemma e) qcs
//let tAssertByLemma (#a:Type) (p:Type0) (qcs:quickCodes a []) (mods:mods_t) (s0:state) =
// unit -> Lemma (requires t_require s0 /\ wp [] qcs mods (fun _ _ -> p) s0) (ensures p)
//val qAssertByLemma (#a:Type) (p:Type0) (qcs:quickCodes a []) (mods:mods_t) (s0:state) : tAssertByLemma p qcs mods s0
//
//[@va_qattr]
//let va_qAssertBy (#a:Type) (#cs:codes) (mods:mods_t) (r:range) (msg:string) (p:Type0) (qcsBy:quickCodes unit []) (s0:state) (qcsTail:quickCodes a cs) : quickCodes a cs =
// QLemma r msg (t_require s0 /\ wp [] qcsBy mods (fun _ _ -> p) s0) (fun () -> p) (qAssertByLemma p qcsBy mods s0) qcsTail
[@va_qattr]
let va_qAssertBy (#a:Type) (#cs:codes) (r:range) (msg:string) (p:Type0) (qcsBy:quickCodes unit []) (qcsTail:quickCodes a cs) : quickCodes a cs =
QAssertBy r msg p qcsBy qcsTail
///// Code
val wp_sound_code (#a:Type0) (c:code) (qc:quickCode a c) (k:va_state -> a -> Type0) (s0:va_state) :
Ghost (va_state & fuel & a)
(requires t_require s0 /\ QProc?.wp qc s0 k)
(ensures fun (sN, fN, gN) -> eval_code c s0 fN sN /\ update_state_mods qc.mods sN s0 == sN /\ state_inv sN /\ k sN gN)
[@va_qattr]
let state_match (s0:va_state) (s1:va_state) : Type0 =
s0.ok == s1.ok /\
Regs.equal s0.regs s1.regs /\
Vecs.equal s0.vecs s1.vecs /\
s0.cr0 == s1.cr0 /\
s0.xer == s1.xer /\
s0.ms_heap == s1.ms_heap /\
s0.ms_stack == s1.ms_stack /\
s0.ms_stackTaint == s1.ms_stackTaint
val lemma_state_match (s0:va_state) (s1:va_state) : Lemma
(requires state_match s0 s1)
(ensures state_eq s0 s1)
[@va_qattr]
let va_state_match (s0:va_state) (s1:va_state) : Pure Type0
(requires True)
(ensures fun b -> b ==> state_eq s0 s1)
=
FStar.Classical.move_requires (lemma_state_match s0) s1;
state_match s0 s1
[@va_qattr]
unfold let wp_sound_code_pre (#a:Type0) (#c:code) (qc:quickCode a c) (s0:va_state) (k:(s0':va_state{s0 == s0'}) -> va_state -> a -> Type0) : Type0 =
forall
(ok:bool)
(regs:Regs.t)
(vecs:Vecs.t)
(cr0:cr0_t)
(xer:xer_t)
//(mem:vale_full_heap) // splitting mem into its components makes the VCs slightly cleaner:
(mem_layout:vale_heap_layout)
(mem_heap:vale_heap)
(mem_heaplets:vale_heaplets)
(stack:machine_stack)
(stackTaint:memtaint)
.
let mem = {
vf_layout = mem_layout;
vf_heap = mem_heap;
vf_heaplets = mem_heaplets;
} in
let s0' = {
ok = ok;
regs = regs;
vecs = vecs;
cr0 = cr0;
xer = xer;
ms_heap = coerce mem;
ms_stack = stack;
ms_stackTaint = stackTaint
} in
s0 == s0' ==> QProc?.wp qc (state_eta s0') (k (state_eta s0'))
unfold let wp_sound_code_post (#a:Type0) (#c:code) (qc:quickCode a c) (s0:va_state) (k:(s0':va_state{s0 == s0'}) -> va_state -> a -> Type0) ((sN:va_state), (fN:fuel), (gN:a)) : Type0 =
eval c s0 fN sN /\
update_state_mods qc.mods sN s0 == sN /\
state_inv sN /\
k s0 sN gN | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.list Prims.string | Prims.Tot | [
"total"
] | [] | [
"Prims.Cons",
"Prims.string",
"Prims.Nil"
] | [] | false | false | false | true | false | let normal_steps:list string =
| [
`%Mkstate?.ok; `%Mkstate?.regs; `%Mkstate?.vecs; `%Mkstate?.cr0; `%Mkstate?.xer;
`%Mkstate?.ms_heap; `%Mkstate?.ms_stack; `%Mkstate?.ms_stackTaint; `%Mkvale_full_heap?.vf_layout;
`%Mkvale_full_heap?.vf_heap; `%Mkvale_full_heap?.vf_heaplets; `%QProc?.wp; `%QProc?.mods;
`%FStar.FunctionalExtensionality.on_dom
] | false |
FStar.Seq.Permutation.fsti | FStar.Seq.Permutation.foldm_snoc | val foldm_snoc : m: FStar.Algebra.CommMonoid.Equiv.cm a eq -> s: FStar.Seq.Base.seq a -> a | let foldm_snoc (#a:Type) (#eq:CE.equiv a) (m:CE.cm a eq) (s:seq a) =
foldr_snoc m.mult s m.unit | {
"file_name": "ulib/FStar.Seq.Permutation.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 28,
"end_line": 73,
"start_col": 0,
"start_line": 72
} | (*
Copyright 2021-2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Authors: N. Swamy, A. Rastogi, A. Rozanov
*)
module FStar.Seq.Permutation
open FStar.Seq
open FStar.IntegerIntervals
(* This module defines a permutation on sequences as a bijection among
the sequence indices relating equal elements.
It defines a few utilities to work with such permutations.
Notably:
1. Given two sequence with equal element counts, it constructs a
permutation.
2. Folding the multiplication of a commutative monoid over a
sequence and its permutation produces the equivalent results
*)
(* A function from the indices of `s` to itself *)
let index_fun #a (s:seq a) = under (Seq.length s) -> under (Seq.length s)
(* An abstract predicate defining when an index_fun is a permutation *)
val is_permutation (#a:Type) (s0:seq a) (s1:seq a) (f:index_fun s0) : prop
(* Revealing the interpretation of is_permutation *)
val reveal_is_permutation (#a:Type) (s0 s1:seq a) (f:index_fun s0)
: Lemma (is_permutation s0 s1 f <==>
(* lengths of the sequences are the same *)
Seq.length s0 == Seq.length s1 /\
(* f is injective *)
(forall x y. {:pattern f x; f y}
x <> y ==> f x <> f y) /\
(* and f relates equal items in s0 and s1 *)
(forall (i:nat{i < Seq.length s0}).{:pattern (Seq.index s1 (f i))}
Seq.index s0 i == Seq.index s1 (f i)))
(* A seqperm is an index_fun that is also a permutation *)
let seqperm (#a:Type) (s0:seq a) (s1:seq a) =
f:index_fun s0 { is_permutation s0 s1 f }
(* We can construct a permutation from
sequences whose element counts are the same *)
val permutation_from_equal_counts
(#a:eqtype)
(s0:seq a) (s1:seq a{(forall x. count x s0 == count x s1)})
: Tot (seqperm s0 s1)
(** Now, some utilities related to commutative monoids and permutations *)
module CE = FStar.Algebra.CommMonoid.Equiv | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.Equiv.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IntegerIntervals.fst.checked",
"FStar.Algebra.CommMonoid.Equiv.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Seq.Permutation.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.IntegerIntervals",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: FStar.Algebra.CommMonoid.Equiv.cm a eq -> s: FStar.Seq.Base.seq a -> a | Prims.Tot | [
"total"
] | [] | [
"FStar.Algebra.CommMonoid.Equiv.equiv",
"FStar.Algebra.CommMonoid.Equiv.cm",
"FStar.Seq.Base.seq",
"FStar.Seq.Properties.foldr_snoc",
"FStar.Algebra.CommMonoid.Equiv.__proj__CM__item__mult",
"FStar.Algebra.CommMonoid.Equiv.__proj__CM__item__unit"
] | [] | false | false | false | false | false | let foldm_snoc (#a: Type) (#eq: CE.equiv a) (m: CE.cm a eq) (s: seq a) =
| foldr_snoc m.mult s m.unit | false |
|
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.normal | val normal (x: Type0) : Type0 | val normal (x: Type0) : Type0 | let normal (x:Type0) : Type0 = norm [nbe; iota; zeta; simplify; primops; delta_attr [`%va_qattr]; delta_only normal_steps] x | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 131,
"end_line": 431,
"start_col": 7,
"start_line": 431
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1
[@va_qattr]
let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1))
[@va_qattr]
let wp_While
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Type0 =
inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
// REVIEW: we could get a better WP with forall (...state components...) instead of forall (s1:va_state)
(forall (s1:va_state) (g1:a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k)
val qWhile_proof
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k)
(ensures fun (sM, f0, g) ->
eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qWhile
(#a #d:Type) (#c:code) (mods:mods_t) (b:cmp) (qc:a -> quickCode a c) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a)
: quickCode a (While (cmp_to_ocmp b) c) =
QProc (While (cmp_to_ocmp b) c) mods (wp_While b qc mods inv dec g0)
(qWhile_proof b qc mods inv dec g0)
///// Assert, Assume, AssertBy
let tAssertLemma (p:Type0) = unit -> Lemma (requires p) (ensures p)
val qAssertLemma (p:Type0) : tAssertLemma p
[@va_qattr]
let va_qAssert (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg e (fun () -> e) (qAssertLemma e) qcs
let tAssumeLemma (p:Type0) = unit -> Lemma (requires True) (ensures p)
val qAssumeLemma (p:Type0) : tAssumeLemma p
[@va_qattr]
let va_qAssume (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg True (fun () -> e) (qAssumeLemma e) qcs
let tAssertSquashLemma (p:Type0) = unit -> Ghost (squash p) (requires p) (ensures fun () -> p)
val qAssertSquashLemma (p:Type0) : tAssertSquashLemma p
[@va_qattr]
let va_qAssertSquash
(#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:squash e -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QGhost (squash e) r msg e (fun () -> e) (qAssertSquashLemma e) qcs
//let tAssertByLemma (#a:Type) (p:Type0) (qcs:quickCodes a []) (mods:mods_t) (s0:state) =
// unit -> Lemma (requires t_require s0 /\ wp [] qcs mods (fun _ _ -> p) s0) (ensures p)
//val qAssertByLemma (#a:Type) (p:Type0) (qcs:quickCodes a []) (mods:mods_t) (s0:state) : tAssertByLemma p qcs mods s0
//
//[@va_qattr]
//let va_qAssertBy (#a:Type) (#cs:codes) (mods:mods_t) (r:range) (msg:string) (p:Type0) (qcsBy:quickCodes unit []) (s0:state) (qcsTail:quickCodes a cs) : quickCodes a cs =
// QLemma r msg (t_require s0 /\ wp [] qcsBy mods (fun _ _ -> p) s0) (fun () -> p) (qAssertByLemma p qcsBy mods s0) qcsTail
[@va_qattr]
let va_qAssertBy (#a:Type) (#cs:codes) (r:range) (msg:string) (p:Type0) (qcsBy:quickCodes unit []) (qcsTail:quickCodes a cs) : quickCodes a cs =
QAssertBy r msg p qcsBy qcsTail
///// Code
val wp_sound_code (#a:Type0) (c:code) (qc:quickCode a c) (k:va_state -> a -> Type0) (s0:va_state) :
Ghost (va_state & fuel & a)
(requires t_require s0 /\ QProc?.wp qc s0 k)
(ensures fun (sN, fN, gN) -> eval_code c s0 fN sN /\ update_state_mods qc.mods sN s0 == sN /\ state_inv sN /\ k sN gN)
[@va_qattr]
let state_match (s0:va_state) (s1:va_state) : Type0 =
s0.ok == s1.ok /\
Regs.equal s0.regs s1.regs /\
Vecs.equal s0.vecs s1.vecs /\
s0.cr0 == s1.cr0 /\
s0.xer == s1.xer /\
s0.ms_heap == s1.ms_heap /\
s0.ms_stack == s1.ms_stack /\
s0.ms_stackTaint == s1.ms_stackTaint
val lemma_state_match (s0:va_state) (s1:va_state) : Lemma
(requires state_match s0 s1)
(ensures state_eq s0 s1)
[@va_qattr]
let va_state_match (s0:va_state) (s1:va_state) : Pure Type0
(requires True)
(ensures fun b -> b ==> state_eq s0 s1)
=
FStar.Classical.move_requires (lemma_state_match s0) s1;
state_match s0 s1
[@va_qattr]
unfold let wp_sound_code_pre (#a:Type0) (#c:code) (qc:quickCode a c) (s0:va_state) (k:(s0':va_state{s0 == s0'}) -> va_state -> a -> Type0) : Type0 =
forall
(ok:bool)
(regs:Regs.t)
(vecs:Vecs.t)
(cr0:cr0_t)
(xer:xer_t)
//(mem:vale_full_heap) // splitting mem into its components makes the VCs slightly cleaner:
(mem_layout:vale_heap_layout)
(mem_heap:vale_heap)
(mem_heaplets:vale_heaplets)
(stack:machine_stack)
(stackTaint:memtaint)
.
let mem = {
vf_layout = mem_layout;
vf_heap = mem_heap;
vf_heaplets = mem_heaplets;
} in
let s0' = {
ok = ok;
regs = regs;
vecs = vecs;
cr0 = cr0;
xer = xer;
ms_heap = coerce mem;
ms_stack = stack;
ms_stackTaint = stackTaint
} in
s0 == s0' ==> QProc?.wp qc (state_eta s0') (k (state_eta s0'))
unfold let wp_sound_code_post (#a:Type0) (#c:code) (qc:quickCode a c) (s0:va_state) (k:(s0':va_state{s0 == s0'}) -> va_state -> a -> Type0) ((sN:va_state), (fN:fuel), (gN:a)) : Type0 =
eval c s0 fN sN /\
update_state_mods qc.mods sN s0 == sN /\
state_inv sN /\
k s0 sN gN
unfold let normal_steps : list string =
[
`%Mkstate?.ok;
`%Mkstate?.regs;
`%Mkstate?.vecs;
`%Mkstate?.cr0;
`%Mkstate?.xer;
`%Mkstate?.ms_heap;
`%Mkstate?.ms_stack;
`%Mkstate?.ms_stackTaint;
`%Mkvale_full_heap?.vf_layout;
`%Mkvale_full_heap?.vf_heap;
`%Mkvale_full_heap?.vf_heaplets;
`%QProc?.wp;
`%QProc?.mods;
`%FStar.FunctionalExtensionality.on_dom;
] | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Type0 -> Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.nbe",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.simplify",
"FStar.Pervasives.primops",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.delta_only",
"Vale.PPC64LE.QuickCodes.normal_steps"
] | [] | false | false | false | true | true | let normal (x: Type0) : Type0 =
| norm [nbe; iota; zeta; simplify; primops; delta_attr [`%va_qattr]; delta_only normal_steps] x | false |
Vale.AES.GCM_BE_s.fst | Vale.AES.GCM_BE_s.gcm_decrypt_BE | val gcm_decrypt_BE : alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
iv: Vale.AES.GCM_BE_s.supported_iv_BE ->
cipher: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
tag: FStar.Seq.Base.seq Vale.Def.Types_s.nat8
-> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * Prims.bool) | let gcm_decrypt_BE = opaque_make gcm_decrypt_BE_def | {
"file_name": "vale/specs/crypto/Vale.AES.GCM_BE_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 70,
"end_line": 90,
"start_col": 19,
"start_line": 90
} | module Vale.AES.GCM_BE_s
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.AES.AES_BE_s
open Vale.AES.GCTR_BE_s
open Vale.AES.GHash_BE_s
open FStar.Seq
open FStar.Mul
#reset-options "--z3rlimit 30"
type supported_iv_BE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 }
let compute_iv_BE_def (h_BE:quad32) (iv:supported_iv_BE) : quad32
=
if 8 * (length iv) = 96 then (
let iv_BE = be_bytes_to_quad32 (pad_to_128_bits iv) in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE
) else (
let padded_iv_quads = be_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = two_two_to_four (Mktwo (nat_to_two 32 0) (nat_to_two 32 (8 * length iv))) in
let hash_input_BE = append padded_iv_quads (create 1 length_BE) in
let hash_output_BE = ghash_BE h_BE hash_input_BE in
hash_output_BE
)
[@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def
irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def
let gcm_encrypt_BE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_BE) (plain:seq nat8) (auth:seq nat8) :
Pure (seq nat8 & seq nat8)
(requires
is_aes_key alg key /\
length plain < pow2_32 /\
length auth < pow2_32
)
(ensures fun (c, t) -> True)
=
let key_BE = seq_nat8_to_seq_nat32_BE key in
let h_BE = aes_encrypt_word alg key_BE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_BE iv in
let c = gctr_encrypt (inc32 j0_BE 1) plain alg key_BE in
// Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth
let lengths_BE = two_two_to_four (Mktwo (nat_to_two 32 (8 * length auth)) (nat_to_two 32 (8 * length plain))) in
let zero_padded_c_BE = be_bytes_to_seq_quad32 (pad_to_128_bits c) in
let zero_padded_a_BE = be_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_BE = append zero_padded_a_BE (append zero_padded_c_BE (create 1 lengths_BE)) in
let s_BE = ghash_BE h_BE hash_input_BE in
let t = gctr_encrypt j0_BE (be_quad32_to_bytes s_BE) alg key_BE in
(c, t)
[@"opaque_to_smt"] let gcm_encrypt_BE = opaque_make gcm_encrypt_BE_def
irreducible let gcm_encrypt_BE_reveal = opaque_revealer (`%gcm_encrypt_BE) gcm_encrypt_BE gcm_encrypt_BE_def
let gcm_decrypt_BE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_BE) (cipher:seq nat8) (auth:seq nat8) (tag:seq nat8) :
Pure (seq nat8 & bool)
(requires
is_aes_key alg key /\
length cipher < pow2_32 /\
length auth < pow2_32
)
(ensures fun (p, t) -> True)
=
let key_BE = seq_nat8_to_seq_nat32_BE key in
let h_BE = aes_encrypt_word alg key_BE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_BE iv in
let p = gctr_encrypt (inc32 j0_BE 1) cipher alg key_BE in // TODO: Rename gctr_encrypt to gctr
let lengths_BE = two_two_to_four (Mktwo (nat_to_two 32 (8 * length auth)) (nat_to_two 32 (8 * length cipher))) in
let zero_padded_c_BE = be_bytes_to_seq_quad32 (pad_to_128_bits cipher) in
let zero_padded_a_BE = be_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_BE = append zero_padded_a_BE (append zero_padded_c_BE (create 1 lengths_BE)) in
let s_BE = ghash_BE h_BE hash_input_BE in
let t = gctr_encrypt j0_BE (be_quad32_to_bytes s_BE) alg key_BE in | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash_BE_s.fst.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GCM_BE_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"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.Seq_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.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
iv: Vale.AES.GCM_BE_s.supported_iv_BE ->
cipher: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
tag: FStar.Seq.Base.seq Vale.Def.Types_s.nat8
-> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * Prims.bool) | Prims.Pure | [] | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Vale.AES.GCM_BE_s.supported_iv_BE",
"FStar.Pervasives.Native.tuple2",
"Prims.bool",
"Prims.l_and",
"Vale.AES.AES_common_s.is_aes_key",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Vale.Def.Words_s.pow2_32",
"Prims.l_True",
"Vale.AES.GCM_BE_s.gcm_decrypt_BE_def"
] | [] | false | false | false | false | false | let gcm_decrypt_BE =
| opaque_make gcm_decrypt_BE_def | false |
|
Vale.AES.GCM_BE_s.fst | Vale.AES.GCM_BE_s.gcm_decrypt_BE_reveal | val gcm_decrypt_BE_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.AES.GCM_BE_s.gcm_decrypt_BE == Vale.AES.GCM_BE_s.gcm_decrypt_BE_def) | let gcm_decrypt_BE_reveal = opaque_revealer (`%gcm_decrypt_BE) gcm_decrypt_BE gcm_decrypt_BE_def | {
"file_name": "vale/specs/crypto/Vale.AES.GCM_BE_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 108,
"end_line": 91,
"start_col": 12,
"start_line": 91
} | module Vale.AES.GCM_BE_s
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.AES.AES_BE_s
open Vale.AES.GCTR_BE_s
open Vale.AES.GHash_BE_s
open FStar.Seq
open FStar.Mul
#reset-options "--z3rlimit 30"
type supported_iv_BE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 }
let compute_iv_BE_def (h_BE:quad32) (iv:supported_iv_BE) : quad32
=
if 8 * (length iv) = 96 then (
let iv_BE = be_bytes_to_quad32 (pad_to_128_bits iv) in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE
) else (
let padded_iv_quads = be_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = two_two_to_four (Mktwo (nat_to_two 32 0) (nat_to_two 32 (8 * length iv))) in
let hash_input_BE = append padded_iv_quads (create 1 length_BE) in
let hash_output_BE = ghash_BE h_BE hash_input_BE in
hash_output_BE
)
[@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def
irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def
let gcm_encrypt_BE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_BE) (plain:seq nat8) (auth:seq nat8) :
Pure (seq nat8 & seq nat8)
(requires
is_aes_key alg key /\
length plain < pow2_32 /\
length auth < pow2_32
)
(ensures fun (c, t) -> True)
=
let key_BE = seq_nat8_to_seq_nat32_BE key in
let h_BE = aes_encrypt_word alg key_BE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_BE iv in
let c = gctr_encrypt (inc32 j0_BE 1) plain alg key_BE in
// Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth
let lengths_BE = two_two_to_four (Mktwo (nat_to_two 32 (8 * length auth)) (nat_to_two 32 (8 * length plain))) in
let zero_padded_c_BE = be_bytes_to_seq_quad32 (pad_to_128_bits c) in
let zero_padded_a_BE = be_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_BE = append zero_padded_a_BE (append zero_padded_c_BE (create 1 lengths_BE)) in
let s_BE = ghash_BE h_BE hash_input_BE in
let t = gctr_encrypt j0_BE (be_quad32_to_bytes s_BE) alg key_BE in
(c, t)
[@"opaque_to_smt"] let gcm_encrypt_BE = opaque_make gcm_encrypt_BE_def
irreducible let gcm_encrypt_BE_reveal = opaque_revealer (`%gcm_encrypt_BE) gcm_encrypt_BE gcm_encrypt_BE_def
let gcm_decrypt_BE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_BE) (cipher:seq nat8) (auth:seq nat8) (tag:seq nat8) :
Pure (seq nat8 & bool)
(requires
is_aes_key alg key /\
length cipher < pow2_32 /\
length auth < pow2_32
)
(ensures fun (p, t) -> True)
=
let key_BE = seq_nat8_to_seq_nat32_BE key in
let h_BE = aes_encrypt_word alg key_BE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_BE iv in
let p = gctr_encrypt (inc32 j0_BE 1) cipher alg key_BE in // TODO: Rename gctr_encrypt to gctr
let lengths_BE = two_two_to_four (Mktwo (nat_to_two 32 (8 * length auth)) (nat_to_two 32 (8 * length cipher))) in
let zero_padded_c_BE = be_bytes_to_seq_quad32 (pad_to_128_bits cipher) in
let zero_padded_a_BE = be_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_BE = append zero_padded_a_BE (append zero_padded_c_BE (create 1 lengths_BE)) in
let s_BE = ghash_BE h_BE hash_input_BE in
let t = gctr_encrypt j0_BE (be_quad32_to_bytes s_BE) alg key_BE in
(p, t = tag) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash_BE_s.fst.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GCM_BE_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"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.Seq_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.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.AES.GCM_BE_s.gcm_decrypt_BE == Vale.AES.GCM_BE_s.gcm_decrypt_BE_def) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Vale.AES.GCM_BE_s.supported_iv_BE",
"FStar.Pervasives.Native.tuple2",
"Prims.bool",
"Prims.l_and",
"Vale.AES.AES_common_s.is_aes_key",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Vale.Def.Words_s.pow2_32",
"Prims.l_True",
"Vale.AES.GCM_BE_s.gcm_decrypt_BE",
"Vale.AES.GCM_BE_s.gcm_decrypt_BE_def"
] | [] | true | false | true | false | false | let gcm_decrypt_BE_reveal =
| opaque_revealer (`%gcm_decrypt_BE) gcm_decrypt_BE gcm_decrypt_BE_def | false |
|
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.load_point_vartime | val load_point_vartime: res:point -> b:lbuffer uint8 64ul -> Stack bool
(requires fun h ->
live h res /\ live h b /\ disjoint res b)
(ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\
(let ps = S.load_point (as_seq h0 b) in
(r <==> Some? ps) /\ (r ==> (point_inv h1 res /\
from_mont_point (as_point_nat h1 res) == Some?.v ps)))) | val load_point_vartime: res:point -> b:lbuffer uint8 64ul -> Stack bool
(requires fun h ->
live h res /\ live h b /\ disjoint res b)
(ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\
(let ps = S.load_point (as_seq h0 b) in
(r <==> Some? ps) /\ (r ==> (point_inv h1 res /\
from_mont_point (as_point_nat h1 res) == Some?.v ps)))) | let load_point_vartime p b =
push_frame ();
let p_aff = create_aff_point () in
let res = aff_point_load_vartime p_aff b in
if res then to_proj_point p p_aff;
pop_frame ();
res | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 249,
"start_col": 0,
"start_line": 243
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz
[@CInline]
let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz
[@CInline]
let is_point_at_inf_vartime p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz
/// Create a copy of a point
let copy_point res p =
copy res p
/// Point conversion between Projective and Affine coordinates representations
[@CInline]
let to_aff_point res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let py = gety p in
let pz = getz p in
let x = aff_getx res in
let y = aff_gety res in
FI.finv zinv pz;
fmul x px zinv;
fmul y py zinv;
from_mont x x;
from_mont y y;
pop_frame ()
[@CInline]
let to_aff_point_x res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let pz = getz p in
FI.finv zinv pz;
fmul res px zinv;
from_mont res res;
pop_frame ()
[@CInline]
let to_proj_point res p =
let px = aff_getx p in
let py = aff_gety p in
let rx = getx res in
let ry = gety res in
let rz = getz res in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
to_mont rx px;
to_mont ry py;
make_fone rz
/// Check if a point is on the curve
inline_for_extraction noextract
val compute_rp_ec_equation: x:felem -> res:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
as_nat h x < S.prime)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_nat h1 res < S.prime /\
(let x = fmont_as_nat h0 x in
fmont_as_nat h1 res ==
S.fadd (S.fadd (S.fmul (S.fmul x x) x) (S.fmul S.a_coeff x)) S.b_coeff))
let compute_rp_ec_equation x res =
push_frame ();
let tmp = create_felem () in
fcube res x;
make_a_coeff tmp;
fmul tmp tmp x;
fadd res tmp res;
make_b_coeff tmp;
fadd res tmp res;
pop_frame ()
inline_for_extraction noextract
val is_y_sqr_is_y2_vartime (y2 y:felem) : Stack bool
(requires fun h ->
live h y /\ live h y2 /\ disjoint y y2 /\
as_nat h y2 < S.prime /\ as_nat h y < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
b == (fmont_as_nat h0 y2 = S.fmul (fmont_as_nat h0 y) (fmont_as_nat h0 y)))
let is_y_sqr_is_y2_vartime y2 y =
fsqr y y; // y = y * y
let r = feq_mask y y2 in
Hacl.Bignum.Base.unsafe_bool_of_limb r
// y *% y =?= x *% x *% x +% a_coeff *% x +% b_coeff
[@CInline]
let is_on_curve_vartime p =
push_frame ();
let rp = create_felem () in
let tx = create_felem () in
let ty = create_felem () in
let px = aff_getx p in
let py = aff_gety p in
let h0 = ST.get () in
to_mont tx px;
to_mont ty py;
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
compute_rp_ec_equation tx rp;
let r = is_y_sqr_is_y2_vartime rp ty in
pop_frame ();
r
/// Point load and store functions
[@CInline]
let aff_point_store res p =
let px = aff_getx p in
let py = aff_gety p in
bn2_to_bytes_be4 res px py
[@CInline]
let point_store res p =
push_frame ();
let aff_p = create_aff_point () in
to_aff_point aff_p p;
aff_point_store res aff_p;
pop_frame ()
inline_for_extraction noextract
val is_xy_valid_vartime: p:aff_point -> Stack bool
(requires fun h -> live h p)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == (aff_point_x_as_nat h0 p < S.prime &&
aff_point_y_as_nat h0 p < S.prime))
let is_xy_valid_vartime p =
let px = aff_getx p in
let py = aff_gety p in
let lessX = bn_is_lt_prime_mask4 px in
let lessY = bn_is_lt_prime_mask4 py in
let res = logand lessX lessY in
logand_lemma lessX lessY;
Hacl.Bignum.Base.unsafe_bool_of_limb res
[@CInline]
let aff_point_load_vartime p b =
let p_x = sub b 0ul 32ul in
let p_y = sub b 32ul 32ul in
let bn_p_x = aff_getx p in
let bn_p_y = aff_gety p in
bn_from_bytes_be4 bn_p_x p_x;
bn_from_bytes_be4 bn_p_y p_y;
let is_xy_valid = is_xy_valid_vartime p in
if not is_xy_valid then false
else is_on_curve_vartime p | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"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.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | res: Hacl.Impl.P256.Point.point -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul
-> FStar.HyperStack.ST.Stack Prims.bool | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Point.point",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Prims.bool",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Hacl.Impl.P256.Point.to_proj_point",
"Hacl.Impl.P256.Point.aff_point_load_vartime",
"Hacl.Impl.P256.Point.aff_point",
"Hacl.Impl.P256.Point.create_aff_point",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let load_point_vartime p b =
| push_frame ();
let p_aff = create_aff_point () in
let res = aff_point_load_vartime p_aff b in
if res then to_proj_point p p_aff;
pop_frame ();
res | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.recover_y_vartime_candidate | val recover_y_vartime_candidate (y x:felem) : Stack bool
(requires fun h ->
live h x /\ live h y /\ disjoint x y /\ as_nat h x < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\ as_nat h1 y < S.prime /\
(let x = as_nat h0 x in
let y2 = S.(x *% x *% x +% a_coeff *% x +% b_coeff) in
as_nat h1 y == S.fsqrt y2 /\ (b <==> (S.fmul (as_nat h1 y) (as_nat h1 y) == y2)))) | val recover_y_vartime_candidate (y x:felem) : Stack bool
(requires fun h ->
live h x /\ live h y /\ disjoint x y /\ as_nat h x < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\ as_nat h1 y < S.prime /\
(let x = as_nat h0 x in
let y2 = S.(x *% x *% x +% a_coeff *% x +% b_coeff) in
as_nat h1 y == S.fsqrt y2 /\ (b <==> (S.fmul (as_nat h1 y) (as_nat h1 y) == y2)))) | let recover_y_vartime_candidate y x =
push_frame ();
let y2M = create_felem () in
let xM = create_felem () in
let yM = create_felem () in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 x);
to_mont xM x;
compute_rp_ec_equation xM y2M; // y2M = x *% x *% x +% S.a_coeff *% x +% S.b_coeff
FI.fsqrt yM y2M; // yM = fsqrt y2M
let h1 = ST.get () in
from_mont y yM;
let is_y_valid = is_y_sqr_is_y2_vartime y2M yM in
pop_frame ();
is_y_valid | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 12,
"end_line": 275,
"start_col": 0,
"start_line": 261
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz
[@CInline]
let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz
[@CInline]
let is_point_at_inf_vartime p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz
/// Create a copy of a point
let copy_point res p =
copy res p
/// Point conversion between Projective and Affine coordinates representations
[@CInline]
let to_aff_point res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let py = gety p in
let pz = getz p in
let x = aff_getx res in
let y = aff_gety res in
FI.finv zinv pz;
fmul x px zinv;
fmul y py zinv;
from_mont x x;
from_mont y y;
pop_frame ()
[@CInline]
let to_aff_point_x res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let pz = getz p in
FI.finv zinv pz;
fmul res px zinv;
from_mont res res;
pop_frame ()
[@CInline]
let to_proj_point res p =
let px = aff_getx p in
let py = aff_gety p in
let rx = getx res in
let ry = gety res in
let rz = getz res in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
to_mont rx px;
to_mont ry py;
make_fone rz
/// Check if a point is on the curve
inline_for_extraction noextract
val compute_rp_ec_equation: x:felem -> res:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
as_nat h x < S.prime)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_nat h1 res < S.prime /\
(let x = fmont_as_nat h0 x in
fmont_as_nat h1 res ==
S.fadd (S.fadd (S.fmul (S.fmul x x) x) (S.fmul S.a_coeff x)) S.b_coeff))
let compute_rp_ec_equation x res =
push_frame ();
let tmp = create_felem () in
fcube res x;
make_a_coeff tmp;
fmul tmp tmp x;
fadd res tmp res;
make_b_coeff tmp;
fadd res tmp res;
pop_frame ()
inline_for_extraction noextract
val is_y_sqr_is_y2_vartime (y2 y:felem) : Stack bool
(requires fun h ->
live h y /\ live h y2 /\ disjoint y y2 /\
as_nat h y2 < S.prime /\ as_nat h y < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
b == (fmont_as_nat h0 y2 = S.fmul (fmont_as_nat h0 y) (fmont_as_nat h0 y)))
let is_y_sqr_is_y2_vartime y2 y =
fsqr y y; // y = y * y
let r = feq_mask y y2 in
Hacl.Bignum.Base.unsafe_bool_of_limb r
// y *% y =?= x *% x *% x +% a_coeff *% x +% b_coeff
[@CInline]
let is_on_curve_vartime p =
push_frame ();
let rp = create_felem () in
let tx = create_felem () in
let ty = create_felem () in
let px = aff_getx p in
let py = aff_gety p in
let h0 = ST.get () in
to_mont tx px;
to_mont ty py;
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
compute_rp_ec_equation tx rp;
let r = is_y_sqr_is_y2_vartime rp ty in
pop_frame ();
r
/// Point load and store functions
[@CInline]
let aff_point_store res p =
let px = aff_getx p in
let py = aff_gety p in
bn2_to_bytes_be4 res px py
[@CInline]
let point_store res p =
push_frame ();
let aff_p = create_aff_point () in
to_aff_point aff_p p;
aff_point_store res aff_p;
pop_frame ()
inline_for_extraction noextract
val is_xy_valid_vartime: p:aff_point -> Stack bool
(requires fun h -> live h p)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == (aff_point_x_as_nat h0 p < S.prime &&
aff_point_y_as_nat h0 p < S.prime))
let is_xy_valid_vartime p =
let px = aff_getx p in
let py = aff_gety p in
let lessX = bn_is_lt_prime_mask4 px in
let lessY = bn_is_lt_prime_mask4 py in
let res = logand lessX lessY in
logand_lemma lessX lessY;
Hacl.Bignum.Base.unsafe_bool_of_limb res
[@CInline]
let aff_point_load_vartime p b =
let p_x = sub b 0ul 32ul in
let p_y = sub b 32ul 32ul in
let bn_p_x = aff_getx p in
let bn_p_y = aff_gety p in
bn_from_bytes_be4 bn_p_x p_x;
bn_from_bytes_be4 bn_p_y p_y;
let is_xy_valid = is_xy_valid_vartime p in
if not is_xy_valid then false
else is_on_curve_vartime p
[@CInline]
let load_point_vartime p b =
push_frame ();
let p_aff = create_aff_point () in
let res = aff_point_load_vartime p_aff b in
if res then to_proj_point p p_aff;
pop_frame ();
res
inline_for_extraction noextract
val recover_y_vartime_candidate (y x:felem) : Stack bool
(requires fun h ->
live h x /\ live h y /\ disjoint x y /\ as_nat h x < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\ as_nat h1 y < S.prime /\
(let x = as_nat h0 x in
let y2 = S.(x *% x *% x +% a_coeff *% x +% b_coeff) in
as_nat h1 y == S.fsqrt y2 /\ (b <==> (S.fmul (as_nat h1 y) (as_nat h1 y) == y2)))) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"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.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | y: Hacl.Impl.P256.Bignum.felem -> x: Hacl.Impl.P256.Bignum.felem
-> FStar.HyperStack.ST.Stack Prims.bool | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Prims.bool",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Hacl.Impl.P256.Point.is_y_sqr_is_y2_vartime",
"Hacl.Impl.P256.Field.from_mont",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.P256.Finv.fsqrt",
"Hacl.Impl.P256.Point.compute_rp_ec_equation",
"Hacl.Impl.P256.Field.to_mont",
"Hacl.Spec.P256.Montgomery.lemma_to_from_mont_id",
"Hacl.Impl.P256.Bignum.as_nat",
"Hacl.Impl.P256.Bignum.create_felem",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let recover_y_vartime_candidate y x =
| push_frame ();
let y2M = create_felem () in
let xM = create_felem () in
let yM = create_felem () in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 x);
to_mont xM x;
compute_rp_ec_equation xM y2M;
FI.fsqrt yM y2M;
let h1 = ST.get () in
from_mont y yM;
let is_y_valid = is_y_sqr_is_y2_vartime y2M yM in
pop_frame ();
is_y_valid | false |
Vale.AES.GCM_BE_s.fst | Vale.AES.GCM_BE_s.compute_iv_BE_def | val compute_iv_BE_def (h_BE: quad32) (iv: supported_iv_BE) : quad32 | val compute_iv_BE_def (h_BE: quad32) (iv: supported_iv_BE) : quad32 | let compute_iv_BE_def (h_BE:quad32) (iv:supported_iv_BE) : quad32
=
if 8 * (length iv) = 96 then (
let iv_BE = be_bytes_to_quad32 (pad_to_128_bits iv) in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE
) else (
let padded_iv_quads = be_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = two_two_to_four (Mktwo (nat_to_two 32 0) (nat_to_two 32 (8 * length iv))) in
let hash_input_BE = append padded_iv_quads (create 1 length_BE) in
let hash_output_BE = ghash_BE h_BE hash_input_BE in
hash_output_BE
) | {
"file_name": "vale/specs/crypto/Vale.AES.GCM_BE_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 32,
"start_col": 0,
"start_line": 20
} | module Vale.AES.GCM_BE_s
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.AES.AES_BE_s
open Vale.AES.GCTR_BE_s
open Vale.AES.GHash_BE_s
open FStar.Seq
open FStar.Mul
#reset-options "--z3rlimit 30"
type supported_iv_BE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 } | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash_BE_s.fst.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GCM_BE_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"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.Seq_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.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h_BE: Vale.Def.Types_s.quad32 -> iv: Vale.AES.GCM_BE_s.supported_iv_BE -> Vale.Def.Types_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Types_s.quad32",
"Vale.AES.GCM_BE_s.supported_iv_BE",
"Prims.op_Equality",
"Prims.int",
"FStar.Mul.op_Star",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.nat8",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Types_s.be_bytes_to_quad32",
"Vale.AES.GCTR_BE_s.pad_to_128_bits",
"Prims.bool",
"Vale.AES.GHash_BE_s.ghash_BE",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.append",
"FStar.Seq.Base.create",
"Vale.Def.Words_s.natN",
"Prims.pow2",
"Vale.Def.Words.Four_s.two_two_to_four",
"Vale.Def.Words_s.Mktwo",
"Vale.Def.Words_s.two",
"Vale.Def.Words.Two_s.nat_to_two",
"Vale.Def.Types_s.be_bytes_to_seq_quad32"
] | [] | false | false | false | true | false | let compute_iv_BE_def (h_BE: quad32) (iv: supported_iv_BE) : quad32 =
| if 8 * (length iv) = 96
then
(let iv_BE = be_bytes_to_quad32 (pad_to_128_bits iv) in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE)
else
(let padded_iv_quads = be_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = two_two_to_four (Mktwo (nat_to_two 32 0) (nat_to_two 32 (8 * length iv))) in
let hash_input_BE = append padded_iv_quads (create 1 length_BE) in
let hash_output_BE = ghash_BE h_BE hash_input_BE in
hash_output_BE) | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.mods_contains | val mods_contains (allowed found: mods_t) : bool | val mods_contains (allowed found: mods_t) : bool | let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 63,
"end_line": 47,
"start_col": 0,
"start_line": 44
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | allowed: Vale.PPC64LE.QuickCode.mods_t -> found: Vale.PPC64LE.QuickCode.mods_t -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.QuickCode.mod_t",
"Prims.list",
"Prims.op_AmpAmp",
"Vale.PPC64LE.QuickCodes.mods_contains1",
"Vale.PPC64LE.QuickCodes.mods_contains",
"Prims.bool"
] | [
"recursion"
] | false | false | false | true | false | let rec mods_contains (allowed found: mods_t) : bool =
| match found with
| [] -> true
| h :: t -> mods_contains1 allowed h && mods_contains allowed t | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.mods_contains1 | val mods_contains1 (allowed: mods_t) (found: mod_t) : bool | val mods_contains1 (allowed: mods_t) (found: mod_t) : bool | let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 41,
"start_col": 0,
"start_line": 38
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | allowed: Vale.PPC64LE.QuickCode.mods_t -> found: Vale.PPC64LE.QuickCode.mod_t -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.mod_eq",
"Vale.PPC64LE.QuickCode.Mod_None",
"Prims.list",
"Prims.op_BarBar",
"Vale.PPC64LE.QuickCodes.mods_contains1",
"Prims.bool"
] | [
"recursion"
] | false | false | false | true | false | let rec mods_contains1 (allowed: mods_t) (found: mod_t) : bool =
| match allowed with
| [] -> mod_eq Mod_None found
| h :: t -> mod_eq h found || mods_contains1 t found | false |
FStar.Seq.Permutation.fsti | FStar.Seq.Permutation.init_func_from_expr | val init_func_from_expr
(#c: _)
(#n0: int)
(#nk: not_less_than n0)
(expr: (ifrom_ito n0 nk -> c))
(a: ifrom_ito n0 nk)
(b: ifrom_ito a nk)
(i: under (closed_interval_size a b))
: c | val init_func_from_expr
(#c: _)
(#n0: int)
(#nk: not_less_than n0)
(expr: (ifrom_ito n0 nk -> c))
(a: ifrom_ito n0 nk)
(b: ifrom_ito a nk)
(i: under (closed_interval_size a b))
: c | let init_func_from_expr #c (#n0: int) (#nk: not_less_than n0)
(expr: ifrom_ito n0 nk -> c)
(a: ifrom_ito n0 nk)
(b: ifrom_ito a nk)
(i: under (closed_interval_size a b))
: c
= expr (n0+i) | {
"file_name": "ulib/FStar.Seq.Permutation.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 15,
"end_line": 119,
"start_col": 0,
"start_line": 113
} | (*
Copyright 2021-2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Authors: N. Swamy, A. Rastogi, A. Rozanov
*)
module FStar.Seq.Permutation
open FStar.Seq
open FStar.IntegerIntervals
(* This module defines a permutation on sequences as a bijection among
the sequence indices relating equal elements.
It defines a few utilities to work with such permutations.
Notably:
1. Given two sequence with equal element counts, it constructs a
permutation.
2. Folding the multiplication of a commutative monoid over a
sequence and its permutation produces the equivalent results
*)
(* A function from the indices of `s` to itself *)
let index_fun #a (s:seq a) = under (Seq.length s) -> under (Seq.length s)
(* An abstract predicate defining when an index_fun is a permutation *)
val is_permutation (#a:Type) (s0:seq a) (s1:seq a) (f:index_fun s0) : prop
(* Revealing the interpretation of is_permutation *)
val reveal_is_permutation (#a:Type) (s0 s1:seq a) (f:index_fun s0)
: Lemma (is_permutation s0 s1 f <==>
(* lengths of the sequences are the same *)
Seq.length s0 == Seq.length s1 /\
(* f is injective *)
(forall x y. {:pattern f x; f y}
x <> y ==> f x <> f y) /\
(* and f relates equal items in s0 and s1 *)
(forall (i:nat{i < Seq.length s0}).{:pattern (Seq.index s1 (f i))}
Seq.index s0 i == Seq.index s1 (f i)))
(* A seqperm is an index_fun that is also a permutation *)
let seqperm (#a:Type) (s0:seq a) (s1:seq a) =
f:index_fun s0 { is_permutation s0 s1 f }
(* We can construct a permutation from
sequences whose element counts are the same *)
val permutation_from_equal_counts
(#a:eqtype)
(s0:seq a) (s1:seq a{(forall x. count x s0 == count x s1)})
: Tot (seqperm s0 s1)
(** Now, some utilities related to commutative monoids and permutations *)
module CE = FStar.Algebra.CommMonoid.Equiv
(* folding a m.mult over a sequence *)
let foldm_snoc (#a:Type) (#eq:CE.equiv a) (m:CE.cm a eq) (s:seq a) =
foldr_snoc m.mult s m.unit
(* folding over a sequence of units is unit *)
val foldm_snoc_unit_seq (#a:Type) (#eq:CE.equiv a) (m:CE.cm a eq) (s:Seq.seq a)
: Lemma (requires Seq.equal s (Seq.create (Seq.length s) m.unit))
(ensures eq.eq (foldm_snoc m s) m.unit)
(* folding over a singleton sequence is the sequence element *)
val foldm_snoc_singleton (#a:_) (#eq:_) (m:CE.cm a eq) (x:a)
: Lemma (eq.eq (foldm_snoc m (Seq.create 1 x)) x)
(* folding m over the concatenation of s1 and s2
can be decomposed into a fold over s1 and a fold over s2 *)
val foldm_snoc_append (#a:Type) (#eq:CE.equiv a) (m:CE.cm a eq) (s1 s2: seq a)
: Lemma
(ensures eq.eq (foldm_snoc m (append s1 s2))
(m.mult (foldm_snoc m s1) (foldm_snoc m s2)))
(* folds over concatenated lists can is symmetric *)
val foldm_snoc_sym (#a:Type) (#eq:CE.equiv a) (m:CE.cm a eq) (s1 s2: seq a)
: Lemma
(ensures eq.eq (foldm_snoc m (append s1 s2))
(foldm_snoc m (append s2 s1)))
(* And, finally, if s0 and s1 are permutations,
then folding m over them is identical *)
val foldm_snoc_perm (#a:_) (#eq:_)
(m:CE.cm a eq)
(s0:seq a)
(s1:seq a)
(p:seqperm s0 s1)
: Lemma
(ensures eq.eq (foldm_snoc m s0) (foldm_snoc m s1))
/// foldm_snoc_split: This next bit is for a lemma that proves that if
/// if the fold is taken over a sequence of sums, it is equal
/// to a sum of folds of the summand sequences
(* This constructs a sequence init function to be used to create | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.Equiv.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IntegerIntervals.fst.checked",
"FStar.Algebra.CommMonoid.Equiv.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Seq.Permutation.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.IntegerIntervals",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": 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 |
expr: (_: FStar.IntegerIntervals.ifrom_ito n0 nk -> c) ->
a: FStar.IntegerIntervals.ifrom_ito n0 nk ->
b: FStar.IntegerIntervals.ifrom_ito a nk ->
i: FStar.IntegerIntervals.under (FStar.IntegerIntervals.closed_interval_size a b)
-> c | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"FStar.IntegerIntervals.not_less_than",
"FStar.IntegerIntervals.ifrom_ito",
"FStar.IntegerIntervals.under",
"FStar.IntegerIntervals.closed_interval_size",
"Prims.op_Addition"
] | [] | false | false | false | false | false | let init_func_from_expr
#c
(#n0: int)
(#nk: not_less_than n0)
(expr: (ifrom_ito n0 nk -> c))
(a: ifrom_ito n0 nk)
(b: ifrom_ito a nk)
(i: under (closed_interval_size a b))
: c =
| expr (n0 + i) | false |
Pulse.Typing.Combinators.fst | Pulse.Typing.Combinators.inames_of | val inames_of (c: comp_st) : term | val inames_of (c: comp_st) : term | let inames_of (c:comp_st) : term =
match c with
| C_ST _
| C_STGhost _ -> tm_emp_inames
| C_STAtomic inames _ _ -> inames | {
"file_name": "lib/steel/pulse/Pulse.Typing.Combinators.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 35,
"end_line": 183,
"start_col": 0,
"start_line": 179
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Typing.Combinators
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
assume
val invert_forall_typing
(#g #u #b #body:_)
(d:tot_typing g (tm_forall_sl u b body) tm_vprop)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
: GTot (
tot_typing g b.binder_ty (tm_type u) &
tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop
)
assume
val construct_forall_typing
(#g #u #b #body:_)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
(dt:tot_typing g b.binder_ty (tm_type u))
(db:tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop)
: GTot (tot_typing g (tm_forall_sl u b body) tm_vprop)
let rec vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1)
: GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop))
(decreases v)
= match v with
| VE_Refl _ _ -> (fun x -> x), (fun x -> x)
| VE_Sym _ _ _ v' ->
let f, g = vprop_equiv_typing v' in
g, f
| VE_Trans g t0 t2 t1 v02 v21 ->
let f02, f20 = vprop_equiv_typing v02 in
let f21, f12 = vprop_equiv_typing v21 in
(fun x -> f21 (f02 x)),
(fun x -> f20 (f12 x))
| VE_Ctxt g s0 s1 s0' s1' v0 v1 ->
let f0, f0' = vprop_equiv_typing v0 in
let f1, f1' = vprop_equiv_typing v1 in
let ff (x:tot_typing g (tm_star s0 s1) tm_vprop)
: tot_typing g (tm_star s0' s1') tm_vprop
= let s0_typing = star_typing_inversion_l x in
let s1_typing = star_typing_inversion_r x in
let s0'_typing, s1'_typing = f0 s0_typing, f1 s1_typing in
star_typing s0'_typing s1'_typing
in
let gg (x:tot_typing g (tm_star s0' s1') tm_vprop)
: tot_typing g (tm_star s0 s1) tm_vprop
= let s0'_typing = star_typing_inversion_l x in
let s1'_typing = star_typing_inversion_r x in
star_typing (f0' s0'_typing) (f1' s1'_typing)
in
ff, gg
| VE_Unit g t ->
let fwd (x:tot_typing g (tm_star tm_emp t) tm_vprop)
: tot_typing g t tm_vprop
= let r = star_typing_inversion_r x in
r
in
let bk (x:tot_typing g t tm_vprop)
: tot_typing g (tm_star tm_emp t) tm_vprop
= star_typing emp_typing x
in
fwd, bk
| VE_Comm g t0 t1 ->
let f t0 t1 (x:tot_typing g (tm_star t0 t1) tm_vprop)
: tot_typing g (tm_star t1 t0) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt1 = star_typing_inversion_r x in
star_typing tt1 tt0
in
f t0 t1, f t1 t0
| VE_Assoc g t0 t1 t2 ->
let fwd (x:tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop)
: tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt12 = star_typing_inversion_r x in
let tt1 = star_typing_inversion_l tt12 in
let tt2 = star_typing_inversion_r tt12 in
star_typing (star_typing tt0 tt1) tt2
in
let bk (x : tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop)
: tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop
= let tt01 = star_typing_inversion_l x in
let tt2 = star_typing_inversion_r x in
let tt0 = star_typing_inversion_l tt01 in
let tt1 = star_typing_inversion_r tt01 in
star_typing tt0 (star_typing tt1 tt2)
in
fwd, bk
| VE_Ext g t0 t1 token ->
let d1, d2 = vprop_eq_typing_inversion g t0 t1 token in
(fun _ -> d2),
(fun _ -> d1)
| VE_Fa g x u b t0 t1 d ->
let d0, d1 = vprop_equiv_typing d in
(fun fa0_typing ->
let b_typing, t0_typing = invert_forall_typing fa0_typing x in
let t1_typing = d0 t0_typing in
construct_forall_typing #g #u x b_typing t1_typing),
(fun fa1_typing ->
let b_typing, t1_typing = invert_forall_typing fa1_typing x in
let t0_typing = d1 t1_typing in
construct_forall_typing #g #u #b #t0 x b_typing t0_typing)
#push-options "--z3rlimit_factor 8 --ifuel 1 --fuel 2 --query_stats"
let bind_t (case_c1 case_c2:comp_st -> bool) =
(g:env) ->
(pre:term) ->
(e1:st_term) ->
(e2:st_term) ->
(c1:comp_st{ case_c1 c1 }) ->
(c2:comp_st{ case_c2 c2 }) ->
(px:nvar { ~ (Set.mem (snd px) (dom g)) }) ->
(d_e1:st_typing g e1 c1) ->
(d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1))) ->
(d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2) ->
(res_typing:universe_of g (comp_res c2) (comp_u c2)) ->
(post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop) ->
(bias_towards_continuation:bool) ->
T.TacH (t:st_term &
c:comp_st { st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires fun _ ->
let _, x = px in
comp_pre c1 == pre /\
None? (lookup g x) /\
(~(x `Set.mem` freevars_st e2)) /\
open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))))
(ensures fun _ _ -> True)
let mk_bind_st_st
: bind_t C_ST? C_ST?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.PP.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Result.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Typing.Combinators.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: Pulse.Syntax.Base.comp_st -> Pulse.Syntax.Base.term | Prims.Tot | [
"total"
] | [] | [
"Pulse.Syntax.Base.comp_st",
"Pulse.Syntax.Base.st_comp",
"Pulse.Syntax.Base.tm_emp_inames",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.observability"
] | [] | false | false | false | true | false | let inames_of (c: comp_st) : term =
| match c with
| C_ST _ | C_STGhost _ -> tm_emp_inames
| C_STAtomic inames _ _ -> inames | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.qblock | val qblock (#a: Type) (#cs: codes) (mods: mods_t) (qcs: (va_state -> GTot (quickCodes a cs)))
: quickCode a (block cs) | val qblock (#a: Type) (#cs: codes) (mods: mods_t) (qcs: (va_state -> GTot (quickCodes a cs)))
: quickCode a (block cs) | let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods) | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 67,
"end_line": 185,
"start_col": 0,
"start_line": 184
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mods: Vale.PPC64LE.QuickCode.mods_t ->
qcs: (_: Vale.PPC64LE.Decls.va_state -> Prims.GTot (Vale.PPC64LE.QuickCodes.quickCodes a cs))
-> Vale.PPC64LE.QuickCode.quickCode a (Vale.PPC64LE.QuickCodes.block cs) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.codes",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.QuickCode.QProc",
"Vale.PPC64LE.QuickCodes.block",
"Vale.PPC64LE.QuickCodes.wp_block",
"Vale.PPC64LE.QuickCodes.qblock_proof",
"Vale.PPC64LE.QuickCode.quickCode"
] | [] | false | false | false | false | false | let qblock (#a: Type) (#cs: codes) (mods: mods_t) (qcs: (va_state -> GTot (quickCodes a cs)))
: quickCode a (block cs) =
| QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods) | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.va_qPURE | val va_qPURE
(#cs: codes)
(#pre: ((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(#a: Type0)
(r: range)
(msg: string)
($l:
(unit
-> PURE unit
(intro_pure_wp_monotonicity pre;
pre)))
(qcs: quickCodes a cs)
: quickCodes a cs | val va_qPURE
(#cs: codes)
(#pre: ((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(#a: Type0)
(r: range)
(msg: string)
($l:
(unit
-> PURE unit
(intro_pure_wp_monotonicity pre;
pre)))
(qcs: quickCodes a cs)
: quickCodes a cs | let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 82,
"start_col": 0,
"start_line": 78
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
r: FStar.Range.range ->
msg: Prims.string ->
$l: (_: Prims.unit -> Prims.PURE Prims.unit) ->
qcs: Vale.PPC64LE.QuickCodes.quickCodes a cs
-> Vale.PPC64LE.QuickCodes.quickCodes a cs | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.codes",
"Prims.unit",
"FStar.Monotonic.Pure.is_monotonic",
"FStar.Range.range",
"Prims.string",
"FStar.Monotonic.Pure.intro_pure_wp_monotonicity",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.QuickCodes.QPURE"
] | [] | false | false | false | false | false | let va_qPURE
(#cs: codes)
(#pre: ((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(#a: Type0)
(r: range)
(msg: string)
($l:
(unit
-> PURE unit
(intro_pure_wp_monotonicity pre;
pre)))
(qcs: quickCodes a cs)
: quickCodes a cs =
| QPURE r msg pre l qcs | false |
Pulse.Typing.Combinators.fst | Pulse.Typing.Combinators.st_ghost_as_atomic | val st_ghost_as_atomic : c: Pulse.Syntax.Base.comp_st{C_STGhost? c} -> Pulse.Syntax.Base.comp | let st_ghost_as_atomic (c:comp_st { C_STGhost? c }) =
C_STAtomic tm_emp_inames Neutral (st_comp_of_comp c) | {
"file_name": "lib/steel/pulse/Pulse.Typing.Combinators.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 54,
"end_line": 203,
"start_col": 0,
"start_line": 202
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Typing.Combinators
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
assume
val invert_forall_typing
(#g #u #b #body:_)
(d:tot_typing g (tm_forall_sl u b body) tm_vprop)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
: GTot (
tot_typing g b.binder_ty (tm_type u) &
tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop
)
assume
val construct_forall_typing
(#g #u #b #body:_)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
(dt:tot_typing g b.binder_ty (tm_type u))
(db:tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop)
: GTot (tot_typing g (tm_forall_sl u b body) tm_vprop)
let rec vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1)
: GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop))
(decreases v)
= match v with
| VE_Refl _ _ -> (fun x -> x), (fun x -> x)
| VE_Sym _ _ _ v' ->
let f, g = vprop_equiv_typing v' in
g, f
| VE_Trans g t0 t2 t1 v02 v21 ->
let f02, f20 = vprop_equiv_typing v02 in
let f21, f12 = vprop_equiv_typing v21 in
(fun x -> f21 (f02 x)),
(fun x -> f20 (f12 x))
| VE_Ctxt g s0 s1 s0' s1' v0 v1 ->
let f0, f0' = vprop_equiv_typing v0 in
let f1, f1' = vprop_equiv_typing v1 in
let ff (x:tot_typing g (tm_star s0 s1) tm_vprop)
: tot_typing g (tm_star s0' s1') tm_vprop
= let s0_typing = star_typing_inversion_l x in
let s1_typing = star_typing_inversion_r x in
let s0'_typing, s1'_typing = f0 s0_typing, f1 s1_typing in
star_typing s0'_typing s1'_typing
in
let gg (x:tot_typing g (tm_star s0' s1') tm_vprop)
: tot_typing g (tm_star s0 s1) tm_vprop
= let s0'_typing = star_typing_inversion_l x in
let s1'_typing = star_typing_inversion_r x in
star_typing (f0' s0'_typing) (f1' s1'_typing)
in
ff, gg
| VE_Unit g t ->
let fwd (x:tot_typing g (tm_star tm_emp t) tm_vprop)
: tot_typing g t tm_vprop
= let r = star_typing_inversion_r x in
r
in
let bk (x:tot_typing g t tm_vprop)
: tot_typing g (tm_star tm_emp t) tm_vprop
= star_typing emp_typing x
in
fwd, bk
| VE_Comm g t0 t1 ->
let f t0 t1 (x:tot_typing g (tm_star t0 t1) tm_vprop)
: tot_typing g (tm_star t1 t0) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt1 = star_typing_inversion_r x in
star_typing tt1 tt0
in
f t0 t1, f t1 t0
| VE_Assoc g t0 t1 t2 ->
let fwd (x:tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop)
: tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt12 = star_typing_inversion_r x in
let tt1 = star_typing_inversion_l tt12 in
let tt2 = star_typing_inversion_r tt12 in
star_typing (star_typing tt0 tt1) tt2
in
let bk (x : tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop)
: tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop
= let tt01 = star_typing_inversion_l x in
let tt2 = star_typing_inversion_r x in
let tt0 = star_typing_inversion_l tt01 in
let tt1 = star_typing_inversion_r tt01 in
star_typing tt0 (star_typing tt1 tt2)
in
fwd, bk
| VE_Ext g t0 t1 token ->
let d1, d2 = vprop_eq_typing_inversion g t0 t1 token in
(fun _ -> d2),
(fun _ -> d1)
| VE_Fa g x u b t0 t1 d ->
let d0, d1 = vprop_equiv_typing d in
(fun fa0_typing ->
let b_typing, t0_typing = invert_forall_typing fa0_typing x in
let t1_typing = d0 t0_typing in
construct_forall_typing #g #u x b_typing t1_typing),
(fun fa1_typing ->
let b_typing, t1_typing = invert_forall_typing fa1_typing x in
let t0_typing = d1 t1_typing in
construct_forall_typing #g #u #b #t0 x b_typing t0_typing)
#push-options "--z3rlimit_factor 8 --ifuel 1 --fuel 2 --query_stats"
let bind_t (case_c1 case_c2:comp_st -> bool) =
(g:env) ->
(pre:term) ->
(e1:st_term) ->
(e2:st_term) ->
(c1:comp_st{ case_c1 c1 }) ->
(c2:comp_st{ case_c2 c2 }) ->
(px:nvar { ~ (Set.mem (snd px) (dom g)) }) ->
(d_e1:st_typing g e1 c1) ->
(d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1))) ->
(d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2) ->
(res_typing:universe_of g (comp_res c2) (comp_u c2)) ->
(post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop) ->
(bias_towards_continuation:bool) ->
T.TacH (t:st_term &
c:comp_st { st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires fun _ ->
let _, x = px in
comp_pre c1 == pre /\
None? (lookup g x) /\
(~(x `Set.mem` freevars_st e2)) /\
open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))))
(ensures fun _ _ -> True)
let mk_bind_st_st
: bind_t C_ST? C_ST?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
let inames_of (c:comp_st) : term =
match c with
| C_ST _
| C_STGhost _ -> tm_emp_inames
| C_STAtomic inames _ _ -> inames
let with_inames (c:comp_st) (i:term) =
match c with
| C_ST _ -> c
| C_STGhost sc -> C_STGhost sc
| C_STAtomic _ obs sc -> C_STAtomic i obs sc
let weaken_comp_inames (#g:env) (#e:st_term) (#c:comp_st) (d_e:st_typing g e c) (new_inames:term)
: T.Tac (c':comp_st { with_inames c new_inames == c' } &
st_typing g e c')
= match c with
| C_ST _
| C_STGhost _ -> (| c, d_e |)
| C_STAtomic inames obs sc ->
let d_e = T_Sub _ _ _ _ d_e (STS_AtomicInvs _ sc inames new_inames obs obs (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
(| with_inames c new_inames, d_e |) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.PP.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Result.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Typing.Combinators.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: Pulse.Syntax.Base.comp_st{C_STGhost? c} -> Pulse.Syntax.Base.comp | Prims.Tot | [
"total"
] | [] | [
"Pulse.Syntax.Base.comp_st",
"Prims.b2t",
"Pulse.Syntax.Base.uu___is_C_STGhost",
"Pulse.Syntax.Base.C_STAtomic",
"Pulse.Syntax.Base.tm_emp_inames",
"Pulse.Syntax.Base.Neutral",
"Pulse.Syntax.Base.st_comp_of_comp",
"Pulse.Syntax.Base.comp"
] | [] | false | false | false | false | false | let st_ghost_as_atomic (c: comp_st{C_STGhost? c}) =
| C_STAtomic tm_emp_inames Neutral (st_comp_of_comp c) | false |
|
Pulse.Typing.Combinators.fst | Pulse.Typing.Combinators.with_inames | val with_inames : c: Pulse.Syntax.Base.comp_st -> i: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.comp | let with_inames (c:comp_st) (i:term) =
match c with
| C_ST _ -> c
| C_STGhost sc -> C_STGhost sc
| C_STAtomic _ obs sc -> C_STAtomic i obs sc | {
"file_name": "lib/steel/pulse/Pulse.Typing.Combinators.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 46,
"end_line": 189,
"start_col": 0,
"start_line": 185
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Typing.Combinators
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
assume
val invert_forall_typing
(#g #u #b #body:_)
(d:tot_typing g (tm_forall_sl u b body) tm_vprop)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
: GTot (
tot_typing g b.binder_ty (tm_type u) &
tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop
)
assume
val construct_forall_typing
(#g #u #b #body:_)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
(dt:tot_typing g b.binder_ty (tm_type u))
(db:tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop)
: GTot (tot_typing g (tm_forall_sl u b body) tm_vprop)
let rec vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1)
: GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop))
(decreases v)
= match v with
| VE_Refl _ _ -> (fun x -> x), (fun x -> x)
| VE_Sym _ _ _ v' ->
let f, g = vprop_equiv_typing v' in
g, f
| VE_Trans g t0 t2 t1 v02 v21 ->
let f02, f20 = vprop_equiv_typing v02 in
let f21, f12 = vprop_equiv_typing v21 in
(fun x -> f21 (f02 x)),
(fun x -> f20 (f12 x))
| VE_Ctxt g s0 s1 s0' s1' v0 v1 ->
let f0, f0' = vprop_equiv_typing v0 in
let f1, f1' = vprop_equiv_typing v1 in
let ff (x:tot_typing g (tm_star s0 s1) tm_vprop)
: tot_typing g (tm_star s0' s1') tm_vprop
= let s0_typing = star_typing_inversion_l x in
let s1_typing = star_typing_inversion_r x in
let s0'_typing, s1'_typing = f0 s0_typing, f1 s1_typing in
star_typing s0'_typing s1'_typing
in
let gg (x:tot_typing g (tm_star s0' s1') tm_vprop)
: tot_typing g (tm_star s0 s1) tm_vprop
= let s0'_typing = star_typing_inversion_l x in
let s1'_typing = star_typing_inversion_r x in
star_typing (f0' s0'_typing) (f1' s1'_typing)
in
ff, gg
| VE_Unit g t ->
let fwd (x:tot_typing g (tm_star tm_emp t) tm_vprop)
: tot_typing g t tm_vprop
= let r = star_typing_inversion_r x in
r
in
let bk (x:tot_typing g t tm_vprop)
: tot_typing g (tm_star tm_emp t) tm_vprop
= star_typing emp_typing x
in
fwd, bk
| VE_Comm g t0 t1 ->
let f t0 t1 (x:tot_typing g (tm_star t0 t1) tm_vprop)
: tot_typing g (tm_star t1 t0) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt1 = star_typing_inversion_r x in
star_typing tt1 tt0
in
f t0 t1, f t1 t0
| VE_Assoc g t0 t1 t2 ->
let fwd (x:tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop)
: tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt12 = star_typing_inversion_r x in
let tt1 = star_typing_inversion_l tt12 in
let tt2 = star_typing_inversion_r tt12 in
star_typing (star_typing tt0 tt1) tt2
in
let bk (x : tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop)
: tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop
= let tt01 = star_typing_inversion_l x in
let tt2 = star_typing_inversion_r x in
let tt0 = star_typing_inversion_l tt01 in
let tt1 = star_typing_inversion_r tt01 in
star_typing tt0 (star_typing tt1 tt2)
in
fwd, bk
| VE_Ext g t0 t1 token ->
let d1, d2 = vprop_eq_typing_inversion g t0 t1 token in
(fun _ -> d2),
(fun _ -> d1)
| VE_Fa g x u b t0 t1 d ->
let d0, d1 = vprop_equiv_typing d in
(fun fa0_typing ->
let b_typing, t0_typing = invert_forall_typing fa0_typing x in
let t1_typing = d0 t0_typing in
construct_forall_typing #g #u x b_typing t1_typing),
(fun fa1_typing ->
let b_typing, t1_typing = invert_forall_typing fa1_typing x in
let t0_typing = d1 t1_typing in
construct_forall_typing #g #u #b #t0 x b_typing t0_typing)
#push-options "--z3rlimit_factor 8 --ifuel 1 --fuel 2 --query_stats"
let bind_t (case_c1 case_c2:comp_st -> bool) =
(g:env) ->
(pre:term) ->
(e1:st_term) ->
(e2:st_term) ->
(c1:comp_st{ case_c1 c1 }) ->
(c2:comp_st{ case_c2 c2 }) ->
(px:nvar { ~ (Set.mem (snd px) (dom g)) }) ->
(d_e1:st_typing g e1 c1) ->
(d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1))) ->
(d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2) ->
(res_typing:universe_of g (comp_res c2) (comp_u c2)) ->
(post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop) ->
(bias_towards_continuation:bool) ->
T.TacH (t:st_term &
c:comp_st { st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires fun _ ->
let _, x = px in
comp_pre c1 == pre /\
None? (lookup g x) /\
(~(x `Set.mem` freevars_st e2)) /\
open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))))
(ensures fun _ _ -> True)
let mk_bind_st_st
: bind_t C_ST? C_ST?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
let inames_of (c:comp_st) : term =
match c with
| C_ST _
| C_STGhost _ -> tm_emp_inames
| C_STAtomic inames _ _ -> inames | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.PP.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Result.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Typing.Combinators.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: Pulse.Syntax.Base.comp_st -> i: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.comp | Prims.Tot | [
"total"
] | [] | [
"Pulse.Syntax.Base.comp_st",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.st_comp",
"Pulse.Syntax.Base.C_STGhost",
"Pulse.Syntax.Base.observability",
"Pulse.Syntax.Base.C_STAtomic",
"Pulse.Syntax.Base.comp"
] | [] | false | false | false | true | false | let with_inames (c: comp_st) (i: term) =
| match c with
| C_ST _ -> c
| C_STGhost sc -> C_STGhost sc
| C_STAtomic _ obs sc -> C_STAtomic i obs sc | false |
|
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.va_qInlineIf | val va_qInlineIf
(#a: Type)
(#c1 #c2: code)
(mods: mods_t)
(b: bool)
(qc1: quickCode a c1)
(qc2: quickCode a c2)
: quickCode a (if_code b c1 c2) | val va_qInlineIf
(#a: Type)
(#c1 #c2: code)
(mods: mods_t)
(b: bool)
(qc1: quickCode a c1)
(qc2: quickCode a c2)
: quickCode a (if_code b c1 c2) | let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods) | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 92,
"end_line": 204,
"start_col": 0,
"start_line": 203
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mods: Vale.PPC64LE.QuickCode.mods_t ->
b: Prims.bool ->
qc1: Vale.PPC64LE.QuickCode.quickCode a c1 ->
qc2: Vale.PPC64LE.QuickCode.quickCode a c2
-> Vale.PPC64LE.QuickCode.quickCode a (Vale.PPC64LE.QuickCodes.if_code b c1 c2) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCode.mods_t",
"Prims.bool",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.QuickCode.QProc",
"Vale.PPC64LE.QuickCodes.if_code",
"Vale.PPC64LE.QuickCodes.wp_InlineIf",
"Vale.PPC64LE.QuickCodes.qInlineIf_proof"
] | [] | false | false | false | false | false | let va_qInlineIf
(#a: Type)
(#c1 #c2: code)
(mods: mods_t)
(b: bool)
(qc1: quickCode a c1)
(qc2: quickCode a c2)
: quickCode a (if_code b c1 c2) =
| QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods) | false |
Pulse.Typing.Combinators.fst | Pulse.Typing.Combinators.bind_t | val bind_t : case_c1: (_: Pulse.Syntax.Base.comp_st -> Prims.bool) ->
case_c2: (_: Pulse.Syntax.Base.comp_st -> Prims.bool)
-> Type0 | let bind_t (case_c1 case_c2:comp_st -> bool) =
(g:env) ->
(pre:term) ->
(e1:st_term) ->
(e2:st_term) ->
(c1:comp_st{ case_c1 c1 }) ->
(c2:comp_st{ case_c2 c2 }) ->
(px:nvar { ~ (Set.mem (snd px) (dom g)) }) ->
(d_e1:st_typing g e1 c1) ->
(d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1))) ->
(d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2) ->
(res_typing:universe_of g (comp_res c2) (comp_u c2)) ->
(post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop) ->
(bias_towards_continuation:bool) ->
T.TacH (t:st_term &
c:comp_st { st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires fun _ ->
let _, x = px in
comp_pre c1 == pre /\
None? (lookup g x) /\
(~(x `Set.mem` freevars_st e2)) /\
open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))))
(ensures fun _ _ -> True) | {
"file_name": "lib/steel/pulse/Pulse.Typing.Combinators.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 36,
"end_line": 169,
"start_col": 0,
"start_line": 142
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Typing.Combinators
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
assume
val invert_forall_typing
(#g #u #b #body:_)
(d:tot_typing g (tm_forall_sl u b body) tm_vprop)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
: GTot (
tot_typing g b.binder_ty (tm_type u) &
tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop
)
assume
val construct_forall_typing
(#g #u #b #body:_)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
(dt:tot_typing g b.binder_ty (tm_type u))
(db:tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop)
: GTot (tot_typing g (tm_forall_sl u b body) tm_vprop)
let rec vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1)
: GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop))
(decreases v)
= match v with
| VE_Refl _ _ -> (fun x -> x), (fun x -> x)
| VE_Sym _ _ _ v' ->
let f, g = vprop_equiv_typing v' in
g, f
| VE_Trans g t0 t2 t1 v02 v21 ->
let f02, f20 = vprop_equiv_typing v02 in
let f21, f12 = vprop_equiv_typing v21 in
(fun x -> f21 (f02 x)),
(fun x -> f20 (f12 x))
| VE_Ctxt g s0 s1 s0' s1' v0 v1 ->
let f0, f0' = vprop_equiv_typing v0 in
let f1, f1' = vprop_equiv_typing v1 in
let ff (x:tot_typing g (tm_star s0 s1) tm_vprop)
: tot_typing g (tm_star s0' s1') tm_vprop
= let s0_typing = star_typing_inversion_l x in
let s1_typing = star_typing_inversion_r x in
let s0'_typing, s1'_typing = f0 s0_typing, f1 s1_typing in
star_typing s0'_typing s1'_typing
in
let gg (x:tot_typing g (tm_star s0' s1') tm_vprop)
: tot_typing g (tm_star s0 s1) tm_vprop
= let s0'_typing = star_typing_inversion_l x in
let s1'_typing = star_typing_inversion_r x in
star_typing (f0' s0'_typing) (f1' s1'_typing)
in
ff, gg
| VE_Unit g t ->
let fwd (x:tot_typing g (tm_star tm_emp t) tm_vprop)
: tot_typing g t tm_vprop
= let r = star_typing_inversion_r x in
r
in
let bk (x:tot_typing g t tm_vprop)
: tot_typing g (tm_star tm_emp t) tm_vprop
= star_typing emp_typing x
in
fwd, bk
| VE_Comm g t0 t1 ->
let f t0 t1 (x:tot_typing g (tm_star t0 t1) tm_vprop)
: tot_typing g (tm_star t1 t0) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt1 = star_typing_inversion_r x in
star_typing tt1 tt0
in
f t0 t1, f t1 t0
| VE_Assoc g t0 t1 t2 ->
let fwd (x:tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop)
: tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt12 = star_typing_inversion_r x in
let tt1 = star_typing_inversion_l tt12 in
let tt2 = star_typing_inversion_r tt12 in
star_typing (star_typing tt0 tt1) tt2
in
let bk (x : tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop)
: tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop
= let tt01 = star_typing_inversion_l x in
let tt2 = star_typing_inversion_r x in
let tt0 = star_typing_inversion_l tt01 in
let tt1 = star_typing_inversion_r tt01 in
star_typing tt0 (star_typing tt1 tt2)
in
fwd, bk
| VE_Ext g t0 t1 token ->
let d1, d2 = vprop_eq_typing_inversion g t0 t1 token in
(fun _ -> d2),
(fun _ -> d1)
| VE_Fa g x u b t0 t1 d ->
let d0, d1 = vprop_equiv_typing d in
(fun fa0_typing ->
let b_typing, t0_typing = invert_forall_typing fa0_typing x in
let t1_typing = d0 t0_typing in
construct_forall_typing #g #u x b_typing t1_typing),
(fun fa1_typing ->
let b_typing, t1_typing = invert_forall_typing fa1_typing x in
let t0_typing = d1 t1_typing in
construct_forall_typing #g #u #b #t0 x b_typing t0_typing)
#push-options "--z3rlimit_factor 8 --ifuel 1 --fuel 2 --query_stats" | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.PP.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Result.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Typing.Combinators.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
case_c1: (_: Pulse.Syntax.Base.comp_st -> Prims.bool) ->
case_c2: (_: Pulse.Syntax.Base.comp_st -> Prims.bool)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Pulse.Syntax.Base.comp_st",
"Prims.bool",
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.st_term",
"Prims.b2t",
"Pulse.Syntax.Base.nvar",
"Prims.l_not",
"FStar.Set.mem",
"Pulse.Syntax.Base.var",
"FStar.Pervasives.Native.snd",
"Pulse.Syntax.Base.ppname",
"Pulse.Typing.Env.dom",
"Pulse.Typing.st_typing",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.comp_res",
"Pulse.Syntax.Pure.tm_type",
"Pulse.Syntax.Base.comp_u",
"Pulse.Typing.Env.push_binding",
"FStar.Pervasives.Native.fst",
"Pulse.Syntax.Naming.open_st_term_nv",
"Pulse.Typing.universe_of",
"Pulse.Syntax.Naming.open_term_nv",
"Pulse.Syntax.Base.comp_post",
"Pulse.Syntax.Base.tm_vprop",
"FStar.Pervasives.dtuple3",
"Prims.l_and",
"Prims.eq2",
"Pulse.Syntax.Base.st_comp",
"Pulse.Syntax.Base.st_comp_of_comp",
"Pulse.Typing.Combinators.st_comp_with_pre",
"Prims.l_imp",
"Pulse.Syntax.Base.effect_annot",
"Pulse.Syntax.Base.effect_annot_of_comp",
"FStar.Stubs.Tactics.Types.proofstate",
"Pulse.Syntax.Base.comp_pre",
"FStar.Pervasives.Native.uu___is_None",
"Pulse.Syntax.Base.typ",
"Pulse.Typing.Env.lookup",
"Pulse.Syntax.Naming.freevars_st",
"Pulse.Syntax.Naming.open_term",
"Pulse.Syntax.Naming.freevars",
"FStar.Stubs.Tactics.Result.__result",
"Prims.l_True"
] | [] | false | false | false | true | true | let bind_t (case_c1 case_c2: (comp_st -> bool)) =
|
g: env ->
pre: term ->
e1: st_term ->
e2: st_term ->
c1: comp_st{case_c1 c1} ->
c2: comp_st{case_c2 c2} ->
px: nvar{~(Set.mem (snd px) (dom g))} ->
d_e1: st_typing g e1 c1 ->
d_c1res: tot_typing g (comp_res c1) (tm_type (comp_u c1)) ->
d_e2: st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2 ->
res_typing: universe_of g (comp_res c2) (comp_u c2) ->
post_typing:
tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop ->
bias_towards_continuation: bool
-> T.TacH
(t: st_term &
c:
comp_st
{ st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires
fun _ ->
let _, x = px in
comp_pre c1 == pre /\ None? (lookup g x) /\ (~(x `Set.mem` (freevars_st e2))) /\
open_term (comp_post c1) x == comp_pre c2 /\ (~(x `Set.mem` (freevars (comp_post c2)))))
(ensures fun _ _ -> True) | false |
|
Vale.AES.GCM_BE_s.fst | Vale.AES.GCM_BE_s.gcm_decrypt_BE_def | val gcm_decrypt_BE_def
(alg: algorithm)
(key: seq nat8)
(iv: supported_iv_BE)
(cipher auth tag: seq nat8)
: Pure (seq nat8 & bool)
(requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32)
(ensures fun (p, t) -> True) | val gcm_decrypt_BE_def
(alg: algorithm)
(key: seq nat8)
(iv: supported_iv_BE)
(cipher auth tag: seq nat8)
: Pure (seq nat8 & bool)
(requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32)
(ensures fun (p, t) -> True) | let gcm_decrypt_BE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_BE) (cipher:seq nat8) (auth:seq nat8) (tag:seq nat8) :
Pure (seq nat8 & bool)
(requires
is_aes_key alg key /\
length cipher < pow2_32 /\
length auth < pow2_32
)
(ensures fun (p, t) -> True)
=
let key_BE = seq_nat8_to_seq_nat32_BE key in
let h_BE = aes_encrypt_word alg key_BE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_BE iv in
let p = gctr_encrypt (inc32 j0_BE 1) cipher alg key_BE in // TODO: Rename gctr_encrypt to gctr
let lengths_BE = two_two_to_four (Mktwo (nat_to_two 32 (8 * length auth)) (nat_to_two 32 (8 * length cipher))) in
let zero_padded_c_BE = be_bytes_to_seq_quad32 (pad_to_128_bits cipher) in
let zero_padded_a_BE = be_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_BE = append zero_padded_a_BE (append zero_padded_c_BE (create 1 lengths_BE)) in
let s_BE = ghash_BE h_BE hash_input_BE in
let t = gctr_encrypt j0_BE (be_quad32_to_bytes s_BE) alg key_BE in
(p, t = tag) | {
"file_name": "vale/specs/crypto/Vale.AES.GCM_BE_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 89,
"start_col": 0,
"start_line": 65
} | module Vale.AES.GCM_BE_s
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.AES.AES_BE_s
open Vale.AES.GCTR_BE_s
open Vale.AES.GHash_BE_s
open FStar.Seq
open FStar.Mul
#reset-options "--z3rlimit 30"
type supported_iv_BE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 }
let compute_iv_BE_def (h_BE:quad32) (iv:supported_iv_BE) : quad32
=
if 8 * (length iv) = 96 then (
let iv_BE = be_bytes_to_quad32 (pad_to_128_bits iv) in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE
) else (
let padded_iv_quads = be_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = two_two_to_four (Mktwo (nat_to_two 32 0) (nat_to_two 32 (8 * length iv))) in
let hash_input_BE = append padded_iv_quads (create 1 length_BE) in
let hash_output_BE = ghash_BE h_BE hash_input_BE in
hash_output_BE
)
[@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def
irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def
let gcm_encrypt_BE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_BE) (plain:seq nat8) (auth:seq nat8) :
Pure (seq nat8 & seq nat8)
(requires
is_aes_key alg key /\
length plain < pow2_32 /\
length auth < pow2_32
)
(ensures fun (c, t) -> True)
=
let key_BE = seq_nat8_to_seq_nat32_BE key in
let h_BE = aes_encrypt_word alg key_BE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_BE iv in
let c = gctr_encrypt (inc32 j0_BE 1) plain alg key_BE in
// Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth
let lengths_BE = two_two_to_four (Mktwo (nat_to_two 32 (8 * length auth)) (nat_to_two 32 (8 * length plain))) in
let zero_padded_c_BE = be_bytes_to_seq_quad32 (pad_to_128_bits c) in
let zero_padded_a_BE = be_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_BE = append zero_padded_a_BE (append zero_padded_c_BE (create 1 lengths_BE)) in
let s_BE = ghash_BE h_BE hash_input_BE in
let t = gctr_encrypt j0_BE (be_quad32_to_bytes s_BE) alg key_BE in
(c, t)
[@"opaque_to_smt"] let gcm_encrypt_BE = opaque_make gcm_encrypt_BE_def
irreducible let gcm_encrypt_BE_reveal = opaque_revealer (`%gcm_encrypt_BE) gcm_encrypt_BE gcm_encrypt_BE_def | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash_BE_s.fst.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GCM_BE_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"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.Seq_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.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
iv: Vale.AES.GCM_BE_s.supported_iv_BE ->
cipher: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
tag: FStar.Seq.Base.seq Vale.Def.Types_s.nat8
-> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * Prims.bool) | Prims.Pure | [] | [] | [
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Vale.AES.GCM_BE_s.supported_iv_BE",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"Prims.op_Equality",
"Vale.Def.Words_s.nat8",
"Vale.AES.GCTR_BE_s.gctr_encrypt",
"Vale.Arch.Types.be_quad32_to_bytes",
"Vale.Def.Types_s.quad32",
"Vale.AES.GHash_BE_s.ghash_BE",
"FStar.Seq.Base.append",
"FStar.Seq.Base.create",
"Vale.Def.Types_s.be_bytes_to_seq_quad32",
"Vale.AES.GCTR_BE_s.pad_to_128_bits",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.natN",
"Prims.pow2",
"Vale.Def.Words.Four_s.two_two_to_four",
"Vale.Def.Words_s.Mktwo",
"Vale.Def.Words_s.two",
"Vale.Def.Words.Two_s.nat_to_two",
"FStar.Mul.op_Star",
"FStar.Seq.Base.length",
"Vale.AES.GCTR_BE_s.inc32",
"Vale.AES.GCM_BE_s.compute_iv_BE",
"Vale.AES.AES_BE_s.aes_encrypt_word",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_BE",
"FStar.Pervasives.Native.tuple2",
"Prims.l_and",
"Vale.AES.AES_common_s.is_aes_key",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.Def.Words_s.pow2_32",
"Prims.l_True"
] | [] | false | false | false | false | false | let gcm_decrypt_BE_def
(alg: algorithm)
(key: seq nat8)
(iv: supported_iv_BE)
(cipher auth tag: seq nat8)
: Pure (seq nat8 & bool)
(requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32)
(ensures fun (p, t) -> True) =
| let key_BE = seq_nat8_to_seq_nat32_BE key in
let h_BE = aes_encrypt_word alg key_BE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_BE iv in
let p = gctr_encrypt (inc32 j0_BE 1) cipher alg key_BE in
let lengths_BE =
two_two_to_four (Mktwo (nat_to_two 32 (8 * length auth)) (nat_to_two 32 (8 * length cipher)))
in
let zero_padded_c_BE = be_bytes_to_seq_quad32 (pad_to_128_bits cipher) in
let zero_padded_a_BE = be_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_BE = append zero_padded_a_BE (append zero_padded_c_BE (create 1 lengths_BE)) in
let s_BE = ghash_BE h_BE hash_input_BE in
let t = gctr_encrypt j0_BE (be_quad32_to_bytes s_BE) alg key_BE in
(p, t = tag) | false |
Pulse.Typing.Combinators.fst | Pulse.Typing.Combinators.try_lift_ghost_atomic | val try_lift_ghost_atomic (#g: env) (#e: st_term) (#c: comp_st{C_STGhost? c}) (d: st_typing g e c)
: T.Tac (option (st_typing g e (st_ghost_as_atomic c))) | val try_lift_ghost_atomic (#g: env) (#e: st_term) (#c: comp_st{C_STGhost? c}) (d: st_typing g e c)
: T.Tac (option (st_typing g e (st_ghost_as_atomic c))) | let try_lift_ghost_atomic (#g:env) (#e:st_term) (#c:comp_st { C_STGhost? c }) (d:st_typing g e c)
: T.Tac (option (st_typing g e (st_ghost_as_atomic c)))
= let w = try_get_non_informative_witness g (comp_u c) (comp_res c) in
match w with
| None -> None
| Some w ->
let d = T_Lift _ _ _ _ d (Lift_Ghost_Neutral _ c w) in
Some d | {
"file_name": "lib/steel/pulse/Pulse.Typing.Combinators.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 10,
"end_line": 212,
"start_col": 0,
"start_line": 205
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Typing.Combinators
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
assume
val invert_forall_typing
(#g #u #b #body:_)
(d:tot_typing g (tm_forall_sl u b body) tm_vprop)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
: GTot (
tot_typing g b.binder_ty (tm_type u) &
tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop
)
assume
val construct_forall_typing
(#g #u #b #body:_)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
(dt:tot_typing g b.binder_ty (tm_type u))
(db:tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop)
: GTot (tot_typing g (tm_forall_sl u b body) tm_vprop)
let rec vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1)
: GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop))
(decreases v)
= match v with
| VE_Refl _ _ -> (fun x -> x), (fun x -> x)
| VE_Sym _ _ _ v' ->
let f, g = vprop_equiv_typing v' in
g, f
| VE_Trans g t0 t2 t1 v02 v21 ->
let f02, f20 = vprop_equiv_typing v02 in
let f21, f12 = vprop_equiv_typing v21 in
(fun x -> f21 (f02 x)),
(fun x -> f20 (f12 x))
| VE_Ctxt g s0 s1 s0' s1' v0 v1 ->
let f0, f0' = vprop_equiv_typing v0 in
let f1, f1' = vprop_equiv_typing v1 in
let ff (x:tot_typing g (tm_star s0 s1) tm_vprop)
: tot_typing g (tm_star s0' s1') tm_vprop
= let s0_typing = star_typing_inversion_l x in
let s1_typing = star_typing_inversion_r x in
let s0'_typing, s1'_typing = f0 s0_typing, f1 s1_typing in
star_typing s0'_typing s1'_typing
in
let gg (x:tot_typing g (tm_star s0' s1') tm_vprop)
: tot_typing g (tm_star s0 s1) tm_vprop
= let s0'_typing = star_typing_inversion_l x in
let s1'_typing = star_typing_inversion_r x in
star_typing (f0' s0'_typing) (f1' s1'_typing)
in
ff, gg
| VE_Unit g t ->
let fwd (x:tot_typing g (tm_star tm_emp t) tm_vprop)
: tot_typing g t tm_vprop
= let r = star_typing_inversion_r x in
r
in
let bk (x:tot_typing g t tm_vprop)
: tot_typing g (tm_star tm_emp t) tm_vprop
= star_typing emp_typing x
in
fwd, bk
| VE_Comm g t0 t1 ->
let f t0 t1 (x:tot_typing g (tm_star t0 t1) tm_vprop)
: tot_typing g (tm_star t1 t0) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt1 = star_typing_inversion_r x in
star_typing tt1 tt0
in
f t0 t1, f t1 t0
| VE_Assoc g t0 t1 t2 ->
let fwd (x:tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop)
: tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt12 = star_typing_inversion_r x in
let tt1 = star_typing_inversion_l tt12 in
let tt2 = star_typing_inversion_r tt12 in
star_typing (star_typing tt0 tt1) tt2
in
let bk (x : tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop)
: tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop
= let tt01 = star_typing_inversion_l x in
let tt2 = star_typing_inversion_r x in
let tt0 = star_typing_inversion_l tt01 in
let tt1 = star_typing_inversion_r tt01 in
star_typing tt0 (star_typing tt1 tt2)
in
fwd, bk
| VE_Ext g t0 t1 token ->
let d1, d2 = vprop_eq_typing_inversion g t0 t1 token in
(fun _ -> d2),
(fun _ -> d1)
| VE_Fa g x u b t0 t1 d ->
let d0, d1 = vprop_equiv_typing d in
(fun fa0_typing ->
let b_typing, t0_typing = invert_forall_typing fa0_typing x in
let t1_typing = d0 t0_typing in
construct_forall_typing #g #u x b_typing t1_typing),
(fun fa1_typing ->
let b_typing, t1_typing = invert_forall_typing fa1_typing x in
let t0_typing = d1 t1_typing in
construct_forall_typing #g #u #b #t0 x b_typing t0_typing)
#push-options "--z3rlimit_factor 8 --ifuel 1 --fuel 2 --query_stats"
let bind_t (case_c1 case_c2:comp_st -> bool) =
(g:env) ->
(pre:term) ->
(e1:st_term) ->
(e2:st_term) ->
(c1:comp_st{ case_c1 c1 }) ->
(c2:comp_st{ case_c2 c2 }) ->
(px:nvar { ~ (Set.mem (snd px) (dom g)) }) ->
(d_e1:st_typing g e1 c1) ->
(d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1))) ->
(d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2) ->
(res_typing:universe_of g (comp_res c2) (comp_u c2)) ->
(post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop) ->
(bias_towards_continuation:bool) ->
T.TacH (t:st_term &
c:comp_st { st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires fun _ ->
let _, x = px in
comp_pre c1 == pre /\
None? (lookup g x) /\
(~(x `Set.mem` freevars_st e2)) /\
open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))))
(ensures fun _ _ -> True)
let mk_bind_st_st
: bind_t C_ST? C_ST?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
let inames_of (c:comp_st) : term =
match c with
| C_ST _
| C_STGhost _ -> tm_emp_inames
| C_STAtomic inames _ _ -> inames
let with_inames (c:comp_st) (i:term) =
match c with
| C_ST _ -> c
| C_STGhost sc -> C_STGhost sc
| C_STAtomic _ obs sc -> C_STAtomic i obs sc
let weaken_comp_inames (#g:env) (#e:st_term) (#c:comp_st) (d_e:st_typing g e c) (new_inames:term)
: T.Tac (c':comp_st { with_inames c new_inames == c' } &
st_typing g e c')
= match c with
| C_ST _
| C_STGhost _ -> (| c, d_e |)
| C_STAtomic inames obs sc ->
let d_e = T_Sub _ _ _ _ d_e (STS_AtomicInvs _ sc inames new_inames obs obs (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
(| with_inames c new_inames, d_e |)
let st_ghost_as_atomic (c:comp_st { C_STGhost? c }) =
C_STAtomic tm_emp_inames Neutral (st_comp_of_comp c) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.PP.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Result.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Typing.Combinators.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | d: Pulse.Typing.st_typing g e c
-> FStar.Tactics.Effect.Tac
(FStar.Pervasives.Native.option (Pulse.Typing.st_typing g
e
(Pulse.Typing.Combinators.st_ghost_as_atomic c))) | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.st_term",
"Pulse.Syntax.Base.comp_st",
"Prims.b2t",
"Pulse.Syntax.Base.uu___is_C_STGhost",
"Pulse.Typing.st_typing",
"FStar.Pervasives.Native.None",
"Pulse.Typing.Combinators.st_ghost_as_atomic",
"Pulse.Typing.non_informative_t",
"Pulse.Syntax.Base.comp_u",
"Pulse.Syntax.Base.comp_res",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.C_STAtomic",
"Pulse.Syntax.Base.tm_emp_inames",
"Pulse.Syntax.Base.Neutral",
"Pulse.Syntax.Base.st_comp_of_comp",
"Pulse.Typing.T_Lift",
"Pulse.Typing.Lift_Ghost_Neutral",
"FStar.Pervasives.Native.option",
"Pulse.Checker.Pure.try_get_non_informative_witness"
] | [] | false | true | false | false | false | let try_lift_ghost_atomic (#g: env) (#e: st_term) (#c: comp_st{C_STGhost? c}) (d: st_typing g e c)
: T.Tac (option (st_typing g e (st_ghost_as_atomic c))) =
| let w = try_get_non_informative_witness g (comp_u c) (comp_res c) in
match w with
| None -> None
| Some w ->
let d = T_Lift _ _ _ _ d (Lift_Ghost_Neutral _ c w) in
Some d | false |
Vale.AES.GCM_BE_s.fst | Vale.AES.GCM_BE_s.gcm_encrypt_BE_def | val gcm_encrypt_BE_def (alg: algorithm) (key: seq nat8) (iv: supported_iv_BE) (plain auth: seq nat8)
: Pure (seq nat8 & seq nat8)
(requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32)
(ensures fun (c, t) -> True) | val gcm_encrypt_BE_def (alg: algorithm) (key: seq nat8) (iv: supported_iv_BE) (plain auth: seq nat8)
: Pure (seq nat8 & seq nat8)
(requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32)
(ensures fun (c, t) -> True) | let gcm_encrypt_BE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_BE) (plain:seq nat8) (auth:seq nat8) :
Pure (seq nat8 & seq nat8)
(requires
is_aes_key alg key /\
length plain < pow2_32 /\
length auth < pow2_32
)
(ensures fun (c, t) -> True)
=
let key_BE = seq_nat8_to_seq_nat32_BE key in
let h_BE = aes_encrypt_word alg key_BE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_BE iv in
let c = gctr_encrypt (inc32 j0_BE 1) plain alg key_BE in
// Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth
let lengths_BE = two_two_to_four (Mktwo (nat_to_two 32 (8 * length auth)) (nat_to_two 32 (8 * length plain))) in
let zero_padded_c_BE = be_bytes_to_seq_quad32 (pad_to_128_bits c) in
let zero_padded_a_BE = be_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_BE = append zero_padded_a_BE (append zero_padded_c_BE (create 1 lengths_BE)) in
let s_BE = ghash_BE h_BE hash_input_BE in
let t = gctr_encrypt j0_BE (be_quad32_to_bytes s_BE) alg key_BE in
(c, t) | {
"file_name": "vale/specs/crypto/Vale.AES.GCM_BE_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 8,
"end_line": 61,
"start_col": 0,
"start_line": 36
} | module Vale.AES.GCM_BE_s
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.AES.AES_BE_s
open Vale.AES.GCTR_BE_s
open Vale.AES.GHash_BE_s
open FStar.Seq
open FStar.Mul
#reset-options "--z3rlimit 30"
type supported_iv_BE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 }
let compute_iv_BE_def (h_BE:quad32) (iv:supported_iv_BE) : quad32
=
if 8 * (length iv) = 96 then (
let iv_BE = be_bytes_to_quad32 (pad_to_128_bits iv) in
let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in
j0_BE
) else (
let padded_iv_quads = be_bytes_to_seq_quad32 (pad_to_128_bits iv) in
let length_BE = two_two_to_four (Mktwo (nat_to_two 32 0) (nat_to_two 32 (8 * length iv))) in
let hash_input_BE = append padded_iv_quads (create 1 length_BE) in
let hash_output_BE = ghash_BE h_BE hash_input_BE in
hash_output_BE
)
[@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def
irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash_BE_s.fst.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GCM_BE_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"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.Seq_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.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
iv: Vale.AES.GCM_BE_s.supported_iv_BE ->
plain: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8
-> Prims.Pure
(FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * FStar.Seq.Base.seq Vale.Def.Types_s.nat8) | Prims.Pure | [] | [] | [
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Vale.AES.GCM_BE_s.supported_iv_BE",
"FStar.Pervasives.Native.Mktuple2",
"Vale.Def.Words_s.nat8",
"Vale.AES.GCTR_BE_s.gctr_encrypt",
"Vale.Arch.Types.be_quad32_to_bytes",
"Vale.Def.Types_s.quad32",
"Vale.AES.GHash_BE_s.ghash_BE",
"FStar.Seq.Base.append",
"FStar.Seq.Base.create",
"Vale.Def.Types_s.be_bytes_to_seq_quad32",
"Vale.AES.GCTR_BE_s.pad_to_128_bits",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.natN",
"Prims.pow2",
"Vale.Def.Words.Four_s.two_two_to_four",
"Vale.Def.Words_s.Mktwo",
"Vale.Def.Words_s.two",
"Vale.Def.Words.Two_s.nat_to_two",
"FStar.Mul.op_Star",
"FStar.Seq.Base.length",
"Vale.AES.GCTR_BE_s.inc32",
"Vale.AES.GCM_BE_s.compute_iv_BE",
"Vale.AES.AES_BE_s.aes_encrypt_word",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_BE",
"FStar.Pervasives.Native.tuple2",
"Prims.l_and",
"Vale.AES.AES_common_s.is_aes_key",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.Def.Words_s.pow2_32",
"Prims.l_True"
] | [] | false | false | false | false | false | let gcm_encrypt_BE_def (alg: algorithm) (key: seq nat8) (iv: supported_iv_BE) (plain auth: seq nat8)
: Pure (seq nat8 & seq nat8)
(requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32)
(ensures fun (c, t) -> True) =
| let key_BE = seq_nat8_to_seq_nat32_BE key in
let h_BE = aes_encrypt_word alg key_BE (Mkfour 0 0 0 0) in
let j0_BE = compute_iv_BE h_BE iv in
let c = gctr_encrypt (inc32 j0_BE 1) plain alg key_BE in
let lengths_BE =
two_two_to_four (Mktwo (nat_to_two 32 (8 * length auth)) (nat_to_two 32 (8 * length plain)))
in
let zero_padded_c_BE = be_bytes_to_seq_quad32 (pad_to_128_bits c) in
let zero_padded_a_BE = be_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let hash_input_BE = append zero_padded_a_BE (append zero_padded_c_BE (create 1 lengths_BE)) in
let s_BE = ghash_BE h_BE hash_input_BE in
let t = gctr_encrypt j0_BE (be_quad32_to_bytes s_BE) alg key_BE in
(c, t) | false |
Pulse.Typing.Combinators.fst | Pulse.Typing.Combinators.vprop_equiv_typing | val vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1)
: GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop)) | val vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1)
: GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop)) | let rec vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1)
: GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop))
(decreases v)
= match v with
| VE_Refl _ _ -> (fun x -> x), (fun x -> x)
| VE_Sym _ _ _ v' ->
let f, g = vprop_equiv_typing v' in
g, f
| VE_Trans g t0 t2 t1 v02 v21 ->
let f02, f20 = vprop_equiv_typing v02 in
let f21, f12 = vprop_equiv_typing v21 in
(fun x -> f21 (f02 x)),
(fun x -> f20 (f12 x))
| VE_Ctxt g s0 s1 s0' s1' v0 v1 ->
let f0, f0' = vprop_equiv_typing v0 in
let f1, f1' = vprop_equiv_typing v1 in
let ff (x:tot_typing g (tm_star s0 s1) tm_vprop)
: tot_typing g (tm_star s0' s1') tm_vprop
= let s0_typing = star_typing_inversion_l x in
let s1_typing = star_typing_inversion_r x in
let s0'_typing, s1'_typing = f0 s0_typing, f1 s1_typing in
star_typing s0'_typing s1'_typing
in
let gg (x:tot_typing g (tm_star s0' s1') tm_vprop)
: tot_typing g (tm_star s0 s1) tm_vprop
= let s0'_typing = star_typing_inversion_l x in
let s1'_typing = star_typing_inversion_r x in
star_typing (f0' s0'_typing) (f1' s1'_typing)
in
ff, gg
| VE_Unit g t ->
let fwd (x:tot_typing g (tm_star tm_emp t) tm_vprop)
: tot_typing g t tm_vprop
= let r = star_typing_inversion_r x in
r
in
let bk (x:tot_typing g t tm_vprop)
: tot_typing g (tm_star tm_emp t) tm_vprop
= star_typing emp_typing x
in
fwd, bk
| VE_Comm g t0 t1 ->
let f t0 t1 (x:tot_typing g (tm_star t0 t1) tm_vprop)
: tot_typing g (tm_star t1 t0) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt1 = star_typing_inversion_r x in
star_typing tt1 tt0
in
f t0 t1, f t1 t0
| VE_Assoc g t0 t1 t2 ->
let fwd (x:tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop)
: tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt12 = star_typing_inversion_r x in
let tt1 = star_typing_inversion_l tt12 in
let tt2 = star_typing_inversion_r tt12 in
star_typing (star_typing tt0 tt1) tt2
in
let bk (x : tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop)
: tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop
= let tt01 = star_typing_inversion_l x in
let tt2 = star_typing_inversion_r x in
let tt0 = star_typing_inversion_l tt01 in
let tt1 = star_typing_inversion_r tt01 in
star_typing tt0 (star_typing tt1 tt2)
in
fwd, bk
| VE_Ext g t0 t1 token ->
let d1, d2 = vprop_eq_typing_inversion g t0 t1 token in
(fun _ -> d2),
(fun _ -> d1)
| VE_Fa g x u b t0 t1 d ->
let d0, d1 = vprop_equiv_typing d in
(fun fa0_typing ->
let b_typing, t0_typing = invert_forall_typing fa0_typing x in
let t1_typing = d0 t0_typing in
construct_forall_typing #g #u x b_typing t1_typing),
(fun fa1_typing ->
let b_typing, t1_typing = invert_forall_typing fa1_typing x in
let t0_typing = d1 t1_typing in
construct_forall_typing #g #u #b #t0 x b_typing t0_typing) | {
"file_name": "lib/steel/pulse/Pulse.Typing.Combinators.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 66,
"end_line": 138,
"start_col": 0,
"start_line": 49
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Typing.Combinators
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
assume
val invert_forall_typing
(#g #u #b #body:_)
(d:tot_typing g (tm_forall_sl u b body) tm_vprop)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
: GTot (
tot_typing g b.binder_ty (tm_type u) &
tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop
)
assume
val construct_forall_typing
(#g #u #b #body:_)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
(dt:tot_typing g b.binder_ty (tm_type u))
(db:tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop)
: GTot (tot_typing g (tm_forall_sl u b body) tm_vprop) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.PP.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Result.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Typing.Combinators.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": 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: Pulse.Typing.vprop_equiv g t0 t1
-> Prims.GTot
((_: Pulse.Typing.tot_typing g t0 Pulse.Syntax.Base.tm_vprop
-> Pulse.Typing.tot_typing g t1 Pulse.Syntax.Base.tm_vprop) *
(_: Pulse.Typing.tot_typing g t1 Pulse.Syntax.Base.tm_vprop
-> Pulse.Typing.tot_typing g t0 Pulse.Syntax.Base.tm_vprop)) | Prims.GTot | [
"",
"sometrivial"
] | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.term",
"Pulse.Typing.vprop_equiv",
"FStar.Pervasives.Native.Mktuple2",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.tm_vprop",
"FStar.Pervasives.Native.tuple2",
"Pulse.Typing.Combinators.vprop_equiv_typing",
"Pulse.Syntax.Base.tm_star",
"Pulse.Typing.star_typing",
"Pulse.Typing.star_typing_inversion_r",
"Pulse.Typing.star_typing_inversion_l",
"Pulse.Syntax.Base.tm_emp",
"Pulse.Typing.emp_typing",
"Pulse.Syntax.Base.vprop",
"FStar.Stubs.Tactics.Types.equiv_token",
"Pulse.Typing.elab_env",
"Pulse.Elaborate.Pure.elab_term",
"Pulse.Typing.vprop_eq_typing_inversion",
"Pulse.Syntax.Base.var",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_None",
"Pulse.Syntax.Base.typ",
"Pulse.Typing.Env.lookup",
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.binder",
"Prims.l_not",
"FStar.Set.mem",
"Pulse.Syntax.Naming.freevars",
"Pulse.Typing.Env.push_binding",
"Pulse.Syntax.Base.ppname_default",
"Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty",
"Pulse.Syntax.Naming.open_term",
"Pulse.Syntax.Base.tm_forall_sl",
"Pulse.Syntax.Pure.tm_type",
"Pulse.Typing.Combinators.construct_forall_typing",
"Pulse.Typing.Combinators.invert_forall_typing"
] | [
"recursion"
] | false | false | false | false | false | let rec vprop_equiv_typing (#g: _) (#t0 #t1: term) (v: vprop_equiv g t0 t1)
: GTot
((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop)) (decreases v) =
| match v with
| VE_Refl _ _ -> (fun x -> x), (fun x -> x)
| VE_Sym _ _ _ v' ->
let f, g = vprop_equiv_typing v' in
g, f
| VE_Trans g t0 t2 t1 v02 v21 ->
let f02, f20 = vprop_equiv_typing v02 in
let f21, f12 = vprop_equiv_typing v21 in
(fun x -> f21 (f02 x)), (fun x -> f20 (f12 x))
| VE_Ctxt g s0 s1 s0' s1' v0 v1 ->
let f0, f0' = vprop_equiv_typing v0 in
let f1, f1' = vprop_equiv_typing v1 in
let ff (x: tot_typing g (tm_star s0 s1) tm_vprop) : tot_typing g (tm_star s0' s1') tm_vprop =
let s0_typing = star_typing_inversion_l x in
let s1_typing = star_typing_inversion_r x in
let s0'_typing, s1'_typing = f0 s0_typing, f1 s1_typing in
star_typing s0'_typing s1'_typing
in
let gg (x: tot_typing g (tm_star s0' s1') tm_vprop) : tot_typing g (tm_star s0 s1) tm_vprop =
let s0'_typing = star_typing_inversion_l x in
let s1'_typing = star_typing_inversion_r x in
star_typing (f0' s0'_typing) (f1' s1'_typing)
in
ff, gg
| VE_Unit g t ->
let fwd (x: tot_typing g (tm_star tm_emp t) tm_vprop) : tot_typing g t tm_vprop =
let r = star_typing_inversion_r x in
r
in
let bk (x: tot_typing g t tm_vprop) : tot_typing g (tm_star tm_emp t) tm_vprop =
star_typing emp_typing x
in
fwd, bk
| VE_Comm g t0 t1 ->
let f t0 t1 (x: tot_typing g (tm_star t0 t1) tm_vprop) : tot_typing g (tm_star t1 t0) tm_vprop =
let tt0 = star_typing_inversion_l x in
let tt1 = star_typing_inversion_r x in
star_typing tt1 tt0
in
f t0 t1, f t1 t0
| VE_Assoc g t0 t1 t2 ->
let fwd (x: tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop)
: tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop =
let tt0 = star_typing_inversion_l x in
let tt12 = star_typing_inversion_r x in
let tt1 = star_typing_inversion_l tt12 in
let tt2 = star_typing_inversion_r tt12 in
star_typing (star_typing tt0 tt1) tt2
in
let bk (x: tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop)
: tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop =
let tt01 = star_typing_inversion_l x in
let tt2 = star_typing_inversion_r x in
let tt0 = star_typing_inversion_l tt01 in
let tt1 = star_typing_inversion_r tt01 in
star_typing tt0 (star_typing tt1 tt2)
in
fwd, bk
| VE_Ext g t0 t1 token ->
let d1, d2 = vprop_eq_typing_inversion g t0 t1 token in
(fun _ -> d2), (fun _ -> d1)
| VE_Fa g x u b t0 t1 d ->
let d0, d1 = vprop_equiv_typing d in
(fun fa0_typing ->
let b_typing, t0_typing = invert_forall_typing fa0_typing x in
let t1_typing = d0 t0_typing in
construct_forall_typing #g #u x b_typing t1_typing),
(fun fa1_typing ->
let b_typing, t1_typing = invert_forall_typing fa1_typing x in
let t0_typing = d1 t1_typing in
construct_forall_typing #g #u #b #t0 x b_typing t0_typing) | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.va_QLemma | val va_QLemma
(#a: Type0)
(#cs: codes)
(r: range)
(msg: string)
(pre: Type0)
(post: (squash pre -> Type0))
(l: (unit -> Lemma (requires pre) (ensures post ())))
(qcs: quickCodes a cs)
: quickCodes a cs | val va_QLemma
(#a: Type0)
(#cs: codes)
(r: range)
(msg: string)
(pre: Type0)
(post: (squash pre -> Type0))
(l: (unit -> Lemma (requires pre) (ensures post ())))
(qcs: quickCodes a cs)
: quickCodes a cs | let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 240,
"end_line": 74,
"start_col": 19,
"start_line": 74
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
r: FStar.Range.range ->
msg: Prims.string ->
pre: Type0 ->
post: (_: Prims.squash pre -> Type0) ->
l: (_: Prims.unit -> FStar.Pervasives.Lemma (requires pre) (ensures post ())) ->
qcs: Vale.PPC64LE.QuickCodes.quickCodes a cs
-> Vale.PPC64LE.QuickCodes.quickCodes a cs | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.codes",
"FStar.Range.range",
"Prims.string",
"Prims.squash",
"Prims.unit",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.QuickCodes.QLemma"
] | [] | false | false | false | false | false | let va_QLemma
(#a: Type0)
(#cs: codes)
(r: range)
(msg: string)
(pre: Type0)
(post: (squash pre -> Type0))
(l: (unit -> Lemma (requires pre) (ensures post ())))
(qcs: quickCodes a cs)
: quickCodes a cs =
| QLemma r msg pre post l qcs | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.va_qIf | val va_qIf
(#a: Type)
(#c1 #c2: code)
(mods: mods_t)
(b: cmp)
(qc1: quickCode a c1)
(qc2: quickCode a c2)
: quickCode a (IfElse (cmp_to_ocmp b) c1 c2) | val va_qIf
(#a: Type)
(#c1 #c2: code)
(mods: mods_t)
(b: cmp)
(qc1: quickCode a c1)
(qc2: quickCode a c2)
: quickCode a (IfElse (cmp_to_ocmp b) c1 c2) | let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods) | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 93,
"end_line": 261,
"start_col": 0,
"start_line": 260
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mods: Vale.PPC64LE.QuickCode.mods_t ->
b: Vale.PPC64LE.QuickCodes.cmp ->
qc1: Vale.PPC64LE.QuickCode.quickCode a c1 ->
qc2: Vale.PPC64LE.QuickCode.quickCode a c2
-> Vale.PPC64LE.QuickCode.quickCode a
(Vale.PPC64LE.Machine_s.IfElse (Vale.PPC64LE.QuickCodes.cmp_to_ocmp b) c1 c2) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.QuickCodes.cmp",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.QuickCode.QProc",
"Vale.PPC64LE.Machine_s.IfElse",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.QuickCodes.cmp_to_ocmp",
"Vale.PPC64LE.QuickCodes.wp_If",
"Vale.PPC64LE.QuickCodes.qIf_proof"
] | [] | false | false | false | false | false | let va_qIf
(#a: Type)
(#c1 #c2: code)
(mods: mods_t)
(b: cmp)
(qc1: quickCode a c1)
(qc2: quickCode a c2)
: quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
| QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods) | false |
Vale.Poly1305.Spec_s.fst | Vale.Poly1305.Spec_s.modp | val modp (x: int) : int | val modp (x: int) : int | let modp (x:int) : int =
x % (pow2_128 * 4 - 5) | {
"file_name": "vale/specs/crypto/Vale.Poly1305.Spec_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 24,
"end_line": 9,
"start_col": 0,
"start_line": 8
} | module Vale.Poly1305.Spec_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Poly1305.Spec_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.int -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Prims.op_Modulus",
"Prims.op_Subtraction",
"FStar.Mul.op_Star",
"Vale.Def.Words_s.pow2_128"
] | [] | false | false | false | true | false | let modp (x: int) : int =
| x % (pow2_128 * 4 - 5) | false |
Vale.Poly1305.Spec_s.fst | Vale.Poly1305.Spec_s.poly1305_hash | val poly1305_hash (key_r key_s: nat128) (inp: (int -> nat128)) (len: nat) : int | val poly1305_hash (key_r key_s: nat128) (inp: (int -> nat128)) (len: nat) : int | let poly1305_hash (key_r key_s:nat128) (inp:int -> nat128) (len:nat) : int =
poly1305_hash_all 0 key_r key_s inp len | {
"file_name": "vale/specs/crypto/Vale.Poly1305.Spec_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 36,
"start_col": 0,
"start_line": 35
} | module Vale.Poly1305.Spec_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
[@"opaque_to_smt"]
let modp (x:int) : int =
x % (pow2_128 * 4 - 5)
[@"opaque_to_smt"]
let mod2_128 (x:int) : int =
x % pow2_128
let rec poly1305_hash_blocks (h pad r:int) (inp:int -> nat128) (k:nat) : int =
if k = 0 then h
else
let hh = poly1305_hash_blocks h pad r inp (k - 1) in
modp ((hh + pad + inp (k - 1)) * r)
let make_r (key_r:nat128) : nat128 =
iand key_r 0x0ffffffc0ffffffc0ffffffc0fffffff
let poly1305_hash_all (h:int) (key_r key_s:nat128) (inp:int -> nat128) (len:nat) : int =
let nBlocks = len / 16 in
let nExtra = len % 16 in
let hBlocks = poly1305_hash_blocks h pow2_128 (make_r key_r) inp nBlocks in
if nExtra = 0 then
mod2_128 (hBlocks + key_s)
else
let padLast = pow2 (nExtra * 8) in
let hLast = modp ((hBlocks + padLast + inp nBlocks % padLast) * (make_r key_r)) in
mod2_128 (hLast + key_s) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Poly1305.Spec_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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 |
key_r: Vale.Def.Words_s.nat128 ->
key_s: Vale.Def.Words_s.nat128 ->
inp: (_: Prims.int -> Vale.Def.Words_s.nat128) ->
len: Prims.nat
-> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Words_s.nat128",
"Prims.int",
"Prims.nat",
"Vale.Poly1305.Spec_s.poly1305_hash_all"
] | [] | false | false | false | true | false | let poly1305_hash (key_r key_s: nat128) (inp: (int -> nat128)) (len: nat) : int =
| poly1305_hash_all 0 key_r key_s inp len | false |
Vale.Poly1305.Spec_s.fst | Vale.Poly1305.Spec_s.mod2_128 | val mod2_128 (x: int) : int | val mod2_128 (x: int) : int | let mod2_128 (x:int) : int =
x % pow2_128 | {
"file_name": "vale/specs/crypto/Vale.Poly1305.Spec_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 13,
"start_col": 0,
"start_line": 12
} | module Vale.Poly1305.Spec_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
[@"opaque_to_smt"]
let modp (x:int) : int =
x % (pow2_128 * 4 - 5) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Poly1305.Spec_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.int -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Prims.op_Modulus",
"Vale.Def.Words_s.pow2_128"
] | [] | false | false | false | true | false | let mod2_128 (x: int) : int =
| x % pow2_128 | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.eval_cmp | val eval_cmp (s: va_state) (c: cmp) : GTot bool | val eval_cmp (s: va_state) (c: cmp) : GTot bool | let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 64,
"end_line": 242,
"start_col": 0,
"start_line": 235
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1 | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Vale.PPC64LE.Decls.va_state -> c: Vale.PPC64LE.QuickCodes.cmp -> Prims.GTot Prims.bool | Prims.GTot | [
"sometrivial"
] | [] | [
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.cmp",
"Vale.PPC64LE.Machine_s.cmp_opr",
"Prims.op_Equality",
"Vale.PPC64LE.Machine_s.nat64",
"Vale.PPC64LE.Decls.va_eval_cmp_opr",
"Prims.op_disEquality",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.op_GreaterThan",
"Prims.bool"
] | [] | false | false | false | false | false | let eval_cmp (s: va_state) (c: cmp) : GTot bool =
| match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2 | false |
Vale.Poly1305.Spec_s.fst | Vale.Poly1305.Spec_s.make_r | val make_r (key_r: nat128) : nat128 | val make_r (key_r: nat128) : nat128 | let make_r (key_r:nat128) : nat128 =
iand key_r 0x0ffffffc0ffffffc0ffffffc0fffffff | {
"file_name": "vale/specs/crypto/Vale.Poly1305.Spec_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 47,
"end_line": 22,
"start_col": 0,
"start_line": 21
} | module Vale.Poly1305.Spec_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
[@"opaque_to_smt"]
let modp (x:int) : int =
x % (pow2_128 * 4 - 5)
[@"opaque_to_smt"]
let mod2_128 (x:int) : int =
x % pow2_128
let rec poly1305_hash_blocks (h pad r:int) (inp:int -> nat128) (k:nat) : int =
if k = 0 then h
else
let hh = poly1305_hash_blocks h pad r inp (k - 1) in
modp ((hh + pad + inp (k - 1)) * r) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Poly1305.Spec_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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 | key_r: Vale.Def.Words_s.nat128 -> Vale.Def.Words_s.nat128 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Words_s.nat128",
"Vale.Def.Types_s.iand",
"Vale.Def.Words_s.pow2_128"
] | [] | false | false | false | true | false | let make_r (key_r: nat128) : nat128 =
| iand key_r 0x0ffffffc0ffffffc0ffffffc0fffffff | false |
Pulse.Typing.Combinators.fst | Pulse.Typing.Combinators.lift_ghost_atomic | val lift_ghost_atomic (#g: env) (#e: st_term) (#c: comp_st{C_STGhost? c}) (d: st_typing g e c)
: T.Tac (st_typing g e (st_ghost_as_atomic c)) | val lift_ghost_atomic (#g: env) (#e: st_term) (#c: comp_st{C_STGhost? c}) (d: st_typing g e c)
: T.Tac (st_typing g e (st_ghost_as_atomic c)) | let lift_ghost_atomic (#g:env) (#e:st_term) (#c:comp_st { C_STGhost? c }) (d:st_typing g e c)
: T.Tac (st_typing g e (st_ghost_as_atomic c))
= let w = try_lift_ghost_atomic d in
match w with
| None ->
let open Pulse.PP in
let t = comp_res c in
fail_doc g (Some t.range) [
text "Expected a term with a non-informative (e.g., erased) type; got"
^/^ pp t
]
| Some d ->
d | {
"file_name": "lib/steel/pulse/Pulse.Typing.Combinators.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 5,
"end_line": 226,
"start_col": 0,
"start_line": 214
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Typing.Combinators
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
assume
val invert_forall_typing
(#g #u #b #body:_)
(d:tot_typing g (tm_forall_sl u b body) tm_vprop)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
: GTot (
tot_typing g b.binder_ty (tm_type u) &
tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop
)
assume
val construct_forall_typing
(#g #u #b #body:_)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
(dt:tot_typing g b.binder_ty (tm_type u))
(db:tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop)
: GTot (tot_typing g (tm_forall_sl u b body) tm_vprop)
let rec vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1)
: GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop))
(decreases v)
= match v with
| VE_Refl _ _ -> (fun x -> x), (fun x -> x)
| VE_Sym _ _ _ v' ->
let f, g = vprop_equiv_typing v' in
g, f
| VE_Trans g t0 t2 t1 v02 v21 ->
let f02, f20 = vprop_equiv_typing v02 in
let f21, f12 = vprop_equiv_typing v21 in
(fun x -> f21 (f02 x)),
(fun x -> f20 (f12 x))
| VE_Ctxt g s0 s1 s0' s1' v0 v1 ->
let f0, f0' = vprop_equiv_typing v0 in
let f1, f1' = vprop_equiv_typing v1 in
let ff (x:tot_typing g (tm_star s0 s1) tm_vprop)
: tot_typing g (tm_star s0' s1') tm_vprop
= let s0_typing = star_typing_inversion_l x in
let s1_typing = star_typing_inversion_r x in
let s0'_typing, s1'_typing = f0 s0_typing, f1 s1_typing in
star_typing s0'_typing s1'_typing
in
let gg (x:tot_typing g (tm_star s0' s1') tm_vprop)
: tot_typing g (tm_star s0 s1) tm_vprop
= let s0'_typing = star_typing_inversion_l x in
let s1'_typing = star_typing_inversion_r x in
star_typing (f0' s0'_typing) (f1' s1'_typing)
in
ff, gg
| VE_Unit g t ->
let fwd (x:tot_typing g (tm_star tm_emp t) tm_vprop)
: tot_typing g t tm_vprop
= let r = star_typing_inversion_r x in
r
in
let bk (x:tot_typing g t tm_vprop)
: tot_typing g (tm_star tm_emp t) tm_vprop
= star_typing emp_typing x
in
fwd, bk
| VE_Comm g t0 t1 ->
let f t0 t1 (x:tot_typing g (tm_star t0 t1) tm_vprop)
: tot_typing g (tm_star t1 t0) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt1 = star_typing_inversion_r x in
star_typing tt1 tt0
in
f t0 t1, f t1 t0
| VE_Assoc g t0 t1 t2 ->
let fwd (x:tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop)
: tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt12 = star_typing_inversion_r x in
let tt1 = star_typing_inversion_l tt12 in
let tt2 = star_typing_inversion_r tt12 in
star_typing (star_typing tt0 tt1) tt2
in
let bk (x : tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop)
: tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop
= let tt01 = star_typing_inversion_l x in
let tt2 = star_typing_inversion_r x in
let tt0 = star_typing_inversion_l tt01 in
let tt1 = star_typing_inversion_r tt01 in
star_typing tt0 (star_typing tt1 tt2)
in
fwd, bk
| VE_Ext g t0 t1 token ->
let d1, d2 = vprop_eq_typing_inversion g t0 t1 token in
(fun _ -> d2),
(fun _ -> d1)
| VE_Fa g x u b t0 t1 d ->
let d0, d1 = vprop_equiv_typing d in
(fun fa0_typing ->
let b_typing, t0_typing = invert_forall_typing fa0_typing x in
let t1_typing = d0 t0_typing in
construct_forall_typing #g #u x b_typing t1_typing),
(fun fa1_typing ->
let b_typing, t1_typing = invert_forall_typing fa1_typing x in
let t0_typing = d1 t1_typing in
construct_forall_typing #g #u #b #t0 x b_typing t0_typing)
#push-options "--z3rlimit_factor 8 --ifuel 1 --fuel 2 --query_stats"
let bind_t (case_c1 case_c2:comp_st -> bool) =
(g:env) ->
(pre:term) ->
(e1:st_term) ->
(e2:st_term) ->
(c1:comp_st{ case_c1 c1 }) ->
(c2:comp_st{ case_c2 c2 }) ->
(px:nvar { ~ (Set.mem (snd px) (dom g)) }) ->
(d_e1:st_typing g e1 c1) ->
(d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1))) ->
(d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2) ->
(res_typing:universe_of g (comp_res c2) (comp_u c2)) ->
(post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop) ->
(bias_towards_continuation:bool) ->
T.TacH (t:st_term &
c:comp_st { st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires fun _ ->
let _, x = px in
comp_pre c1 == pre /\
None? (lookup g x) /\
(~(x `Set.mem` freevars_st e2)) /\
open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))))
(ensures fun _ _ -> True)
let mk_bind_st_st
: bind_t C_ST? C_ST?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
let inames_of (c:comp_st) : term =
match c with
| C_ST _
| C_STGhost _ -> tm_emp_inames
| C_STAtomic inames _ _ -> inames
let with_inames (c:comp_st) (i:term) =
match c with
| C_ST _ -> c
| C_STGhost sc -> C_STGhost sc
| C_STAtomic _ obs sc -> C_STAtomic i obs sc
let weaken_comp_inames (#g:env) (#e:st_term) (#c:comp_st) (d_e:st_typing g e c) (new_inames:term)
: T.Tac (c':comp_st { with_inames c new_inames == c' } &
st_typing g e c')
= match c with
| C_ST _
| C_STGhost _ -> (| c, d_e |)
| C_STAtomic inames obs sc ->
let d_e = T_Sub _ _ _ _ d_e (STS_AtomicInvs _ sc inames new_inames obs obs (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
(| with_inames c new_inames, d_e |)
let st_ghost_as_atomic (c:comp_st { C_STGhost? c }) =
C_STAtomic tm_emp_inames Neutral (st_comp_of_comp c)
let try_lift_ghost_atomic (#g:env) (#e:st_term) (#c:comp_st { C_STGhost? c }) (d:st_typing g e c)
: T.Tac (option (st_typing g e (st_ghost_as_atomic c)))
= let w = try_get_non_informative_witness g (comp_u c) (comp_res c) in
match w with
| None -> None
| Some w ->
let d = T_Lift _ _ _ _ d (Lift_Ghost_Neutral _ c w) in
Some d | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.PP.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Result.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Typing.Combinators.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | d: Pulse.Typing.st_typing g e c
-> FStar.Tactics.Effect.Tac
(Pulse.Typing.st_typing g e (Pulse.Typing.Combinators.st_ghost_as_atomic c)) | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.st_term",
"Pulse.Syntax.Base.comp_st",
"Prims.b2t",
"Pulse.Syntax.Base.uu___is_C_STGhost",
"Pulse.Typing.st_typing",
"Pulse.Typing.Env.fail_doc",
"Pulse.Typing.Combinators.st_ghost_as_atomic",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.range",
"Pulse.Syntax.Base.__proj__Mkterm__item__range",
"Prims.list",
"FStar.Stubs.Pprint.document",
"Prims.Cons",
"Prims.Nil",
"FStar.Stubs.Pprint.op_Hat_Slash_Hat",
"Pulse.PP.text",
"Pulse.PP.pp",
"Pulse.Syntax.Base.term",
"Pulse.PP.uu___44",
"Pulse.Syntax.Base.comp_res",
"FStar.Pervasives.Native.option",
"Pulse.Typing.Combinators.try_lift_ghost_atomic"
] | [] | false | true | false | false | false | let lift_ghost_atomic (#g: env) (#e: st_term) (#c: comp_st{C_STGhost? c}) (d: st_typing g e c)
: T.Tac (st_typing g e (st_ghost_as_atomic c)) =
| let w = try_lift_ghost_atomic d in
match w with
| None ->
let open Pulse.PP in
let t = comp_res c in
fail_doc g
(Some t.range)
[text "Expected a term with a non-informative (e.g., erased) type; got" ^/^ pp t]
| Some d -> d | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.cmp_to_ocmp | val cmp_to_ocmp (c: cmp) : ocmp | val cmp_to_ocmp (c: cmp) : ocmp | let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 35,
"end_line": 222,
"start_col": 0,
"start_line": 215
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: Vale.PPC64LE.QuickCodes.cmp -> Vale.PPC64LE.Decls.ocmp | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.cmp",
"Vale.PPC64LE.Machine_s.cmp_opr",
"Vale.PPC64LE.Decls.va_cmp_eq",
"Vale.PPC64LE.Decls.va_cmp_ne",
"Vale.PPC64LE.Decls.va_cmp_le",
"Vale.PPC64LE.Decls.va_cmp_ge",
"Vale.PPC64LE.Decls.va_cmp_lt",
"Vale.PPC64LE.Decls.va_cmp_gt",
"Vale.PPC64LE.Decls.ocmp"
] | [] | false | false | false | true | false | let cmp_to_ocmp (c: cmp) : ocmp =
| match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2 | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.wp | val wp
(#a: Type0)
(cs: codes)
(qcs: quickCodes a cs)
(mods: mods_t)
(k: (va_state -> a -> Type0))
(s0: va_state)
: Tot Type0 (decreases %[cs;0;qcs]) | val wp
(#a: Type0)
(cs: codes)
(qcs: quickCodes a cs)
(mods: mods_t)
(k: (va_state -> a -> Type0))
(s0: va_state)
: Tot Type0 (decreases %[cs;0;qcs]) | let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 158,
"start_col": 0,
"start_line": 111
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20" | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
cs: Vale.PPC64LE.QuickCodes.codes ->
qcs: Vale.PPC64LE.QuickCodes.quickCodes a cs ->
mods: Vale.PPC64LE.QuickCode.mods_t ->
k: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0) ->
s0: Vale.PPC64LE.Decls.va_state
-> Prims.Tot Type0 | Prims.Tot | [
"total",
""
] | [
"wp",
"wp_Seq",
"wp_Bind"
] | [
"Vale.PPC64LE.QuickCodes.codes",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.code",
"FStar.Range.range",
"Prims.string",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.Decls.va_code",
"Prims.list",
"Vale.PPC64LE.QuickCodes.label",
"Prims.l_and",
"Prims.b2t",
"Vale.PPC64LE.QuickCodes.mods_contains",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.PPC64LE.QuickCodes.wp_proc",
"Vale.PPC64LE.QuickCodes.wp_Seq",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.QuickCodes.wp_Bind",
"Vale.PPC64LE.QuickCodes.wp",
"Prims.unit",
"FStar.Monotonic.Pure.is_monotonic",
"FStar.Monotonic.Pure.as_pure_wp",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.guard_free",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.PPC64LE.QuickCodes.k_AssertBy",
"Vale.PPC64LE.QuickCodes.empty_list_is_small"
] | [
"mutual recursion"
] | false | false | false | false | true | let rec wp
(#a: Type0)
(cs: codes)
(qcs: quickCodes a cs)
(mods: mods_t)
(k: (va_state -> a -> Type0))
(s0: va_state)
: Tot Type0 (decreases %[cs;0;qcs]) =
| match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c :: cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c :: cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c :: cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
(forall (p: (unit -> GTot Type0)).
(forall (u: unit). {:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ()) ==>
label r msg (pre p))
| QLemma r msg pre post l qcs -> label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c :: cs = cs in
label r msg pre /\ (forall (g: b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0) | false |
Arith.fst | Arith.lem2 | val lem2 : x: Prims.int -> Prims.unit | let lem2 (x:int) =
assert (List.rev [1;2;3;4] == [4;3;2;1] /\ op_Multiply 2 (x + 3) == 6 + (op_Multiply 3 x) - x)
by split_arith () | {
"file_name": "examples/tactics/Arith.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 25,
"end_line": 47,
"start_col": 0,
"start_line": 45
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Arith
//
open FStar.Tactics.V2
open FStar.Tactics.Arith
open FStar.List
open FStar.Mul
let lem0 (x:int) =
assert (op_Multiply 2 (x + 3) == 6 + (op_Multiply 3 x) - x)
by (prune ""; addns "Prims")
// Can't locally define tactics
let tau1 () : Tac unit =
prune "";
FStar.Tactics.split ();
(* rev part *)
addns "FStar.List";
addns "Prims";
smt ();
(* arithmetic part *)
addns "Prims";
smt ()
let lem1 (x:int) =
assert (List.rev [1;2;3;4] == [4;3;2;1] /\ op_Multiply 2 (x + 3) == 6 + (op_Multiply 3 x) - x)
by tau1 () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Arith.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Arith.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Arith",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.int -> Prims.unit | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"FStar.Tactics.Effect.assert_by_tactic",
"Prims.l_and",
"Prims.eq2",
"Prims.list",
"FStar.List.Tot.Base.rev",
"Prims.Cons",
"Prims.Nil",
"Prims.op_Multiply",
"Prims.op_Addition",
"Prims.op_Subtraction",
"Prims.unit",
"FStar.Tactics.Arith.split_arith"
] | [] | false | false | false | true | false | let lem2 (x: int) =
| FStar.Tactics.Effect.assert_by_tactic (List.rev [1; 2; 3; 4] == [4; 3; 2; 1] /\
op_Multiply 2 (x + 3) == 6 + (op_Multiply 3 x) - x)
(fun _ ->
();
split_arith ()) | false |
|
EnumEq.fst | EnumEq.test | val test (#a: Type0) {| _: enum a |} (x y: a) : bool | val test (#a: Type0) {| _: enum a |} (x y: a) : bool | let test (#a:Type0) {|enum a|} (x y : a) : bool =
eq x y | {
"file_name": "examples/typeclasses/EnumEq.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 8,
"end_line": 29,
"start_col": 0,
"start_line": 28
} | (*
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 EnumEq
open Enum
open Eq
open FStar.Tactics.Typeclasses
(* Trying out a "class morphism", a post-facto relation between two existing classes. *)
instance enum_eq (#a:Type) (d : enum a) : deq a = {
eq = (fun (x y : a) -> toInt x = toInt y);
eq_ok = (fun (x y : a) -> inv1 x; inv1 y);
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"Eq.fst.checked",
"Enum.fst.checked"
],
"interface_file": true,
"source_file": "EnumEq.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "Eq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Enum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "Eq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Enum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": 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 | {| _: Enum.enum a |} -> x: a -> y: a -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Enum.enum",
"Eq.eq",
"EnumEq.enum_eq",
"Prims.bool"
] | [] | false | false | false | true | false | let test (#a: Type0) {| _: enum a |} (x y: a) : bool =
| eq x y | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.va_qWhile | val va_qWhile
(#a #d: Type)
(#c: code)
(mods: mods_t)
(b: cmp)
(qc: (a -> quickCode a c))
(inv: (va_state -> a -> Type0))
(dec: (va_state -> a -> d))
(g0: a)
: quickCode a (While (cmp_to_ocmp b) c) | val va_qWhile
(#a #d: Type)
(#c: code)
(mods: mods_t)
(b: cmp)
(qc: (a -> quickCode a c))
(inv: (va_state -> a -> Type0))
(dec: (va_state -> a -> d))
(g0: a)
: quickCode a (While (cmp_to_ocmp b) c) | let va_qWhile
(#a #d:Type) (#c:code) (mods:mods_t) (b:cmp) (qc:a -> quickCode a c) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a)
: quickCode a (While (cmp_to_ocmp b) c) =
QProc (While (cmp_to_ocmp b) c) mods (wp_While b qc mods inv dec g0)
(qWhile_proof b qc mods inv dec g0) | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 39,
"end_line": 306,
"start_col": 0,
"start_line": 301
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1
[@va_qattr]
let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1))
[@va_qattr]
let wp_While
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Type0 =
inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
// REVIEW: we could get a better WP with forall (...state components...) instead of forall (s1:va_state)
(forall (s1:va_state) (g1:a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k)
val qWhile_proof
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k)
(ensures fun (sM, f0, g) ->
eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mods: Vale.PPC64LE.QuickCode.mods_t ->
b: Vale.PPC64LE.QuickCodes.cmp ->
qc: (_: a -> Vale.PPC64LE.QuickCode.quickCode a c) ->
inv: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0) ->
dec: (_: Vale.PPC64LE.Decls.va_state -> _: a -> d) ->
g0: a
-> Vale.PPC64LE.QuickCode.quickCode a
(Vale.PPC64LE.Machine_s.While (Vale.PPC64LE.QuickCodes.cmp_to_ocmp b) c) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.QuickCodes.cmp",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCode.QProc",
"Vale.PPC64LE.Machine_s.While",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.QuickCodes.cmp_to_ocmp",
"Vale.PPC64LE.QuickCodes.wp_While",
"Vale.PPC64LE.QuickCodes.qWhile_proof"
] | [] | false | false | false | false | false | let va_qWhile
(#a #d: Type)
(#c: code)
(mods: mods_t)
(b: cmp)
(qc: (a -> quickCode a c))
(inv: (va_state -> a -> Type0))
(dec: (va_state -> a -> d))
(g0: a)
: quickCode a (While (cmp_to_ocmp b) c) =
| QProc (While (cmp_to_ocmp b) c)
mods
(wp_While b qc mods inv dec g0)
(qWhile_proof b qc mods inv dec g0) | false |
Vale.Poly1305.Spec_s.fst | Vale.Poly1305.Spec_s.poly1305_hash_blocks | val poly1305_hash_blocks (h pad r: int) (inp: (int -> nat128)) (k: nat) : int | val poly1305_hash_blocks (h pad r: int) (inp: (int -> nat128)) (k: nat) : int | let rec poly1305_hash_blocks (h pad r:int) (inp:int -> nat128) (k:nat) : int =
if k = 0 then h
else
let hh = poly1305_hash_blocks h pad r inp (k - 1) in
modp ((hh + pad + inp (k - 1)) * r) | {
"file_name": "vale/specs/crypto/Vale.Poly1305.Spec_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 39,
"end_line": 19,
"start_col": 0,
"start_line": 15
} | module Vale.Poly1305.Spec_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
[@"opaque_to_smt"]
let modp (x:int) : int =
x % (pow2_128 * 4 - 5)
[@"opaque_to_smt"]
let mod2_128 (x:int) : int =
x % pow2_128 | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Poly1305.Spec_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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 |
h: Prims.int ->
pad: Prims.int ->
r: Prims.int ->
inp: (_: Prims.int -> Vale.Def.Words_s.nat128) ->
k: Prims.nat
-> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.Def.Words_s.nat128",
"Prims.nat",
"Prims.op_Equality",
"Prims.bool",
"Vale.Poly1305.Spec_s.modp",
"FStar.Mul.op_Star",
"Prims.op_Addition",
"Prims.op_Subtraction",
"Vale.Poly1305.Spec_s.poly1305_hash_blocks"
] | [
"recursion"
] | false | false | false | true | false | let rec poly1305_hash_blocks (h pad r: int) (inp: (int -> nat128)) (k: nat) : int =
| if k = 0
then h
else
let hh = poly1305_hash_blocks h pad r inp (k - 1) in
modp ((hh + pad + inp (k - 1)) * r) | false |
Vale.Poly1305.Spec_s.fst | Vale.Poly1305.Spec_s.poly1305_hash_all | val poly1305_hash_all (h: int) (key_r key_s: nat128) (inp: (int -> nat128)) (len: nat) : int | val poly1305_hash_all (h: int) (key_r key_s: nat128) (inp: (int -> nat128)) (len: nat) : int | let poly1305_hash_all (h:int) (key_r key_s:nat128) (inp:int -> nat128) (len:nat) : int =
let nBlocks = len / 16 in
let nExtra = len % 16 in
let hBlocks = poly1305_hash_blocks h pow2_128 (make_r key_r) inp nBlocks in
if nExtra = 0 then
mod2_128 (hBlocks + key_s)
else
let padLast = pow2 (nExtra * 8) in
let hLast = modp ((hBlocks + padLast + inp nBlocks % padLast) * (make_r key_r)) in
mod2_128 (hLast + key_s) | {
"file_name": "vale/specs/crypto/Vale.Poly1305.Spec_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 33,
"start_col": 0,
"start_line": 24
} | module Vale.Poly1305.Spec_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
[@"opaque_to_smt"]
let modp (x:int) : int =
x % (pow2_128 * 4 - 5)
[@"opaque_to_smt"]
let mod2_128 (x:int) : int =
x % pow2_128
let rec poly1305_hash_blocks (h pad r:int) (inp:int -> nat128) (k:nat) : int =
if k = 0 then h
else
let hh = poly1305_hash_blocks h pad r inp (k - 1) in
modp ((hh + pad + inp (k - 1)) * r)
let make_r (key_r:nat128) : nat128 =
iand key_r 0x0ffffffc0ffffffc0ffffffc0fffffff | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Poly1305.Spec_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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 |
h: Prims.int ->
key_r: Vale.Def.Words_s.nat128 ->
key_s: Vale.Def.Words_s.nat128 ->
inp: (_: Prims.int -> Vale.Def.Words_s.nat128) ->
len: Prims.nat
-> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.Def.Words_s.nat128",
"Prims.nat",
"Prims.op_Equality",
"Vale.Poly1305.Spec_s.mod2_128",
"Prims.op_Addition",
"Prims.bool",
"Vale.Poly1305.Spec_s.modp",
"FStar.Mul.op_Star",
"Prims.op_Modulus",
"Vale.Poly1305.Spec_s.make_r",
"Prims.pos",
"Prims.pow2",
"Vale.Poly1305.Spec_s.poly1305_hash_blocks",
"Vale.Def.Words_s.pow2_128",
"Prims.op_Division"
] | [] | false | false | false | true | false | let poly1305_hash_all (h: int) (key_r key_s: nat128) (inp: (int -> nat128)) (len: nat) : int =
| let nBlocks = len / 16 in
let nExtra = len % 16 in
let hBlocks = poly1305_hash_blocks h pow2_128 (make_r key_r) inp nBlocks in
if nExtra = 0
then mod2_128 (hBlocks + key_s)
else
let padLast = pow2 (nExtra * 8) in
let hLast = modp ((hBlocks + padLast + inp nBlocks % padLast) * (make_r key_r)) in
mod2_128 (hLast + key_s) | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.valid_cmp | val valid_cmp (c: cmp) (s: va_state) : Type0 | val valid_cmp (c: cmp) (s: va_state) : Type0 | let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 232,
"start_col": 0,
"start_line": 225
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2 | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: Vale.PPC64LE.QuickCodes.cmp -> s: Vale.PPC64LE.Decls.va_state -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.cmp",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.Machine_s.cmp_opr",
"Prims.b2t",
"Vale.PPC64LE.Machine_s.valid_first_cmp_opr"
] | [] | false | false | false | true | true | let valid_cmp (c: cmp) (s: va_state) : Type0 =
| match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1 | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_quad32_of_nat32s | val lemma_quad32_of_nat32s (a0 a1 a2 a3:nat32) : Lemma
(Mkfour a0 a1 a2 a3 == to_quad32 (poly128_of_nat32s a0 a1 a2 a3)) | val lemma_quad32_of_nat32s (a0 a1 a2 a3:nat32) : Lemma
(Mkfour a0 a1 a2 a3 == to_quad32 (poly128_of_nat32s a0 a1 a2 a3)) | let lemma_quad32_of_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_quad32_vec_equal (Mkfour a0 a1 a2 a3) (to_quad32 a) | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 59,
"end_line": 107,
"start_col": 0,
"start_line": 103
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n
let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x
let of_nat32_zero =
lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero
let of_nat32_ones =
lemma_bitwise_all ();
lemma_to_nat 32 (ones 32) 0xffffffff
let of_nat32_eq a b =
lemma_of_nat_of_uint 32 a;
lemma_of_nat_of_uint 32 b;
lemma_to_of_uint 32 a;
lemma_to_of_uint 32 b;
()
let of_nat32_xor a b =
lemma_bitwise_all ();
lemma_ixor_nth_all 32;
lemma_equal (of_nat32 a +. of_nat32 b) (of_nat32 (ixor a b))
let of_nat32_and a b =
lemma_bitwise_all ();
lemma_iand_nth_all 32;
lemma_equal (poly_and (of_nat32 a) (of_nat32 b)) (of_nat32 (iand a b))
let lemma_poly128_extract_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
lemma_bitwise_all ();
lemma_equal (of_nat32 a0) (mask a 32);
lemma_equal (of_nat32 a1) (mask (shift a (-32)) 32);
lemma_equal (of_nat32 a2) (mask (shift a (-64)) 32);
lemma_equal (of_nat32 a3) (shift a (-96));
() | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 |
a0: Vale.Def.Types_s.nat32 ->
a1: Vale.Def.Types_s.nat32 ->
a2: Vale.Def.Types_s.nat32 ->
a3: Vale.Def.Types_s.nat32
-> FStar.Pervasives.Lemma
(ensures
Vale.Def.Words_s.Mkfour a0 a1 a2 a3 ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2.Bits.poly128_of_nat32s a0 a1 a2 a3)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Types_s.nat32",
"Vale.Arch.TypesNative.lemma_quad32_vec_equal",
"Vale.Def.Words_s.Mkfour",
"Vale.Math.Poly2.Bits_s.to_quad32",
"Prims.unit",
"Vale.Math.Poly2.Lemmas.lemma_bitwise_all",
"Vale.Math.Poly2.Bits_s.reveal_to_quad32",
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2.Bits.poly128_of_nat32s"
] | [] | true | false | true | false | false | let lemma_quad32_of_nat32s a0 a1 a2 a3 =
| let a = poly128_of_nat32s a0 a1 a2 a3 in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_quad32_vec_equal (Mkfour a0 a1 a2 a3) (to_quad32 a) | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.wp_sound_code_pre | val wp_sound_code_pre
(#a: Type0)
(#c: code)
(qc: quickCode a c)
(s0: va_state)
(k: (s0': va_state{s0 == s0'} -> va_state -> a -> Type0))
: Type0 | val wp_sound_code_pre
(#a: Type0)
(#c: code)
(qc: quickCode a c)
(s0: va_state)
(k: (s0': va_state{s0 == s0'} -> va_state -> a -> Type0))
: Type0 | let wp_sound_code_pre (#a:Type0) (#c:code) (qc:quickCode a c) (s0:va_state) (k:(s0':va_state{s0 == s0'}) -> va_state -> a -> Type0) : Type0 =
forall
(ok:bool)
(regs:Regs.t)
(vecs:Vecs.t)
(cr0:cr0_t)
(xer:xer_t)
//(mem:vale_full_heap) // splitting mem into its components makes the VCs slightly cleaner:
(mem_layout:vale_heap_layout)
(mem_heap:vale_heap)
(mem_heaplets:vale_heaplets)
(stack:machine_stack)
(stackTaint:memtaint)
.
let mem = {
vf_layout = mem_layout;
vf_heap = mem_heap;
vf_heaplets = mem_heaplets;
} in
let s0' = {
ok = ok;
regs = regs;
vecs = vecs;
cr0 = cr0;
xer = xer;
ms_heap = coerce mem;
ms_stack = stack;
ms_stackTaint = stackTaint
} in
s0 == s0' ==> QProc?.wp qc (state_eta s0') (k (state_eta s0')) | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 66,
"end_line": 405,
"start_col": 7,
"start_line": 376
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1
[@va_qattr]
let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1))
[@va_qattr]
let wp_While
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Type0 =
inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
// REVIEW: we could get a better WP with forall (...state components...) instead of forall (s1:va_state)
(forall (s1:va_state) (g1:a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k)
val qWhile_proof
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k)
(ensures fun (sM, f0, g) ->
eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qWhile
(#a #d:Type) (#c:code) (mods:mods_t) (b:cmp) (qc:a -> quickCode a c) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a)
: quickCode a (While (cmp_to_ocmp b) c) =
QProc (While (cmp_to_ocmp b) c) mods (wp_While b qc mods inv dec g0)
(qWhile_proof b qc mods inv dec g0)
///// Assert, Assume, AssertBy
let tAssertLemma (p:Type0) = unit -> Lemma (requires p) (ensures p)
val qAssertLemma (p:Type0) : tAssertLemma p
[@va_qattr]
let va_qAssert (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg e (fun () -> e) (qAssertLemma e) qcs
let tAssumeLemma (p:Type0) = unit -> Lemma (requires True) (ensures p)
val qAssumeLemma (p:Type0) : tAssumeLemma p
[@va_qattr]
let va_qAssume (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg True (fun () -> e) (qAssumeLemma e) qcs
let tAssertSquashLemma (p:Type0) = unit -> Ghost (squash p) (requires p) (ensures fun () -> p)
val qAssertSquashLemma (p:Type0) : tAssertSquashLemma p
[@va_qattr]
let va_qAssertSquash
(#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:squash e -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QGhost (squash e) r msg e (fun () -> e) (qAssertSquashLemma e) qcs
//let tAssertByLemma (#a:Type) (p:Type0) (qcs:quickCodes a []) (mods:mods_t) (s0:state) =
// unit -> Lemma (requires t_require s0 /\ wp [] qcs mods (fun _ _ -> p) s0) (ensures p)
//val qAssertByLemma (#a:Type) (p:Type0) (qcs:quickCodes a []) (mods:mods_t) (s0:state) : tAssertByLemma p qcs mods s0
//
//[@va_qattr]
//let va_qAssertBy (#a:Type) (#cs:codes) (mods:mods_t) (r:range) (msg:string) (p:Type0) (qcsBy:quickCodes unit []) (s0:state) (qcsTail:quickCodes a cs) : quickCodes a cs =
// QLemma r msg (t_require s0 /\ wp [] qcsBy mods (fun _ _ -> p) s0) (fun () -> p) (qAssertByLemma p qcsBy mods s0) qcsTail
[@va_qattr]
let va_qAssertBy (#a:Type) (#cs:codes) (r:range) (msg:string) (p:Type0) (qcsBy:quickCodes unit []) (qcsTail:quickCodes a cs) : quickCodes a cs =
QAssertBy r msg p qcsBy qcsTail
///// Code
val wp_sound_code (#a:Type0) (c:code) (qc:quickCode a c) (k:va_state -> a -> Type0) (s0:va_state) :
Ghost (va_state & fuel & a)
(requires t_require s0 /\ QProc?.wp qc s0 k)
(ensures fun (sN, fN, gN) -> eval_code c s0 fN sN /\ update_state_mods qc.mods sN s0 == sN /\ state_inv sN /\ k sN gN)
[@va_qattr]
let state_match (s0:va_state) (s1:va_state) : Type0 =
s0.ok == s1.ok /\
Regs.equal s0.regs s1.regs /\
Vecs.equal s0.vecs s1.vecs /\
s0.cr0 == s1.cr0 /\
s0.xer == s1.xer /\
s0.ms_heap == s1.ms_heap /\
s0.ms_stack == s1.ms_stack /\
s0.ms_stackTaint == s1.ms_stackTaint
val lemma_state_match (s0:va_state) (s1:va_state) : Lemma
(requires state_match s0 s1)
(ensures state_eq s0 s1)
[@va_qattr]
let va_state_match (s0:va_state) (s1:va_state) : Pure Type0
(requires True)
(ensures fun b -> b ==> state_eq s0 s1)
=
FStar.Classical.move_requires (lemma_state_match s0) s1;
state_match s0 s1 | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
qc: Vale.PPC64LE.QuickCode.quickCode a c ->
s0: Vale.PPC64LE.Decls.va_state ->
k:
(s0': Vale.PPC64LE.Decls.va_state{s0 == s0'} -> _: Vale.PPC64LE.Decls.va_state -> _: a
-> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.Decls.va_state",
"Prims.eq2",
"Prims.l_Forall",
"Prims.bool",
"Vale.PPC64LE.Regs.t",
"Vale.PPC64LE.Vecs.t",
"Vale.PPC64LE.Machine_s.cr0_t",
"Vale.PPC64LE.Machine_s.xer_t",
"Vale.Arch.HeapImpl.vale_heap_layout",
"Vale.PPC64LE.Decls.vale_heap",
"Vale.Arch.HeapImpl.vale_heaplets",
"Vale.PPC64LE.Machine_s.machine_stack",
"Vale.PPC64LE.Memory.memtaint",
"Prims.l_imp",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__wp",
"Vale.PPC64LE.State.state_eta",
"Vale.PPC64LE.Machine_s.Mkstate",
"Vale.PPC64LE.Decls.coerce",
"Vale.Arch.Heap.heap_impl",
"Vale.Arch.HeapImpl.vale_full_heap",
"Vale.Arch.HeapImpl.Mkvale_full_heap"
] | [] | false | false | false | false | true | let wp_sound_code_pre
(#a: Type0)
(#c: code)
(qc: quickCode a c)
(s0: va_state)
(k: (s0': va_state{s0 == s0'} -> va_state -> a -> Type0))
: Type0 =
| forall (ok: bool) (regs: Regs.t) (vecs: Vecs.t) (cr0: cr0_t) (xer: xer_t)
(mem_layout: vale_heap_layout) (mem_heap: vale_heap) (mem_heaplets: vale_heaplets)
(stack: machine_stack) (stackTaint: memtaint).
let mem = { vf_layout = mem_layout; vf_heap = mem_heap; vf_heaplets = mem_heaplets } in
let s0' =
{
ok = ok;
regs = regs;
vecs = vecs;
cr0 = cr0;
xer = xer;
ms_heap = coerce mem;
ms_stack = stack;
ms_stackTaint = stackTaint
}
in
s0 == s0' ==> QProc?.wp qc (state_eta s0') (k (state_eta s0')) | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.wp_Bind | val wp_Bind
(#a #b: Type0)
(cs: codes)
(qcs: (va_state -> a -> GTot (quickCodes b cs)))
(mods: mods_t)
(k: (va_state -> b -> Type0))
: Tot (wp_Bind_t a) (decreases %[cs;1;qcs]) | val wp_Bind
(#a #b: Type0)
(cs: codes)
(qcs: (va_state -> a -> GTot (quickCodes b cs)))
(mods: mods_t)
(k: (va_state -> b -> Type0))
: Tot (wp_Bind_t a) (decreases %[cs;1;qcs]) | let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 158,
"start_col": 0,
"start_line": 111
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20" | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
cs: Vale.PPC64LE.QuickCodes.codes ->
qcs:
(_: Vale.PPC64LE.Decls.va_state -> _: a
-> Prims.GTot (Vale.PPC64LE.QuickCodes.quickCodes b cs)) ->
mods: Vale.PPC64LE.QuickCode.mods_t ->
k: (_: Vale.PPC64LE.Decls.va_state -> _: b -> Type0)
-> Prims.Tot (Vale.PPC64LE.QuickCodes.wp_Bind_t a) | Prims.Tot | [
"total",
""
] | [
"wp",
"wp_Seq",
"wp_Bind"
] | [
"Vale.PPC64LE.QuickCodes.codes",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCodes.wp",
"Vale.PPC64LE.QuickCodes.wp_Bind_t"
] | [
"mutual recursion"
] | false | false | false | false | false | let rec wp_Bind
(#a #b: Type0)
(cs: codes)
(qcs: (va_state -> a -> GTot (quickCodes b cs)))
(mods: mods_t)
(k: (va_state -> b -> Type0))
: Tot (wp_Bind_t a) (decreases %[cs;1;qcs]) =
| let f s0 g = wp cs (qcs s0 g) mods k s0 in
f | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.wp_Seq | val wp_Seq
(#a #b: Type0)
(cs: codes)
(qcs: quickCodes b cs)
(mods: mods_t)
(k: (va_state -> b -> Type0))
: Tot (wp_Seq_t a) (decreases %[cs;1;qcs]) | val wp_Seq
(#a #b: Type0)
(cs: codes)
(qcs: quickCodes b cs)
(mods: mods_t)
(k: (va_state -> b -> Type0))
: Tot (wp_Seq_t a) (decreases %[cs;1;qcs]) | let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 158,
"start_col": 0,
"start_line": 111
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20" | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
cs: Vale.PPC64LE.QuickCodes.codes ->
qcs: Vale.PPC64LE.QuickCodes.quickCodes b cs ->
mods: Vale.PPC64LE.QuickCode.mods_t ->
k: (_: Vale.PPC64LE.Decls.va_state -> _: b -> Type0)
-> Prims.Tot (Vale.PPC64LE.QuickCodes.wp_Seq_t a) | Prims.Tot | [
"total",
""
] | [
"wp",
"wp_Seq",
"wp_Bind"
] | [
"Vale.PPC64LE.QuickCodes.codes",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.Machine_s.state",
"Prims.l_or",
"Prims.precedes",
"Prims.list",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Prims.l_and",
"Prims.op_Equals_Equals_Equals",
"Prims.int",
"Vale.PPC64LE.QuickCodes.wp",
"Vale.PPC64LE.QuickCodes.wp_Seq_t"
] | [
"mutual recursion"
] | false | false | false | false | false | let rec wp_Seq
(#a #b: Type0)
(cs: codes)
(qcs: quickCodes b cs)
(mods: mods_t)
(k: (va_state -> b -> Type0))
: Tot (wp_Seq_t a) (decreases %[cs;1;qcs]) =
| let f s0 _ = wp cs qcs mods k s0 in
f | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.va_state_match | val va_state_match (s0 s1: va_state)
: Pure Type0 (requires True) (ensures fun b -> b ==> state_eq s0 s1) | val va_state_match (s0 s1: va_state)
: Pure Type0 (requires True) (ensures fun b -> b ==> state_eq s0 s1) | let va_state_match (s0:va_state) (s1:va_state) : Pure Type0
(requires True)
(ensures fun b -> b ==> state_eq s0 s1)
=
FStar.Classical.move_requires (lemma_state_match s0) s1;
state_match s0 s1 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 19,
"end_line": 373,
"start_col": 0,
"start_line": 368
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1
[@va_qattr]
let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1))
[@va_qattr]
let wp_While
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Type0 =
inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
// REVIEW: we could get a better WP with forall (...state components...) instead of forall (s1:va_state)
(forall (s1:va_state) (g1:a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k)
val qWhile_proof
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k)
(ensures fun (sM, f0, g) ->
eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qWhile
(#a #d:Type) (#c:code) (mods:mods_t) (b:cmp) (qc:a -> quickCode a c) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a)
: quickCode a (While (cmp_to_ocmp b) c) =
QProc (While (cmp_to_ocmp b) c) mods (wp_While b qc mods inv dec g0)
(qWhile_proof b qc mods inv dec g0)
///// Assert, Assume, AssertBy
let tAssertLemma (p:Type0) = unit -> Lemma (requires p) (ensures p)
val qAssertLemma (p:Type0) : tAssertLemma p
[@va_qattr]
let va_qAssert (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg e (fun () -> e) (qAssertLemma e) qcs
let tAssumeLemma (p:Type0) = unit -> Lemma (requires True) (ensures p)
val qAssumeLemma (p:Type0) : tAssumeLemma p
[@va_qattr]
let va_qAssume (#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:quickCodes a cs) : quickCodes a cs =
QLemma r msg True (fun () -> e) (qAssumeLemma e) qcs
let tAssertSquashLemma (p:Type0) = unit -> Ghost (squash p) (requires p) (ensures fun () -> p)
val qAssertSquashLemma (p:Type0) : tAssertSquashLemma p
[@va_qattr]
let va_qAssertSquash
(#a:Type) (#cs:codes) (r:range) (msg:string) (e:Type0) (qcs:squash e -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QGhost (squash e) r msg e (fun () -> e) (qAssertSquashLemma e) qcs
//let tAssertByLemma (#a:Type) (p:Type0) (qcs:quickCodes a []) (mods:mods_t) (s0:state) =
// unit -> Lemma (requires t_require s0 /\ wp [] qcs mods (fun _ _ -> p) s0) (ensures p)
//val qAssertByLemma (#a:Type) (p:Type0) (qcs:quickCodes a []) (mods:mods_t) (s0:state) : tAssertByLemma p qcs mods s0
//
//[@va_qattr]
//let va_qAssertBy (#a:Type) (#cs:codes) (mods:mods_t) (r:range) (msg:string) (p:Type0) (qcsBy:quickCodes unit []) (s0:state) (qcsTail:quickCodes a cs) : quickCodes a cs =
// QLemma r msg (t_require s0 /\ wp [] qcsBy mods (fun _ _ -> p) s0) (fun () -> p) (qAssertByLemma p qcsBy mods s0) qcsTail
[@va_qattr]
let va_qAssertBy (#a:Type) (#cs:codes) (r:range) (msg:string) (p:Type0) (qcsBy:quickCodes unit []) (qcsTail:quickCodes a cs) : quickCodes a cs =
QAssertBy r msg p qcsBy qcsTail
///// Code
val wp_sound_code (#a:Type0) (c:code) (qc:quickCode a c) (k:va_state -> a -> Type0) (s0:va_state) :
Ghost (va_state & fuel & a)
(requires t_require s0 /\ QProc?.wp qc s0 k)
(ensures fun (sN, fN, gN) -> eval_code c s0 fN sN /\ update_state_mods qc.mods sN s0 == sN /\ state_inv sN /\ k sN gN)
[@va_qattr]
let state_match (s0:va_state) (s1:va_state) : Type0 =
s0.ok == s1.ok /\
Regs.equal s0.regs s1.regs /\
Vecs.equal s0.vecs s1.vecs /\
s0.cr0 == s1.cr0 /\
s0.xer == s1.xer /\
s0.ms_heap == s1.ms_heap /\
s0.ms_stack == s1.ms_stack /\
s0.ms_stackTaint == s1.ms_stackTaint
val lemma_state_match (s0:va_state) (s1:va_state) : Lemma
(requires state_match s0 s1)
(ensures state_eq s0 s1) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s0: Vale.PPC64LE.Decls.va_state -> s1: Vale.PPC64LE.Decls.va_state -> Prims.Pure Type0 | Prims.Pure | [] | [] | [
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.state_match",
"Prims.unit",
"FStar.Classical.move_requires",
"Vale.PPC64LE.State.state_eq",
"Vale.PPC64LE.QuickCodes.lemma_state_match",
"Prims.l_True",
"Prims.l_imp"
] | [] | false | false | false | false | true | let va_state_match (s0 s1: va_state)
: Pure Type0 (requires True) (ensures fun b -> b ==> state_eq s0 s1) =
| FStar.Classical.move_requires (lemma_state_match s0) s1;
state_match s0 s1 | false |
Pulse.Checker.Prover.Base.fsti | Pulse.Checker.Prover.Base.vprop_typing | val vprop_typing : g: Pulse.Typing.Env.env -> t: Pulse.Syntax.Base.term -> Type0 | let vprop_typing (g:env) (t:term) = tot_typing g t tm_vprop | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Base.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 59,
"end_line": 28,
"start_col": 0,
"start_line": 28
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Checker.Prover.Base
open Pulse.Syntax
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Base
module T = FStar.Tactics.V2
module PS = Pulse.Checker.Prover.Substs | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Checker.Prover.Base.fsti"
} | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | g: Pulse.Typing.Env.env -> t: Pulse.Syntax.Base.term -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.term",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.tm_vprop"
] | [] | false | false | false | true | true | let vprop_typing (g: env) (t: term) =
| tot_typing g t tm_vprop | false |
|
Pulse.Typing.Combinators.fst | Pulse.Typing.Combinators.weaken_comp_inames | val weaken_comp_inames
(#g: env)
(#e: st_term)
(#c: comp_st)
(d_e: st_typing g e c)
(new_inames: term)
: T.Tac (c': comp_st{with_inames c new_inames == c'} & st_typing g e c') | val weaken_comp_inames
(#g: env)
(#e: st_term)
(#c: comp_st)
(d_e: st_typing g e c)
(new_inames: term)
: T.Tac (c': comp_st{with_inames c new_inames == c'} & st_typing g e c') | let weaken_comp_inames (#g:env) (#e:st_term) (#c:comp_st) (d_e:st_typing g e c) (new_inames:term)
: T.Tac (c':comp_st { with_inames c new_inames == c' } &
st_typing g e c')
= match c with
| C_ST _
| C_STGhost _ -> (| c, d_e |)
| C_STAtomic inames obs sc ->
let d_e = T_Sub _ _ _ _ d_e (STS_AtomicInvs _ sc inames new_inames obs obs (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
(| with_inames c new_inames, d_e |) | {
"file_name": "lib/steel/pulse/Pulse.Typing.Combinators.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 41,
"end_line": 200,
"start_col": 0,
"start_line": 191
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Typing.Combinators
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
assume
val invert_forall_typing
(#g #u #b #body:_)
(d:tot_typing g (tm_forall_sl u b body) tm_vprop)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
: GTot (
tot_typing g b.binder_ty (tm_type u) &
tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop
)
assume
val construct_forall_typing
(#g #u #b #body:_)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
(dt:tot_typing g b.binder_ty (tm_type u))
(db:tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop)
: GTot (tot_typing g (tm_forall_sl u b body) tm_vprop)
let rec vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1)
: GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop))
(decreases v)
= match v with
| VE_Refl _ _ -> (fun x -> x), (fun x -> x)
| VE_Sym _ _ _ v' ->
let f, g = vprop_equiv_typing v' in
g, f
| VE_Trans g t0 t2 t1 v02 v21 ->
let f02, f20 = vprop_equiv_typing v02 in
let f21, f12 = vprop_equiv_typing v21 in
(fun x -> f21 (f02 x)),
(fun x -> f20 (f12 x))
| VE_Ctxt g s0 s1 s0' s1' v0 v1 ->
let f0, f0' = vprop_equiv_typing v0 in
let f1, f1' = vprop_equiv_typing v1 in
let ff (x:tot_typing g (tm_star s0 s1) tm_vprop)
: tot_typing g (tm_star s0' s1') tm_vprop
= let s0_typing = star_typing_inversion_l x in
let s1_typing = star_typing_inversion_r x in
let s0'_typing, s1'_typing = f0 s0_typing, f1 s1_typing in
star_typing s0'_typing s1'_typing
in
let gg (x:tot_typing g (tm_star s0' s1') tm_vprop)
: tot_typing g (tm_star s0 s1) tm_vprop
= let s0'_typing = star_typing_inversion_l x in
let s1'_typing = star_typing_inversion_r x in
star_typing (f0' s0'_typing) (f1' s1'_typing)
in
ff, gg
| VE_Unit g t ->
let fwd (x:tot_typing g (tm_star tm_emp t) tm_vprop)
: tot_typing g t tm_vprop
= let r = star_typing_inversion_r x in
r
in
let bk (x:tot_typing g t tm_vprop)
: tot_typing g (tm_star tm_emp t) tm_vprop
= star_typing emp_typing x
in
fwd, bk
| VE_Comm g t0 t1 ->
let f t0 t1 (x:tot_typing g (tm_star t0 t1) tm_vprop)
: tot_typing g (tm_star t1 t0) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt1 = star_typing_inversion_r x in
star_typing tt1 tt0
in
f t0 t1, f t1 t0
| VE_Assoc g t0 t1 t2 ->
let fwd (x:tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop)
: tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt12 = star_typing_inversion_r x in
let tt1 = star_typing_inversion_l tt12 in
let tt2 = star_typing_inversion_r tt12 in
star_typing (star_typing tt0 tt1) tt2
in
let bk (x : tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop)
: tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop
= let tt01 = star_typing_inversion_l x in
let tt2 = star_typing_inversion_r x in
let tt0 = star_typing_inversion_l tt01 in
let tt1 = star_typing_inversion_r tt01 in
star_typing tt0 (star_typing tt1 tt2)
in
fwd, bk
| VE_Ext g t0 t1 token ->
let d1, d2 = vprop_eq_typing_inversion g t0 t1 token in
(fun _ -> d2),
(fun _ -> d1)
| VE_Fa g x u b t0 t1 d ->
let d0, d1 = vprop_equiv_typing d in
(fun fa0_typing ->
let b_typing, t0_typing = invert_forall_typing fa0_typing x in
let t1_typing = d0 t0_typing in
construct_forall_typing #g #u x b_typing t1_typing),
(fun fa1_typing ->
let b_typing, t1_typing = invert_forall_typing fa1_typing x in
let t0_typing = d1 t1_typing in
construct_forall_typing #g #u #b #t0 x b_typing t0_typing)
#push-options "--z3rlimit_factor 8 --ifuel 1 --fuel 2 --query_stats"
let bind_t (case_c1 case_c2:comp_st -> bool) =
(g:env) ->
(pre:term) ->
(e1:st_term) ->
(e2:st_term) ->
(c1:comp_st{ case_c1 c1 }) ->
(c2:comp_st{ case_c2 c2 }) ->
(px:nvar { ~ (Set.mem (snd px) (dom g)) }) ->
(d_e1:st_typing g e1 c1) ->
(d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1))) ->
(d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2) ->
(res_typing:universe_of g (comp_res c2) (comp_u c2)) ->
(post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop) ->
(bias_towards_continuation:bool) ->
T.TacH (t:st_term &
c:comp_st { st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires fun _ ->
let _, x = px in
comp_pre c1 == pre /\
None? (lookup g x) /\
(~(x `Set.mem` freevars_st e2)) /\
open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))))
(ensures fun _ _ -> True)
let mk_bind_st_st
: bind_t C_ST? C_ST?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
let inames_of (c:comp_st) : term =
match c with
| C_ST _
| C_STGhost _ -> tm_emp_inames
| C_STAtomic inames _ _ -> inames
let with_inames (c:comp_st) (i:term) =
match c with
| C_ST _ -> c
| C_STGhost sc -> C_STGhost sc
| C_STAtomic _ obs sc -> C_STAtomic i obs sc | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.PP.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Result.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Typing.Combinators.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | d_e: Pulse.Typing.st_typing g e c -> new_inames: Pulse.Syntax.Base.term
-> FStar.Tactics.Effect.Tac
(Prims.dtuple2 (c':
Pulse.Syntax.Base.comp_st{Pulse.Typing.Combinators.with_inames c new_inames == c'})
(fun c' -> Pulse.Typing.st_typing g e c')) | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.st_term",
"Pulse.Syntax.Base.comp_st",
"Pulse.Typing.st_typing",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.st_comp",
"Prims.Mkdtuple2",
"Prims.eq2",
"Pulse.Syntax.Base.comp",
"Pulse.Typing.Combinators.with_inames",
"Prims.dtuple2",
"Pulse.Syntax.Base.observability",
"Pulse.Syntax.Base.C_STAtomic",
"Pulse.Typing.T_Sub",
"Pulse.Typing.st_sub",
"Pulse.Typing.STS_AtomicInvs",
"Pulse.Typing.prop_validity",
"Pulse.Typing.tm_inames_subset",
"Pulse.Checker.Pure.check_prop_validity",
"Pulse.Typing.tm_inames_subset_typing"
] | [] | false | true | false | false | false | let weaken_comp_inames
(#g: env)
(#e: st_term)
(#c: comp_st)
(d_e: st_typing g e c)
(new_inames: term)
: T.Tac (c': comp_st{with_inames c new_inames == c'} & st_typing g e c') =
| match c with
| C_ST _ | C_STGhost _ -> (| c, d_e |)
| C_STAtomic inames obs sc ->
let d_e =
T_Sub _
_
_
_
d_e
(STS_AtomicInvs _
sc
inames
new_inames
obs
obs
(check_prop_validity _ _ (tm_inames_subset_typing _ _ _)))
in
(| with_inames c new_inames, d_e |) | false |
Pulse.Checker.Prover.Base.fsti | Pulse.Checker.Prover.Base.is_terminal | val is_terminal : st: Pulse.Checker.Prover.Base.prover_state preamble -> Prims.logical | let is_terminal (#preamble:_) (st:prover_state preamble) =
st.unsolved == [] | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Base.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 19,
"end_line": 109,
"start_col": 0,
"start_line": 108
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Checker.Prover.Base
open Pulse.Syntax
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Base
module T = FStar.Tactics.V2
module PS = Pulse.Checker.Prover.Substs
let vprop_typing (g:env) (t:term) = tot_typing g t tm_vprop
//
// Scaffolding for adding elims
//
// Given a function f : vprop -> T.Tac bool that decides whether a vprop
// should be elim-ed,
// and an mk function to create the elim term, comp, and typing,
// add_elims will create a continuation_elaborator
//
type mk_t =
#g:env ->
#v:vprop ->
tot_typing g v tm_vprop ->
T.Tac (option (x:ppname &
t:st_term &
c:comp { stateful_comp c /\ comp_pre c == v } &
st_typing g t c))
val add_elims (#g:env) (#ctxt:term) (#frame:term)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(ctxt_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame))
//
// Prover state
//
noeq type preamble = {
g0 : env;
ctxt : vprop;
frame : vprop;
ctxt_frame_typing : vprop_typing g0 (tm_star ctxt frame);
goals : vprop;
}
let op_Array_Access (ss:PS.ss_t) (t:term) =
PS.ss_term t ss
let op_Star = tm_star
noeq
type prover_state (preamble:preamble) = {
pg : g:env { g `env_extends` preamble.g0 };
remaining_ctxt : list vprop;
remaining_ctxt_frame_typing : vprop_typing pg (list_as_vprop remaining_ctxt * preamble.frame);
uvs : uvs:env { disjoint uvs pg };
ss : PS.ss_t;
//
// these are the typed ss
// sometimes a step in the prover (e.g., intro exists) may compute these
// in such cases, the prover doesn't need to compute again
// so we cache them here
//
nts : option (nts:PS.nt_substs & effect_labels:list T.tot_or_ghost {
PS.well_typed_nt_substs pg uvs nts effect_labels /\
PS.is_permutation nts ss
});
solved : vprop;
unsolved : list vprop;
k : continuation_elaborator preamble.g0 (preamble.ctxt * preamble.frame)
pg ((list_as_vprop remaining_ctxt * preamble.frame) * ss.(solved));
goals_inv : vprop_equiv (push_env pg uvs) preamble.goals (list_as_vprop unsolved * solved);
solved_inv : squash (freevars ss.(solved) `Set.subset` dom pg);
} | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Checker.Prover.Base.fsti"
} | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": 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 | st: Pulse.Checker.Prover.Base.prover_state preamble -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Pulse.Checker.Prover.Base.preamble",
"Pulse.Checker.Prover.Base.prover_state",
"Prims.eq2",
"Prims.list",
"Pulse.Syntax.Base.vprop",
"Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__unsolved",
"Prims.Nil",
"Prims.logical"
] | [] | false | false | false | false | true | let is_terminal (#preamble: _) (st: prover_state preamble) =
| st.unsolved == [] | false |
|
Pulse.Checker.Prover.Base.fsti | Pulse.Checker.Prover.Base.op_Array_Access | val op_Array_Access : ss: Pulse.Checker.Prover.Substs.ss_t -> t: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.term | let op_Array_Access (ss:PS.ss_t) (t:term) =
PS.ss_term t ss | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Base.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 17,
"end_line": 73,
"start_col": 0,
"start_line": 72
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Checker.Prover.Base
open Pulse.Syntax
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Base
module T = FStar.Tactics.V2
module PS = Pulse.Checker.Prover.Substs
let vprop_typing (g:env) (t:term) = tot_typing g t tm_vprop
//
// Scaffolding for adding elims
//
// Given a function f : vprop -> T.Tac bool that decides whether a vprop
// should be elim-ed,
// and an mk function to create the elim term, comp, and typing,
// add_elims will create a continuation_elaborator
//
type mk_t =
#g:env ->
#v:vprop ->
tot_typing g v tm_vprop ->
T.Tac (option (x:ppname &
t:st_term &
c:comp { stateful_comp c /\ comp_pre c == v } &
st_typing g t c))
val add_elims (#g:env) (#ctxt:term) (#frame:term)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(ctxt_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame))
//
// Prover state
//
noeq type preamble = {
g0 : env;
ctxt : vprop;
frame : vprop;
ctxt_frame_typing : vprop_typing g0 (tm_star ctxt frame);
goals : vprop;
} | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Checker.Prover.Base.fsti"
} | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": 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 | ss: Pulse.Checker.Prover.Substs.ss_t -> t: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.term | Prims.Tot | [
"total"
] | [] | [
"Pulse.Checker.Prover.Substs.ss_t",
"Pulse.Syntax.Base.term",
"Pulse.Checker.Prover.Substs.ss_term"
] | [] | false | false | false | true | false | let ( .() ) (ss: PS.ss_t) (t: term) =
| PS.ss_term t ss | false |
|
Pulse.Typing.Combinators.fst | Pulse.Typing.Combinators.mk_bind_ghost_ghost | val mk_bind_ghost_ghost:bind_t C_STGhost? C_STGhost? | val mk_bind_ghost_ghost:bind_t C_STGhost? C_STGhost? | let mk_bind_ghost_ghost
: bind_t C_STGhost? C_STGhost?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |) | {
"file_name": "lib/steel/pulse/Pulse.Typing.Combinators.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 63,
"end_line": 234,
"start_col": 0,
"start_line": 228
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Typing.Combinators
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
assume
val invert_forall_typing
(#g #u #b #body:_)
(d:tot_typing g (tm_forall_sl u b body) tm_vprop)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
: GTot (
tot_typing g b.binder_ty (tm_type u) &
tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop
)
assume
val construct_forall_typing
(#g #u #b #body:_)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
(dt:tot_typing g b.binder_ty (tm_type u))
(db:tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop)
: GTot (tot_typing g (tm_forall_sl u b body) tm_vprop)
let rec vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1)
: GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop))
(decreases v)
= match v with
| VE_Refl _ _ -> (fun x -> x), (fun x -> x)
| VE_Sym _ _ _ v' ->
let f, g = vprop_equiv_typing v' in
g, f
| VE_Trans g t0 t2 t1 v02 v21 ->
let f02, f20 = vprop_equiv_typing v02 in
let f21, f12 = vprop_equiv_typing v21 in
(fun x -> f21 (f02 x)),
(fun x -> f20 (f12 x))
| VE_Ctxt g s0 s1 s0' s1' v0 v1 ->
let f0, f0' = vprop_equiv_typing v0 in
let f1, f1' = vprop_equiv_typing v1 in
let ff (x:tot_typing g (tm_star s0 s1) tm_vprop)
: tot_typing g (tm_star s0' s1') tm_vprop
= let s0_typing = star_typing_inversion_l x in
let s1_typing = star_typing_inversion_r x in
let s0'_typing, s1'_typing = f0 s0_typing, f1 s1_typing in
star_typing s0'_typing s1'_typing
in
let gg (x:tot_typing g (tm_star s0' s1') tm_vprop)
: tot_typing g (tm_star s0 s1) tm_vprop
= let s0'_typing = star_typing_inversion_l x in
let s1'_typing = star_typing_inversion_r x in
star_typing (f0' s0'_typing) (f1' s1'_typing)
in
ff, gg
| VE_Unit g t ->
let fwd (x:tot_typing g (tm_star tm_emp t) tm_vprop)
: tot_typing g t tm_vprop
= let r = star_typing_inversion_r x in
r
in
let bk (x:tot_typing g t tm_vprop)
: tot_typing g (tm_star tm_emp t) tm_vprop
= star_typing emp_typing x
in
fwd, bk
| VE_Comm g t0 t1 ->
let f t0 t1 (x:tot_typing g (tm_star t0 t1) tm_vprop)
: tot_typing g (tm_star t1 t0) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt1 = star_typing_inversion_r x in
star_typing tt1 tt0
in
f t0 t1, f t1 t0
| VE_Assoc g t0 t1 t2 ->
let fwd (x:tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop)
: tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt12 = star_typing_inversion_r x in
let tt1 = star_typing_inversion_l tt12 in
let tt2 = star_typing_inversion_r tt12 in
star_typing (star_typing tt0 tt1) tt2
in
let bk (x : tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop)
: tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop
= let tt01 = star_typing_inversion_l x in
let tt2 = star_typing_inversion_r x in
let tt0 = star_typing_inversion_l tt01 in
let tt1 = star_typing_inversion_r tt01 in
star_typing tt0 (star_typing tt1 tt2)
in
fwd, bk
| VE_Ext g t0 t1 token ->
let d1, d2 = vprop_eq_typing_inversion g t0 t1 token in
(fun _ -> d2),
(fun _ -> d1)
| VE_Fa g x u b t0 t1 d ->
let d0, d1 = vprop_equiv_typing d in
(fun fa0_typing ->
let b_typing, t0_typing = invert_forall_typing fa0_typing x in
let t1_typing = d0 t0_typing in
construct_forall_typing #g #u x b_typing t1_typing),
(fun fa1_typing ->
let b_typing, t1_typing = invert_forall_typing fa1_typing x in
let t0_typing = d1 t1_typing in
construct_forall_typing #g #u #b #t0 x b_typing t0_typing)
#push-options "--z3rlimit_factor 8 --ifuel 1 --fuel 2 --query_stats"
let bind_t (case_c1 case_c2:comp_st -> bool) =
(g:env) ->
(pre:term) ->
(e1:st_term) ->
(e2:st_term) ->
(c1:comp_st{ case_c1 c1 }) ->
(c2:comp_st{ case_c2 c2 }) ->
(px:nvar { ~ (Set.mem (snd px) (dom g)) }) ->
(d_e1:st_typing g e1 c1) ->
(d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1))) ->
(d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2) ->
(res_typing:universe_of g (comp_res c2) (comp_u c2)) ->
(post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop) ->
(bias_towards_continuation:bool) ->
T.TacH (t:st_term &
c:comp_st { st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires fun _ ->
let _, x = px in
comp_pre c1 == pre /\
None? (lookup g x) /\
(~(x `Set.mem` freevars_st e2)) /\
open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))))
(ensures fun _ _ -> True)
let mk_bind_st_st
: bind_t C_ST? C_ST?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
let inames_of (c:comp_st) : term =
match c with
| C_ST _
| C_STGhost _ -> tm_emp_inames
| C_STAtomic inames _ _ -> inames
let with_inames (c:comp_st) (i:term) =
match c with
| C_ST _ -> c
| C_STGhost sc -> C_STGhost sc
| C_STAtomic _ obs sc -> C_STAtomic i obs sc
let weaken_comp_inames (#g:env) (#e:st_term) (#c:comp_st) (d_e:st_typing g e c) (new_inames:term)
: T.Tac (c':comp_st { with_inames c new_inames == c' } &
st_typing g e c')
= match c with
| C_ST _
| C_STGhost _ -> (| c, d_e |)
| C_STAtomic inames obs sc ->
let d_e = T_Sub _ _ _ _ d_e (STS_AtomicInvs _ sc inames new_inames obs obs (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
(| with_inames c new_inames, d_e |)
let st_ghost_as_atomic (c:comp_st { C_STGhost? c }) =
C_STAtomic tm_emp_inames Neutral (st_comp_of_comp c)
let try_lift_ghost_atomic (#g:env) (#e:st_term) (#c:comp_st { C_STGhost? c }) (d:st_typing g e c)
: T.Tac (option (st_typing g e (st_ghost_as_atomic c)))
= let w = try_get_non_informative_witness g (comp_u c) (comp_res c) in
match w with
| None -> None
| Some w ->
let d = T_Lift _ _ _ _ d (Lift_Ghost_Neutral _ c w) in
Some d
let lift_ghost_atomic (#g:env) (#e:st_term) (#c:comp_st { C_STGhost? c }) (d:st_typing g e c)
: T.Tac (st_typing g e (st_ghost_as_atomic c))
= let w = try_lift_ghost_atomic d in
match w with
| None ->
let open Pulse.PP in
let t = comp_res c in
fail_doc g (Some t.range) [
text "Expected a term with a non-informative (e.g., erased) type; got"
^/^ pp t
]
| Some d ->
d | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.PP.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Result.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Typing.Combinators.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Pulse.Typing.Combinators.bind_t C_STGhost? C_STGhost? | Prims.Tot | [
"total"
] | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.st_term",
"Pulse.Syntax.Base.comp_st",
"Prims.b2t",
"Pulse.Syntax.Base.uu___is_C_STGhost",
"Pulse.Syntax.Base.nvar",
"Prims.l_not",
"FStar.Set.mem",
"Pulse.Syntax.Base.var",
"FStar.Pervasives.Native.snd",
"Pulse.Syntax.Base.ppname",
"Pulse.Typing.Env.dom",
"Pulse.Typing.st_typing",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.comp_res",
"Pulse.Syntax.Pure.tm_type",
"Pulse.Syntax.Base.comp_u",
"Pulse.Typing.Env.push_binding",
"FStar.Pervasives.Native.fst",
"Pulse.Syntax.Naming.open_st_term_nv",
"Pulse.Typing.universe_of",
"Pulse.Syntax.Naming.open_term_nv",
"Pulse.Syntax.Base.comp_post",
"Pulse.Syntax.Base.tm_vprop",
"Prims.bool",
"FStar.Pervasives.Mkdtuple3",
"Prims.l_and",
"Prims.eq2",
"Pulse.Syntax.Base.st_comp",
"Pulse.Syntax.Base.st_comp_of_comp",
"Pulse.Typing.Combinators.st_comp_with_pre",
"Prims.l_imp",
"Pulse.Syntax.Base.effect_annot",
"Pulse.Syntax.Base.effect_annot_of_comp",
"Pulse.Typing.wr",
"Pulse.Typing.bind_comp_out",
"Pulse.Syntax.Base.Tm_Bind",
"Pulse.Syntax.Base.Mkst_term'__Tm_Bind__payload",
"Pulse.Typing.T_Bind",
"Pulse.Typing.bind_comp",
"Pulse.Typing.Bind_comp",
"Pulse.Syntax.Base.binder",
"Pulse.Typing.Combinators.nvar_as_binder",
"FStar.Pervasives.dtuple3"
] | [] | false | false | false | true | false | let mk_bind_ghost_ghost:bind_t C_STGhost? C_STGhost? =
| fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |) | false |
Pulse.Typing.Combinators.fst | Pulse.Typing.Combinators.mk_bind_st_st | val mk_bind_st_st:bind_t C_ST? C_ST? | val mk_bind_st_st:bind_t C_ST? C_ST? | let mk_bind_st_st
: bind_t C_ST? C_ST?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |) | {
"file_name": "lib/steel/pulse/Pulse.Typing.Combinators.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 63,
"end_line": 177,
"start_col": 0,
"start_line": 171
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Typing.Combinators
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
assume
val invert_forall_typing
(#g #u #b #body:_)
(d:tot_typing g (tm_forall_sl u b body) tm_vprop)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
: GTot (
tot_typing g b.binder_ty (tm_type u) &
tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop
)
assume
val construct_forall_typing
(#g #u #b #body:_)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
(dt:tot_typing g b.binder_ty (tm_type u))
(db:tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop)
: GTot (tot_typing g (tm_forall_sl u b body) tm_vprop)
let rec vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1)
: GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop))
(decreases v)
= match v with
| VE_Refl _ _ -> (fun x -> x), (fun x -> x)
| VE_Sym _ _ _ v' ->
let f, g = vprop_equiv_typing v' in
g, f
| VE_Trans g t0 t2 t1 v02 v21 ->
let f02, f20 = vprop_equiv_typing v02 in
let f21, f12 = vprop_equiv_typing v21 in
(fun x -> f21 (f02 x)),
(fun x -> f20 (f12 x))
| VE_Ctxt g s0 s1 s0' s1' v0 v1 ->
let f0, f0' = vprop_equiv_typing v0 in
let f1, f1' = vprop_equiv_typing v1 in
let ff (x:tot_typing g (tm_star s0 s1) tm_vprop)
: tot_typing g (tm_star s0' s1') tm_vprop
= let s0_typing = star_typing_inversion_l x in
let s1_typing = star_typing_inversion_r x in
let s0'_typing, s1'_typing = f0 s0_typing, f1 s1_typing in
star_typing s0'_typing s1'_typing
in
let gg (x:tot_typing g (tm_star s0' s1') tm_vprop)
: tot_typing g (tm_star s0 s1) tm_vprop
= let s0'_typing = star_typing_inversion_l x in
let s1'_typing = star_typing_inversion_r x in
star_typing (f0' s0'_typing) (f1' s1'_typing)
in
ff, gg
| VE_Unit g t ->
let fwd (x:tot_typing g (tm_star tm_emp t) tm_vprop)
: tot_typing g t tm_vprop
= let r = star_typing_inversion_r x in
r
in
let bk (x:tot_typing g t tm_vprop)
: tot_typing g (tm_star tm_emp t) tm_vprop
= star_typing emp_typing x
in
fwd, bk
| VE_Comm g t0 t1 ->
let f t0 t1 (x:tot_typing g (tm_star t0 t1) tm_vprop)
: tot_typing g (tm_star t1 t0) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt1 = star_typing_inversion_r x in
star_typing tt1 tt0
in
f t0 t1, f t1 t0
| VE_Assoc g t0 t1 t2 ->
let fwd (x:tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop)
: tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt12 = star_typing_inversion_r x in
let tt1 = star_typing_inversion_l tt12 in
let tt2 = star_typing_inversion_r tt12 in
star_typing (star_typing tt0 tt1) tt2
in
let bk (x : tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop)
: tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop
= let tt01 = star_typing_inversion_l x in
let tt2 = star_typing_inversion_r x in
let tt0 = star_typing_inversion_l tt01 in
let tt1 = star_typing_inversion_r tt01 in
star_typing tt0 (star_typing tt1 tt2)
in
fwd, bk
| VE_Ext g t0 t1 token ->
let d1, d2 = vprop_eq_typing_inversion g t0 t1 token in
(fun _ -> d2),
(fun _ -> d1)
| VE_Fa g x u b t0 t1 d ->
let d0, d1 = vprop_equiv_typing d in
(fun fa0_typing ->
let b_typing, t0_typing = invert_forall_typing fa0_typing x in
let t1_typing = d0 t0_typing in
construct_forall_typing #g #u x b_typing t1_typing),
(fun fa1_typing ->
let b_typing, t1_typing = invert_forall_typing fa1_typing x in
let t0_typing = d1 t1_typing in
construct_forall_typing #g #u #b #t0 x b_typing t0_typing)
#push-options "--z3rlimit_factor 8 --ifuel 1 --fuel 2 --query_stats"
let bind_t (case_c1 case_c2:comp_st -> bool) =
(g:env) ->
(pre:term) ->
(e1:st_term) ->
(e2:st_term) ->
(c1:comp_st{ case_c1 c1 }) ->
(c2:comp_st{ case_c2 c2 }) ->
(px:nvar { ~ (Set.mem (snd px) (dom g)) }) ->
(d_e1:st_typing g e1 c1) ->
(d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1))) ->
(d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2) ->
(res_typing:universe_of g (comp_res c2) (comp_u c2)) ->
(post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop) ->
(bias_towards_continuation:bool) ->
T.TacH (t:st_term &
c:comp_st { st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires fun _ ->
let _, x = px in
comp_pre c1 == pre /\
None? (lookup g x) /\
(~(x `Set.mem` freevars_st e2)) /\
open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))))
(ensures fun _ _ -> True) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.PP.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Result.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Typing.Combinators.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Pulse.Typing.Combinators.bind_t C_ST? C_ST? | Prims.Tot | [
"total"
] | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.st_term",
"Pulse.Syntax.Base.comp_st",
"Prims.b2t",
"Pulse.Syntax.Base.uu___is_C_ST",
"Pulse.Syntax.Base.nvar",
"Prims.l_not",
"FStar.Set.mem",
"Pulse.Syntax.Base.var",
"FStar.Pervasives.Native.snd",
"Pulse.Syntax.Base.ppname",
"Pulse.Typing.Env.dom",
"Pulse.Typing.st_typing",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.comp_res",
"Pulse.Syntax.Pure.tm_type",
"Pulse.Syntax.Base.comp_u",
"Pulse.Typing.Env.push_binding",
"FStar.Pervasives.Native.fst",
"Pulse.Syntax.Naming.open_st_term_nv",
"Pulse.Typing.universe_of",
"Pulse.Syntax.Naming.open_term_nv",
"Pulse.Syntax.Base.comp_post",
"Pulse.Syntax.Base.tm_vprop",
"Prims.bool",
"FStar.Pervasives.Mkdtuple3",
"Prims.l_and",
"Prims.eq2",
"Pulse.Syntax.Base.st_comp",
"Pulse.Syntax.Base.st_comp_of_comp",
"Pulse.Typing.Combinators.st_comp_with_pre",
"Prims.l_imp",
"Pulse.Syntax.Base.effect_annot",
"Pulse.Syntax.Base.effect_annot_of_comp",
"Pulse.Typing.wr",
"Pulse.Typing.bind_comp_out",
"Pulse.Syntax.Base.Tm_Bind",
"Pulse.Syntax.Base.Mkst_term'__Tm_Bind__payload",
"Pulse.Typing.T_Bind",
"Pulse.Typing.bind_comp",
"Pulse.Typing.Bind_comp",
"Pulse.Syntax.Base.binder",
"Pulse.Typing.Combinators.nvar_as_binder",
"FStar.Pervasives.dtuple3"
] | [] | false | false | false | true | false | let mk_bind_st_st:bind_t C_ST? C_ST? =
| fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |) | false |
Pulse.Checker.Prover.Base.fsti | Pulse.Checker.Prover.Base.pst_extends | val pst_extends : pst1: Pulse.Checker.Prover.Base.prover_state preamble ->
pst2: Pulse.Checker.Prover.Base.prover_state preamble
-> Prims.logical | let pst_extends (#preamble:_) (pst1 pst2:prover_state preamble) =
pst1.pg `env_extends` pst2.pg /\
pst1.uvs `env_extends` pst2.uvs /\
pst1.ss `ss_extends` pst2.ss | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Base.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 30,
"end_line": 129,
"start_col": 0,
"start_line": 126
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Checker.Prover.Base
open Pulse.Syntax
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Base
module T = FStar.Tactics.V2
module PS = Pulse.Checker.Prover.Substs
let vprop_typing (g:env) (t:term) = tot_typing g t tm_vprop
//
// Scaffolding for adding elims
//
// Given a function f : vprop -> T.Tac bool that decides whether a vprop
// should be elim-ed,
// and an mk function to create the elim term, comp, and typing,
// add_elims will create a continuation_elaborator
//
type mk_t =
#g:env ->
#v:vprop ->
tot_typing g v tm_vprop ->
T.Tac (option (x:ppname &
t:st_term &
c:comp { stateful_comp c /\ comp_pre c == v } &
st_typing g t c))
val add_elims (#g:env) (#ctxt:term) (#frame:term)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(ctxt_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame))
//
// Prover state
//
noeq type preamble = {
g0 : env;
ctxt : vprop;
frame : vprop;
ctxt_frame_typing : vprop_typing g0 (tm_star ctxt frame);
goals : vprop;
}
let op_Array_Access (ss:PS.ss_t) (t:term) =
PS.ss_term t ss
let op_Star = tm_star
noeq
type prover_state (preamble:preamble) = {
pg : g:env { g `env_extends` preamble.g0 };
remaining_ctxt : list vprop;
remaining_ctxt_frame_typing : vprop_typing pg (list_as_vprop remaining_ctxt * preamble.frame);
uvs : uvs:env { disjoint uvs pg };
ss : PS.ss_t;
//
// these are the typed ss
// sometimes a step in the prover (e.g., intro exists) may compute these
// in such cases, the prover doesn't need to compute again
// so we cache them here
//
nts : option (nts:PS.nt_substs & effect_labels:list T.tot_or_ghost {
PS.well_typed_nt_substs pg uvs nts effect_labels /\
PS.is_permutation nts ss
});
solved : vprop;
unsolved : list vprop;
k : continuation_elaborator preamble.g0 (preamble.ctxt * preamble.frame)
pg ((list_as_vprop remaining_ctxt * preamble.frame) * ss.(solved));
goals_inv : vprop_equiv (push_env pg uvs) preamble.goals (list_as_vprop unsolved * solved);
solved_inv : squash (freevars ss.(solved) `Set.subset` dom pg);
}
let is_terminal (#preamble:_) (st:prover_state preamble) =
st.unsolved == []
irreducible
let extend_post_hint_opt_g (g:env) (post_hint:post_hint_opt g) (g1:env { g1 `env_extends` g })
: p:post_hint_opt g1 { p == post_hint } =
match post_hint with
| None -> None
| Some post_hint ->
assert (g `env_extends` post_hint.g);
assert (g1 `env_extends` g);
assert (g1 `env_extends` post_hint.g);
Some post_hint
let ss_extends (ss1 ss2:PS.ss_t) =
Set.subset (PS.dom ss2) (PS.dom ss1) /\
(forall (x:var). PS.contains ss2 x ==> PS.sel ss1 x == PS.sel ss2 x) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Checker.Prover.Base.fsti"
} | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": 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 |
pst1: Pulse.Checker.Prover.Base.prover_state preamble ->
pst2: Pulse.Checker.Prover.Base.prover_state preamble
-> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Pulse.Checker.Prover.Base.preamble",
"Pulse.Checker.Prover.Base.prover_state",
"Prims.l_and",
"Pulse.Typing.Env.env_extends",
"Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__pg",
"Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__uvs",
"Pulse.Checker.Prover.Base.ss_extends",
"Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__ss",
"Prims.logical"
] | [] | false | false | false | false | true | let pst_extends (#preamble: _) (pst1 pst2: prover_state preamble) =
| pst1.pg `env_extends` pst2.pg /\ pst1.uvs `env_extends` pst2.uvs /\ pst1.ss `ss_extends` pst2.ss | false |
|
Pulse.Checker.Prover.Base.fsti | Pulse.Checker.Prover.Base.op_Star | val op_Star : l: Pulse.Syntax.Base.vprop -> r: Pulse.Syntax.Base.vprop -> Pulse.Syntax.Base.term | let op_Star = tm_star | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Base.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 21,
"end_line": 75,
"start_col": 0,
"start_line": 75
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Checker.Prover.Base
open Pulse.Syntax
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Base
module T = FStar.Tactics.V2
module PS = Pulse.Checker.Prover.Substs
let vprop_typing (g:env) (t:term) = tot_typing g t tm_vprop
//
// Scaffolding for adding elims
//
// Given a function f : vprop -> T.Tac bool that decides whether a vprop
// should be elim-ed,
// and an mk function to create the elim term, comp, and typing,
// add_elims will create a continuation_elaborator
//
type mk_t =
#g:env ->
#v:vprop ->
tot_typing g v tm_vprop ->
T.Tac (option (x:ppname &
t:st_term &
c:comp { stateful_comp c /\ comp_pre c == v } &
st_typing g t c))
val add_elims (#g:env) (#ctxt:term) (#frame:term)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(ctxt_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame))
//
// Prover state
//
noeq type preamble = {
g0 : env;
ctxt : vprop;
frame : vprop;
ctxt_frame_typing : vprop_typing g0 (tm_star ctxt frame);
goals : vprop;
}
let op_Array_Access (ss:PS.ss_t) (t:term) =
PS.ss_term t ss | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Checker.Prover.Base.fsti"
} | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": 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: Pulse.Syntax.Base.vprop -> r: Pulse.Syntax.Base.vprop -> Pulse.Syntax.Base.term | Prims.Tot | [
"total"
] | [] | [
"Pulse.Syntax.Base.tm_star"
] | [] | false | false | false | true | false | let op_Star =
| tm_star | false |
|
EnumEq.fst | EnumEq.enum_eq | val enum_eq : (#a:Type) -> (d : enum a) -> deq a | val enum_eq : (#a:Type) -> (d : enum a) -> deq a | instance enum_eq (#a:Type) (d : enum a) : deq a = {
eq = (fun (x y : a) -> toInt x = toInt y);
eq_ok = (fun (x y : a) -> inv1 x; inv1 y);
} | {
"file_name": "examples/typeclasses/EnumEq.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 1,
"end_line": 26,
"start_col": 0,
"start_line": 23
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EnumEq
open Enum
open Eq
open FStar.Tactics.Typeclasses | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"Eq.fst.checked",
"Enum.fst.checked"
],
"interface_file": true,
"source_file": "EnumEq.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "Eq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Enum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "Eq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Enum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": 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: Enum.enum a -> Eq.deq a | Prims.Tot | [
"total"
] | [] | [
"Enum.enum",
"Eq.Mkdeq",
"Prims.op_Equality",
"Enum.bounded",
"Enum.__proj__Mkenum__item__max",
"Enum.toInt",
"Prims.bool",
"Enum.inv1",
"Prims.unit",
"Eq.deq"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let enum_eq (#a: Type) (d: enum a) : deq a =
| {
eq = (fun (x: a) (y: a) -> toInt x = toInt y);
eq_ok
=
(fun (x: a) (y: a) ->
inv1 x;
inv1 y)
} | false |
Hacl.Streaming.Blake2s_128.fst | Hacl.Streaming.Blake2s_128.block_state_t | val block_state_t : Type0 | let block_state_t = Common.s Spec.Blake2S Core.M128 | {
"file_name": "code/streaming/Hacl.Streaming.Blake2s_128.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 51,
"end_line": 20,
"start_col": 0,
"start_line": 20
} | module Hacl.Streaming.Blake2s_128
module Blake2s128 = Hacl.Blake2s_128
module Common = Hacl.Streaming.Blake2.Common
module Core = Hacl.Impl.Blake2.Core
module F = Hacl.Streaming.Functor
module G = FStar.Ghost
module Impl = Hacl.Impl.Blake2.Generic
module Spec = Spec.Blake2
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// The functor
inline_for_extraction noextract
let blake2s_128 kk =
Common.blake2 Spec.Blake2S Core.M128 kk Blake2s128.init Blake2s128.update_multi
Blake2s128.update_last Blake2s128.finish | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Streaming.Blake2.Common.fst.checked",
"Hacl.Impl.Blake2.Generic.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Blake2s_128.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Blake2s_128.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Generic",
"short_module": "Impl"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Core"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Blake2.Common",
"short_module": "Common"
},
{
"abbrev": true,
"full_module": "Hacl.Blake2s_128",
"short_module": "Blake2s128"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Blake2.Common.s",
"Spec.Blake2.Definitions.Blake2S",
"Hacl.Impl.Blake2.Core.M128"
] | [] | false | false | false | true | true | let block_state_t =
| Common.s Spec.Blake2S Core.M128 | false |
|
Hacl.Streaming.Blake2s_128.fst | Hacl.Streaming.Blake2s_128.hash_with_key | val hash_with_key:Impl.blake2_st Spec.Blake2S Core.M128 | val hash_with_key:Impl.blake2_st Spec.Blake2S Core.M128 | let hash_with_key : Impl.blake2_st Spec.Blake2S Core.M128 =
Impl.blake2 #Spec.Blake2S #Core.M128 Blake2s128.init Blake2s128.update Blake2s128.finish | {
"file_name": "code/streaming/Hacl.Streaming.Blake2s_128.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 90,
"end_line": 58,
"start_col": 0,
"start_line": 57
} | module Hacl.Streaming.Blake2s_128
module Blake2s128 = Hacl.Blake2s_128
module Common = Hacl.Streaming.Blake2.Common
module Core = Hacl.Impl.Blake2.Core
module F = Hacl.Streaming.Functor
module G = FStar.Ghost
module Impl = Hacl.Impl.Blake2.Generic
module Spec = Spec.Blake2
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// The functor
inline_for_extraction noextract
let blake2s_128 kk =
Common.blake2 Spec.Blake2S Core.M128 kk Blake2s128.init Blake2s128.update_multi
Blake2s128.update_last Blake2s128.finish
/// Type abbreviations
let block_state_t = Common.s Spec.Blake2S Core.M128
let state_t = F.state_s (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
/// No key
inline_for_extraction noextract
let alloca =
F.alloca (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
[@ (Comment " State allocation function when there is no key")]
let malloc =
F.malloc (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
[@ (Comment " Re-initialization function when there is no key")]
let reset =
F.reset (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
[@ (Comment " Update function when there is no key; 0 = success, 1 = max length exceeded")]
let update =
F.update (blake2s_128 0) (G.hide ()) (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
[@ (Comment " Finish function when there is no key")]
let digest =
F.digest (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
[@ (Comment " Free state function when there is no key")]
let free =
F.free (blake2s_128 0) (G.hide ()) (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
(* The one-shot hash *)
[@@ Comment "Write the BLAKE2s digest of message `input` using key `key` into `output`.
@param output Pointer to `output_len` bytes of memory where the digest is written to.
@param output_len Length of the to-be-generated digest with 1 <= `output_len` <= 32.
@param input Pointer to `input_len` bytes of memory where the input message is read from.
@param input_len Length of the input message.
@param key Pointer to `key_len` bytes of memory where the key is read from. | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Streaming.Blake2.Common.fst.checked",
"Hacl.Impl.Blake2.Generic.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Blake2s_128.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Blake2s_128.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Generic",
"short_module": "Impl"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Core"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Blake2.Common",
"short_module": "Common"
},
{
"abbrev": true,
"full_module": "Hacl.Blake2s_128",
"short_module": "Blake2s128"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Hacl.Impl.Blake2.Generic.blake2_st Spec.Blake2.Definitions.Blake2S Hacl.Impl.Blake2.Core.M128 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.Blake2.Generic.blake2",
"Spec.Blake2.Definitions.Blake2S",
"Hacl.Impl.Blake2.Core.M128",
"Hacl.Blake2s_128.init",
"Hacl.Blake2s_128.update",
"Hacl.Blake2s_128.finish"
] | [] | false | false | false | true | false | let hash_with_key:Impl.blake2_st Spec.Blake2S Core.M128 =
| Impl.blake2 #Spec.Blake2S #Core.M128 Blake2s128.init Blake2s128.update Blake2s128.finish | false |
Pulse.Lib.Reference.fst | Pulse.Lib.Reference.pts_to | val pts_to
(#a:Type) (r:ref a)
(#[exact (`full_perm)] [@@@equate_by_smt] p:perm)
([@@@equate_by_smt] n:a)
: vprop | val pts_to
(#a:Type) (r:ref a)
(#[exact (`full_perm)] [@@@equate_by_smt] p:perm)
([@@@equate_by_smt] n:a)
: vprop | let pts_to
(#a:Type u#0)
(r:ref a)
(#[exact (`full_perm)] [@@@equate_by_smt] p:perm)
([@@@equate_by_smt] v:a)
= H.pts_to r #p (U.raise_val v) | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Reference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 33,
"end_line": 29,
"start_col": 0,
"start_line": 24
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.Reference
open Pulse.Lib.Core
open Pulse.Main
module H = Pulse.Lib.HigherReference
module U = FStar.Universe
let ref a = H.ref (U.raise_t a) | {
"checked_file": "/",
"dependencies": [
"Pulse.Main.fsti.checked",
"Pulse.Lib.HigherReference.fsti.checked",
"Pulse.Lib.Core.fsti.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Lib.Reference.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Pulse.Lib.HigherReference",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Pulse.Main",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.Observability",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"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: Pulse.Lib.Reference.ref a -> n: a -> Pulse.Lib.Core.vprop | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.Reference.ref",
"PulseCore.FractionalPermission.perm",
"Pulse.Lib.HigherReference.pts_to",
"FStar.Universe.raise_t",
"FStar.Universe.raise_val",
"Pulse.Lib.Core.vprop"
] | [] | false | false | false | true | false | let pts_to
(#a: Type u#0)
(r: ref a)
(#[exact (`full_perm)] [@@@ equate_by_smt]p: perm)
([@@@ equate_by_smt]v: a)
=
| H.pts_to r #p (U.raise_val v) | false |
Pulse.Lib.Reference.fst | Pulse.Lib.Reference.ref | val ref ([@@@unused] a:Type u#0) : Type u#0 | val ref ([@@@unused] a:Type u#0) : Type u#0 | let ref a = H.ref (U.raise_t a) | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Reference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 31,
"end_line": 22,
"start_col": 0,
"start_line": 22
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.Reference
open Pulse.Lib.Core
open Pulse.Main
module H = Pulse.Lib.HigherReference | {
"checked_file": "/",
"dependencies": [
"Pulse.Main.fsti.checked",
"Pulse.Lib.HigherReference.fsti.checked",
"Pulse.Lib.Core.fsti.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Lib.Reference.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Lib.HigherReference",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Pulse.Main",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.Observability",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"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"
] | [] | [
"Pulse.Lib.HigherReference.ref",
"FStar.Universe.raise_t"
] | [] | false | false | false | true | true | let ref a =
| H.ref (U.raise_t a) | false |
Pulse.Lib.Reference.fst | Pulse.Lib.Reference.alloc | val alloc (#a:Type) (x:a)
: stt (ref a) emp (fun r -> pts_to r x) | val alloc (#a:Type) (x:a)
: stt (ref a) emp (fun r -> pts_to r x) | let alloc = alloc' | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Reference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 18,
"end_line": 42,
"start_col": 0,
"start_line": 42
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.Reference
open Pulse.Lib.Core
open Pulse.Main
module H = Pulse.Lib.HigherReference
module U = FStar.Universe
let ref a = H.ref (U.raise_t a)
let pts_to
(#a:Type u#0)
(r:ref a)
(#[exact (`full_perm)] [@@@equate_by_smt] p:perm)
([@@@equate_by_smt] v:a)
= H.pts_to r #p (U.raise_val v)
```pulse
fn alloc' (#a:Type u#0) (v:a)
requires emp
returns r:ref a
ensures pts_to r v
{
let r = H.alloc (U.raise_val v);
fold (pts_to r #full_perm v);
r
} | {
"checked_file": "/",
"dependencies": [
"Pulse.Main.fsti.checked",
"Pulse.Lib.HigherReference.fsti.checked",
"Pulse.Lib.Core.fsti.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Lib.Reference.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Pulse.Lib.HigherReference",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Pulse.Main",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.Observability",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"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
-> Pulse.Lib.Core.stt (Pulse.Lib.Reference.ref a)
Pulse.Lib.Core.emp
(fun r -> Pulse.Lib.Reference.pts_to r x) | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.Reference.alloc'"
] | [] | false | false | false | false | false | let alloc =
| alloc' | false |
Pulse.Lib.Reference.fst | Pulse.Lib.Reference.share | val share (#a:Type) (r:ref a) (#v:erased a) (#p:perm)
: stt_ghost unit
(pts_to r #p v)
(fun _ ->
pts_to r #(half_perm p) v **
pts_to r #(half_perm p) v) | val share (#a:Type) (r:ref a) (#v:erased a) (#p:perm)
: stt_ghost unit
(pts_to r #p v)
(fun _ ->
pts_to r #(half_perm p) v **
pts_to r #(half_perm p) v) | let share = share' | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Reference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 18,
"end_line": 93,
"start_col": 0,
"start_line": 93
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.Reference
open Pulse.Lib.Core
open Pulse.Main
module H = Pulse.Lib.HigherReference
module U = FStar.Universe
let ref a = H.ref (U.raise_t a)
let pts_to
(#a:Type u#0)
(r:ref a)
(#[exact (`full_perm)] [@@@equate_by_smt] p:perm)
([@@@equate_by_smt] v:a)
= H.pts_to r #p (U.raise_val v)
```pulse
fn alloc' (#a:Type u#0) (v:a)
requires emp
returns r:ref a
ensures pts_to r v
{
let r = H.alloc (U.raise_val v);
fold (pts_to r #full_perm v);
r
}
```
let alloc = alloc'
```pulse
fn read (#a:Type) (r:ref a) (#n:erased a) (#p:perm)
requires pts_to r #p n
returns x:a
ensures pts_to r #p n ** pure (eq2 #a (reveal n) x)
{
unfold (pts_to r #p n);
let k = H.( !r );
fold (pts_to r #p n);
U.downgrade_val k
}
```
let ( ! ) #a = read #a
```pulse
fn write (#a:Type) (r:ref a) (x:a) (#n:erased a)
requires pts_to r #full_perm n
ensures pts_to r #full_perm x
{
unfold (pts_to r #full_perm n);
H.(r := (U.raise_val x));
fold (pts_to r #full_perm x)
}
```
let ( := ) #a r x #n = write #a r x #n
```pulse
fn free' #a (r:ref a) (#n:erased a)
requires pts_to r #full_perm n
ensures emp
{
unfold (pts_to r #full_perm n);
H.free r;
}
```
let free = free'
```pulse
ghost
fn share' (#a:Type) (r:ref a) (#v:erased a) (#p:perm)
requires pts_to r #p v
ensures pts_to r #(half_perm p) v ** pts_to r #(half_perm p) v
{
unfold pts_to r #p v;
H.share r;
fold pts_to r #(half_perm p) v;
fold pts_to r #(half_perm p) v
} | {
"checked_file": "/",
"dependencies": [
"Pulse.Main.fsti.checked",
"Pulse.Lib.HigherReference.fsti.checked",
"Pulse.Lib.Core.fsti.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Lib.Reference.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Pulse.Lib.HigherReference",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Pulse.Main",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.Observability",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"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: Pulse.Lib.Reference.ref a
-> Pulse.Lib.Core.stt_ghost Prims.unit
(Pulse.Lib.Reference.pts_to r (FStar.Ghost.reveal v))
(fun _ ->
Pulse.Lib.Reference.pts_to r (FStar.Ghost.reveal v) **
Pulse.Lib.Reference.pts_to r (FStar.Ghost.reveal v)) | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.Reference.share'"
] | [] | false | false | false | false | false | let share =
| share' | false |
Pulse.Lib.Reference.fst | Pulse.Lib.Reference.free | val free (#a:Type) (r:ref a) (#n:erased a)
: stt unit (pts_to r n) (fun _ -> emp) | val free (#a:Type) (r:ref a) (#n:erased a)
: stt unit (pts_to r n) (fun _ -> emp) | let free = free' | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Reference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 16,
"end_line": 79,
"start_col": 0,
"start_line": 79
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.Reference
open Pulse.Lib.Core
open Pulse.Main
module H = Pulse.Lib.HigherReference
module U = FStar.Universe
let ref a = H.ref (U.raise_t a)
let pts_to
(#a:Type u#0)
(r:ref a)
(#[exact (`full_perm)] [@@@equate_by_smt] p:perm)
([@@@equate_by_smt] v:a)
= H.pts_to r #p (U.raise_val v)
```pulse
fn alloc' (#a:Type u#0) (v:a)
requires emp
returns r:ref a
ensures pts_to r v
{
let r = H.alloc (U.raise_val v);
fold (pts_to r #full_perm v);
r
}
```
let alloc = alloc'
```pulse
fn read (#a:Type) (r:ref a) (#n:erased a) (#p:perm)
requires pts_to r #p n
returns x:a
ensures pts_to r #p n ** pure (eq2 #a (reveal n) x)
{
unfold (pts_to r #p n);
let k = H.( !r );
fold (pts_to r #p n);
U.downgrade_val k
}
```
let ( ! ) #a = read #a
```pulse
fn write (#a:Type) (r:ref a) (x:a) (#n:erased a)
requires pts_to r #full_perm n
ensures pts_to r #full_perm x
{
unfold (pts_to r #full_perm n);
H.(r := (U.raise_val x));
fold (pts_to r #full_perm x)
}
```
let ( := ) #a r x #n = write #a r x #n
```pulse
fn free' #a (r:ref a) (#n:erased a)
requires pts_to r #full_perm n
ensures emp
{
unfold (pts_to r #full_perm n);
H.free r;
} | {
"checked_file": "/",
"dependencies": [
"Pulse.Main.fsti.checked",
"Pulse.Lib.HigherReference.fsti.checked",
"Pulse.Lib.Core.fsti.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Lib.Reference.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Pulse.Lib.HigherReference",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Pulse.Main",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.Observability",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"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: Pulse.Lib.Reference.ref a
-> Pulse.Lib.Core.stt Prims.unit
(Pulse.Lib.Reference.pts_to r (FStar.Ghost.reveal n))
(fun _ -> Pulse.Lib.Core.emp) | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.Reference.free'"
] | [] | false | false | false | false | false | let free =
| free' | false |
Hacl.Impl.Curve25519.Generic.fst | Hacl.Impl.Curve25519.Generic.ladder3_ | val ladder3_:
#s:field_spec
-> q:point s
-> p01:lbuffer (limb s) (4ul *! nlimb s)
-> Stack unit
(requires fun h0 ->
live h0 q /\ live h0 p01 /\ disjoint q p01 /\
fget_z h0 q == 1 /\ state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q))
(ensures fun h0 _ h1 ->
modifies (loc p01) h0 h1 /\
(let nq = gsub p01 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x q) /\ state_inv_t h1 (get_z q) /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1) /\
(fget_xz h1 q, fget_xz h1 nq, fget_xz h1 nq_p1) == M.montgomery_ladder1_2 (fget_x h0 q))) | val ladder3_:
#s:field_spec
-> q:point s
-> p01:lbuffer (limb s) (4ul *! nlimb s)
-> Stack unit
(requires fun h0 ->
live h0 q /\ live h0 p01 /\ disjoint q p01 /\
fget_z h0 q == 1 /\ state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q))
(ensures fun h0 _ h1 ->
modifies (loc p01) h0 h1 /\
(let nq = gsub p01 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x q) /\ state_inv_t h1 (get_z q) /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1) /\
(fget_xz h1 q, fget_xz h1 nq, fget_xz h1 nq_p1) == M.montgomery_ladder1_2 (fget_x h0 q))) | let ladder3_ #s q p01 =
let p0 : point s = sub p01 0ul (2ul *! nlimb s) in
let p1 : point s = sub p01 (2ul *! nlimb s) (2ul *! nlimb s) in
copy p1 q;
let x0 : felem s = sub p0 0ul (nlimb s) in
let z0 : felem s = sub p0 (nlimb s) (nlimb s) in
set_one x0;
set_zero z0;
let h0 = ST.get () in
assert (gsub p01 0ul (2ul *! nlimb s) == p0);
assert (gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) == p1);
assert (gsub p0 0ul (nlimb s) == x0);
assert (gsub p0 (nlimb s) (nlimb s) == z0);
assert (fget_x h0 p1 == fget_x h0 q);
assert (fget_z h0 p1 == 1);
assert (fget_x h0 p0 == 1);
assert (fget_z h0 p0 == 0);
assert (
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x p0) /\ state_inv_t h0 (get_z p0) /\
state_inv_t h0 (get_x p1) /\ state_inv_t h0 (get_z p1)) | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Generic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 59,
"end_line": 403,
"start_col": 0,
"start_line": 381
} | module Hacl.Impl.Curve25519.Generic
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Curve25519.Fields
include Hacl.Impl.Curve25519.Finv
include Hacl.Impl.Curve25519.AddAndDouble
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module C = Hacl.Impl.Curve25519.Fields.Core
module S = Spec.Curve25519
module M = Hacl.Spec.Curve25519.AddAndDouble
module Lemmas = Hacl.Spec.Curve25519.Field64.Lemmas
friend Lib.LoopCombinators
#set-options "--z3rlimit 30 --fuel 0 --ifuel 1 --using_facts_from '* -FStar.Seq -Hacl.Spec.*' --record_options"
//#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm"
inline_for_extraction noextract
let scalar = lbuffer uint8 32ul
inline_for_extraction noextract
val scalar_bit:
s:scalar
-> n:size_t{v n < 256}
-> Stack uint64
(requires fun h0 -> live h0 s)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.ith_bit (as_seq h0 s) (v n) /\ v r <= 1)
let scalar_bit s n =
let h0 = ST.get () in
mod_mask_lemma ((LSeq.index (as_seq h0 s) (v n / 8)) >>. (n %. 8ul)) 1ul;
assert_norm (1 = pow2 1 - 1);
assert (v (mod_mask #U8 #SEC 1ul) == v (u8 1));
to_u64 ((s.(n /. 8ul) >>. (n %. 8ul)) &. u8 1)
inline_for_extraction noextract
val decode_point:
#s:field_spec
-> o:point s
-> i:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint o i)
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
state_inv_t h1 (get_x o) /\ state_inv_t h1 (get_z o) /\
fget_x h1 o == S.decodePoint (as_seq h0 i) /\ fget_z h1 o == 1)
[@ Meta.Attribute.specialize ]
let decode_point #s o i =
push_frame();
let tmp = create 4ul (u64 0) in
let h0 = ST.get () in
uints_from_bytes_le #U64 tmp i;
let h1 = ST.get () in
BSeq.uints_from_bytes_le_nat_lemma #U64 #SEC #4 (as_seq h0 i);
assert (BSeq.nat_from_intseq_le (as_seq h1 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i));
let tmp3 = tmp.(3ul) in
tmp.(3ul) <- tmp3 &. u64 0x7fffffffffffffff;
mod_mask_lemma tmp3 63ul;
assert_norm (0x7fffffffffffffff = pow2 63 - 1);
assert (v (mod_mask #U64 #SEC 63ul) == v (u64 0x7fffffffffffffff));
let h2 = ST.get () in
assert (v (LSeq.index (as_seq h2 tmp) 3) < pow2 63);
Lemmas.lemma_felem64_mod255 (as_seq h1 tmp);
assert (BSeq.nat_from_intseq_le (as_seq h2 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i) % pow2 255);
let x : felem s = sub o 0ul (nlimb s) in
let z : felem s = sub o (nlimb s) (nlimb s) in
set_one z;
load_felem x tmp;
pop_frame()
val encode_point:
#s:field_spec
-> o:lbuffer uint8 32ul
-> i:point s
-> Stack unit
(requires fun h0 ->
live h0 o /\ live h0 i /\ disjoint o i /\
state_inv_t h0 (get_x i) /\ state_inv_t h0 (get_z i))
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
as_seq h1 o == S.encodePoint (fget_x h0 i, fget_z h0 i))
[@ Meta.Attribute.specialize ]
let encode_point #s o i =
push_frame();
let x : felem s = sub i 0ul (nlimb s) in
let z : felem s = sub i (nlimb s) (nlimb s) in
let tmp = create_felem s in
let u64s = create 4ul (u64 0) in
let tmp_w = create (2ul `FStar.UInt32.mul` ((nwide s) <: FStar.UInt32.t)) (wide_zero s) in
let h0 = ST.get () in
finv tmp z tmp_w;
fmul tmp tmp x tmp_w;
let h1 = ST.get () in
assert (feval h1 tmp == S.fmul (S.fpow (feval h0 z) (pow2 255 - 21)) (feval h0 x));
assert (feval h1 tmp == S.fmul (feval h0 x) (S.fpow (feval h0 z) (pow2 255 - 21)));
store_felem u64s tmp;
let h2 = ST.get () in
assert (as_seq h2 u64s == BSeq.nat_to_intseq_le 4 (feval h1 tmp));
uints_to_bytes_le #U64 4ul o u64s;
let h3 = ST.get () in
BSeq.uints_to_bytes_le_nat_lemma #U64 #SEC 4 (feval h1 tmp);
assert (as_seq h3 o == BSeq.nat_to_bytes_le 32 (feval h1 tmp));
pop_frame()
// TODO: why re-define the signature here?
val cswap2:
#s:field_spec
-> bit:uint64{v bit <= 1}
-> p1:felem2 s
-> p2:felem2 s
-> Stack unit
(requires fun h0 ->
live h0 p1 /\ live h0 p2 /\ disjoint p1 p2)
(ensures fun h0 _ h1 ->
modifies (loc p1 |+| loc p2) h0 h1 /\
(v bit == 1 ==> as_seq h1 p1 == as_seq h0 p2 /\ as_seq h1 p2 == as_seq h0 p1) /\
(v bit == 0 ==> as_seq h1 p1 == as_seq h0 p1 /\ as_seq h1 p2 == as_seq h0 p2) /\
(fget_xz h1 p1, fget_xz h1 p2) == S.cswap2 bit (fget_xz h0 p1) (fget_xz h0 p2))
[@ Meta.Attribute.inline_ ]
let cswap2 #s bit p0 p1 =
C.cswap2 #s bit p0 p1
val ladder_step:
#s:field_spec
-> k:scalar
-> q:point s
-> i:size_t{v i < 251}
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
v (LSeq.index (as_seq h0 bit) 0) <= 1 /\
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let (p0, p1, b) = S.ladder_step (as_seq h0 k) (fget_xz h0 q) (v i)
(fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in
p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\
b == LSeq.index (as_seq h1 bit) 0 /\
v (LSeq.index (as_seq h1 bit) 0) <= 1 /\
state_inv_t h1 (get_x q) /\ state_inv_t h1 (get_z q) /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1)))
#push-options "--z3rlimit 200 --fuel 0 --ifuel 1"
[@ Meta.Attribute.inline_ ]
let ladder_step #s k q i p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let swap : lbuffer uint64 1ul = sub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let nq = sub p01_tmp1 0ul (2ul *! nlimb s) in
let nq_p1 = sub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap (8ul *! nlimb s) 1ul == swap);
let h0 = ST.get () in
let bit = scalar_bit k (253ul -. i) in
assert (v bit == v (S.ith_bit (as_seq h0 k) (253 - v i)));
let sw = swap.(0ul) ^. bit in
logxor_lemma1 (LSeq.index (as_seq h0 swap) 0) bit;
cswap2 #s sw nq nq_p1;
point_add_and_double #s q p01_tmp1 tmp2;
swap.(0ul) <- bit
#pop-options
#push-options "--z3rlimit 300 --fuel 1 --ifuel 1"
val ladder_step_loop:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
v (LSeq.index (as_seq h0 bit) 0) <= 1 /\
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let (p0, p1, b) =
Lib.LoopCombinators.repeati 251
(S.ladder_step (as_seq h0 k) (fget_xz h0 q))
(fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in
p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\ b == LSeq.index (as_seq h1 bit) 0 /\
v (LSeq.index (as_seq h1 bit) 0) <= 1 /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1)))
[@ Meta.Attribute.inline_ ]
let ladder_step_loop #s k q p01_tmp1_swap tmp2 =
let h0 = ST.get () in
[@ inline_let]
let spec_fh h0 =
S.ladder_step (as_seq h0 k) (fget_x h0 q, fget_z h0 q) in
[@ inline_let]
let acc h : GTot (tuple3 S.proj_point S.proj_point uint64) =
let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
(fget_xz h nq, fget_xz h nq_p1, LSeq.index (as_seq h bit) 0) in
[@ inline_let]
let inv h (i:nat{i <= 251}) =
let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h /\
v (LSeq.index (as_seq h bit) 0) <= 1 /\
state_inv_t h (get_x q) /\ state_inv_t h (get_z q) /\
state_inv_t h (get_x nq) /\ state_inv_t h (get_z nq) /\
state_inv_t h (get_x nq_p1) /\ state_inv_t h (get_z nq_p1) /\
acc h == Lib.LoopCombinators.repeati i (spec_fh h0) (acc h0) in
Lib.Loops.for 0ul 251ul inv
(fun i ->
Lib.LoopCombinators.unfold_repeati 251 (spec_fh h0) (acc h0) (v i);
ladder_step #s k q i p01_tmp1_swap tmp2)
#pop-options
#push-options "--z3refresh --fuel 0 --ifuel 1 --z3rlimit 800"
val ladder0_:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq ==
M.montgomery_ladder1_0 (as_seq h0 k) (fget_xz h0 q) (fget_xz h0 nq) (fget_xz h0 nq_p1)))
[@ Meta.Attribute.inline_ ]
let ladder0_ #s k q p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let nq : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 : point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let swap:lbuffer uint64 1ul = sub p01_tmp1_swap (8ul *! nlimb s) 1ul in
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap (8ul *! nlimb s) 1ul == swap);
// bit 255 is 0 and bit 254 is 1
cswap2 #s (u64 1) nq nq_p1;
point_add_and_double #s q p01_tmp1 tmp2;
swap.(0ul) <- u64 1;
//Got about 1K speedup by removing 4 iterations here.
//First iteration can be skipped because top bit of scalar is 0
ladder_step_loop #s k q p01_tmp1_swap tmp2;
let sw = swap.(0ul) in
cswap2 #s sw nq nq_p1
val ladder1_:
#s:field_spec
-> p01_tmp1:lbuffer (limb s) (8ul *! nlimb s)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 p01_tmp1 /\ live h0 tmp2 /\ disjoint p01_tmp1 tmp2 /\
(let nq = gsub p01_tmp1 0ul (2ul *! nlimb s) in
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1 |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1 0ul (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq == M.montgomery_ladder1_1 (fget_xz h0 nq)))
[@ Meta.Attribute.inline_ ]
let ladder1_ #s p01_tmp1 tmp2 =
let nq : point s = sub p01_tmp1 0ul (2ul *! nlimb s) in
let tmp1 = sub p01_tmp1 (4ul *! nlimb s) (4ul *! nlimb s) in
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (4ul *! nlimb s) (4ul *! nlimb s) == tmp1);
point_double nq tmp1 tmp2;
point_double nq tmp1 tmp2;
point_double nq tmp1 tmp2
val ladder2_:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
(let nq' = M.montgomery_ladder1_0 (as_seq h0 k) (fget_xz h0 q) (fget_xz h0 nq) (fget_xz h0 nq_p1) in
fget_xz h1 nq == M.montgomery_ladder1_1 nq')))
[@ Meta.Attribute.inline_ ]
let ladder2_ #s k q p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let nq : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 : point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
ladder0_ #s k q p01_tmp1_swap tmp2;
ladder1_ #s p01_tmp1 tmp2
inline_for_extraction noextract
val ladder3_:
#s:field_spec
-> q:point s
-> p01:lbuffer (limb s) (4ul *! nlimb s)
-> Stack unit
(requires fun h0 ->
live h0 q /\ live h0 p01 /\ disjoint q p01 /\
fget_z h0 q == 1 /\ state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q))
(ensures fun h0 _ h1 ->
modifies (loc p01) h0 h1 /\
(let nq = gsub p01 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x q) /\ state_inv_t h1 (get_z q) /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1) /\ | {
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.AddAndDouble.fst.checked",
"Hacl.Impl.Curve25519.Finv.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"Hacl.Impl.Curve25519.Fields.fst.checked",
"Hacl.Impl.Curve25519.AddAndDouble.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Generic.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.AddAndDouble",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.AddAndDouble",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Finv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": true,
"z3rlimit": 800,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
q: Hacl.Impl.Curve25519.AddAndDouble.point s ->
p01:
Lib.Buffer.lbuffer (Hacl.Impl.Curve25519.Fields.Core.limb s)
(4ul *! Hacl.Impl.Curve25519.Fields.Core.nlimb s)
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Hacl.Impl.Curve25519.AddAndDouble.point",
"Lib.Buffer.lbuffer",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Prims._assert",
"Prims.l_and",
"Hacl.Impl.Curve25519.Fields.Core.state_inv_t",
"Hacl.Impl.Curve25519.AddAndDouble.get_x",
"Hacl.Impl.Curve25519.AddAndDouble.get_z",
"Prims.unit",
"Prims.eq2",
"Prims.int",
"Hacl.Impl.Curve25519.AddAndDouble.fget_z",
"Hacl.Impl.Curve25519.AddAndDouble.fget_x",
"Spec.Curve25519.elem",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.Buffer.gsub",
"Lib.IntTypes.op_Plus_Bang",
"Lib.Buffer.buffer_t",
"Prims.l_or",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.Buffer.length",
"Lib.IntTypes.v",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.Curve25519.Fields.set_zero",
"Hacl.Impl.Curve25519.Fields.set_one",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Lib.Buffer.sub",
"Lib.Buffer.copy"
] | [] | false | true | false | false | false | let ladder3_ #s q p01 =
| let p0:point s = sub p01 0ul (2ul *! nlimb s) in
let p1:point s = sub p01 (2ul *! nlimb s) (2ul *! nlimb s) in
copy p1 q;
let x0:felem s = sub p0 0ul (nlimb s) in
let z0:felem s = sub p0 (nlimb s) (nlimb s) in
set_one x0;
set_zero z0;
let h0 = ST.get () in
assert (gsub p01 0ul (2ul *! nlimb s) == p0);
assert (gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) == p1);
assert (gsub p0 0ul (nlimb s) == x0);
assert (gsub p0 (nlimb s) (nlimb s) == z0);
assert (fget_x h0 p1 == fget_x h0 q);
assert (fget_z h0 p1 == 1);
assert (fget_x h0 p0 == 1);
assert (fget_z h0 p0 == 0);
assert (state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\ state_inv_t h0 (get_x p0) /\
state_inv_t h0 (get_z p0) /\ state_inv_t h0 (get_x p1) /\ state_inv_t h0 (get_z p1)) | false |
Pulse.Lib.Reference.fst | Pulse.Lib.Reference.share2 | val share2 (#a:Type) (r:ref a) (#v:erased a)
: stt_ghost unit
(pts_to r v)
(fun _ -> pts_to r #one_half v ** pts_to r #one_half v) | val share2 (#a:Type) (r:ref a) (#v:erased a)
: stt_ghost unit
(pts_to r v)
(fun _ -> pts_to r #one_half v ** pts_to r #one_half v) | let share2 (#a:Type) (r:ref a) (#v:erased a)
: stt_ghost unit
(pts_to r v)
(fun _ -> pts_to r #one_half v ** pts_to r #one_half v)
= share #a r #v | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Reference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 15,
"end_line": 128,
"start_col": 0,
"start_line": 124
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.Reference
open Pulse.Lib.Core
open Pulse.Main
module H = Pulse.Lib.HigherReference
module U = FStar.Universe
let ref a = H.ref (U.raise_t a)
let pts_to
(#a:Type u#0)
(r:ref a)
(#[exact (`full_perm)] [@@@equate_by_smt] p:perm)
([@@@equate_by_smt] v:a)
= H.pts_to r #p (U.raise_val v)
```pulse
fn alloc' (#a:Type u#0) (v:a)
requires emp
returns r:ref a
ensures pts_to r v
{
let r = H.alloc (U.raise_val v);
fold (pts_to r #full_perm v);
r
}
```
let alloc = alloc'
```pulse
fn read (#a:Type) (r:ref a) (#n:erased a) (#p:perm)
requires pts_to r #p n
returns x:a
ensures pts_to r #p n ** pure (eq2 #a (reveal n) x)
{
unfold (pts_to r #p n);
let k = H.( !r );
fold (pts_to r #p n);
U.downgrade_val k
}
```
let ( ! ) #a = read #a
```pulse
fn write (#a:Type) (r:ref a) (x:a) (#n:erased a)
requires pts_to r #full_perm n
ensures pts_to r #full_perm x
{
unfold (pts_to r #full_perm n);
H.(r := (U.raise_val x));
fold (pts_to r #full_perm x)
}
```
let ( := ) #a r x #n = write #a r x #n
```pulse
fn free' #a (r:ref a) (#n:erased a)
requires pts_to r #full_perm n
ensures emp
{
unfold (pts_to r #full_perm n);
H.free r;
}
```
let free = free'
```pulse
ghost
fn share' (#a:Type) (r:ref a) (#v:erased a) (#p:perm)
requires pts_to r #p v
ensures pts_to r #(half_perm p) v ** pts_to r #(half_perm p) v
{
unfold pts_to r #p v;
H.share r;
fold pts_to r #(half_perm p) v;
fold pts_to r #(half_perm p) v
}
```
let share = share'
```pulse
ghost
fn raise_inj (a:Type u#0) (x0 x1:a)
requires pure (U.raise_val u#0 u#1 x0 == U.raise_val u#0 u#1 x1)
ensures pure (x0 == x1)
{
assert pure (U.downgrade_val (U.raise_val u#0 u#1 x0) == x0);
assert pure (U.downgrade_val (U.raise_val u#0 u#1 x1) == x1);
}
```
```pulse
ghost
fn gather' (#a:Type) (r:ref a) (#x0 #x1:erased a) (#p0 #p1:perm)
requires pts_to r #p0 x0 ** pts_to r #p1 x1
ensures pts_to r #(sum_perm p0 p1) x0 ** pure (x0 == x1)
{
unfold pts_to r #p0 x0;
unfold pts_to r #p1 x1;
H.gather r;
fold (pts_to r #(sum_perm p1 p0) x0);
let qq = sum_perm p0 p1; //hack! prevent the unifier from structurally matching sum_perm p0 p1 with sum_perm p1 p0
rewrite (pts_to r #(sum_perm p1 p0) x0)
as (pts_to r #qq x0);
raise_inj a x0 x1;
}
```
let gather = gather' | {
"checked_file": "/",
"dependencies": [
"Pulse.Main.fsti.checked",
"Pulse.Lib.HigherReference.fsti.checked",
"Pulse.Lib.Core.fsti.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Lib.Reference.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Pulse.Lib.HigherReference",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Pulse.Main",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.Observability",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"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: Pulse.Lib.Reference.ref a
-> Pulse.Lib.Core.stt_ghost Prims.unit
(Pulse.Lib.Reference.pts_to r (FStar.Ghost.reveal v))
(fun _ ->
Pulse.Lib.Reference.pts_to r (FStar.Ghost.reveal v) **
Pulse.Lib.Reference.pts_to r (FStar.Ghost.reveal v)) | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.Reference.ref",
"FStar.Ghost.erased",
"Pulse.Lib.Reference.share",
"PulseCore.FractionalPermission.full_perm",
"Pulse.Lib.Core.stt_ghost",
"Prims.unit",
"Pulse.Lib.Reference.pts_to",
"FStar.Ghost.reveal",
"Pulse.Lib.Core.op_Star_Star",
"Pulse.Lib.Core.one_half",
"Pulse.Lib.Core.vprop"
] | [] | false | false | false | false | false | let share2 (#a: Type) (r: ref a) (#v: erased a)
: stt_ghost unit (pts_to r v) (fun _ -> pts_to r #one_half v ** pts_to r #one_half v) =
| share #a r #v | false |
Pulse.Lib.Reference.fst | Pulse.Lib.Reference.gather | val gather (#a:Type) (r:ref a) (#x0 #x1:erased a) (#p0 #p1:perm)
: stt_ghost unit
(pts_to r #p0 x0 ** pts_to r #p1 x1)
(fun _ -> pts_to r #(sum_perm p0 p1) x0 ** pure (x0 == x1)) | val gather (#a:Type) (r:ref a) (#x0 #x1:erased a) (#p0 #p1:perm)
: stt_ghost unit
(pts_to r #p0 x0 ** pts_to r #p1 x1)
(fun _ -> pts_to r #(sum_perm p0 p1) x0 ** pure (x0 == x1)) | let gather = gather' | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Reference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 20,
"end_line": 122,
"start_col": 0,
"start_line": 122
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.Reference
open Pulse.Lib.Core
open Pulse.Main
module H = Pulse.Lib.HigherReference
module U = FStar.Universe
let ref a = H.ref (U.raise_t a)
let pts_to
(#a:Type u#0)
(r:ref a)
(#[exact (`full_perm)] [@@@equate_by_smt] p:perm)
([@@@equate_by_smt] v:a)
= H.pts_to r #p (U.raise_val v)
```pulse
fn alloc' (#a:Type u#0) (v:a)
requires emp
returns r:ref a
ensures pts_to r v
{
let r = H.alloc (U.raise_val v);
fold (pts_to r #full_perm v);
r
}
```
let alloc = alloc'
```pulse
fn read (#a:Type) (r:ref a) (#n:erased a) (#p:perm)
requires pts_to r #p n
returns x:a
ensures pts_to r #p n ** pure (eq2 #a (reveal n) x)
{
unfold (pts_to r #p n);
let k = H.( !r );
fold (pts_to r #p n);
U.downgrade_val k
}
```
let ( ! ) #a = read #a
```pulse
fn write (#a:Type) (r:ref a) (x:a) (#n:erased a)
requires pts_to r #full_perm n
ensures pts_to r #full_perm x
{
unfold (pts_to r #full_perm n);
H.(r := (U.raise_val x));
fold (pts_to r #full_perm x)
}
```
let ( := ) #a r x #n = write #a r x #n
```pulse
fn free' #a (r:ref a) (#n:erased a)
requires pts_to r #full_perm n
ensures emp
{
unfold (pts_to r #full_perm n);
H.free r;
}
```
let free = free'
```pulse
ghost
fn share' (#a:Type) (r:ref a) (#v:erased a) (#p:perm)
requires pts_to r #p v
ensures pts_to r #(half_perm p) v ** pts_to r #(half_perm p) v
{
unfold pts_to r #p v;
H.share r;
fold pts_to r #(half_perm p) v;
fold pts_to r #(half_perm p) v
}
```
let share = share'
```pulse
ghost
fn raise_inj (a:Type u#0) (x0 x1:a)
requires pure (U.raise_val u#0 u#1 x0 == U.raise_val u#0 u#1 x1)
ensures pure (x0 == x1)
{
assert pure (U.downgrade_val (U.raise_val u#0 u#1 x0) == x0);
assert pure (U.downgrade_val (U.raise_val u#0 u#1 x1) == x1);
}
```
```pulse
ghost
fn gather' (#a:Type) (r:ref a) (#x0 #x1:erased a) (#p0 #p1:perm)
requires pts_to r #p0 x0 ** pts_to r #p1 x1
ensures pts_to r #(sum_perm p0 p1) x0 ** pure (x0 == x1)
{
unfold pts_to r #p0 x0;
unfold pts_to r #p1 x1;
H.gather r;
fold (pts_to r #(sum_perm p1 p0) x0);
let qq = sum_perm p0 p1; //hack! prevent the unifier from structurally matching sum_perm p0 p1 with sum_perm p1 p0
rewrite (pts_to r #(sum_perm p1 p0) x0)
as (pts_to r #qq x0);
raise_inj a x0 x1;
} | {
"checked_file": "/",
"dependencies": [
"Pulse.Main.fsti.checked",
"Pulse.Lib.HigherReference.fsti.checked",
"Pulse.Lib.Core.fsti.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Lib.Reference.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Pulse.Lib.HigherReference",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Pulse.Main",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.Observability",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"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: Pulse.Lib.Reference.ref a
-> Pulse.Lib.Core.stt_ghost Prims.unit
(Pulse.Lib.Reference.pts_to r (FStar.Ghost.reveal x0) **
Pulse.Lib.Reference.pts_to r (FStar.Ghost.reveal x1))
(fun _ ->
Pulse.Lib.Reference.pts_to r (FStar.Ghost.reveal x0) ** Pulse.Lib.Core.pure (x0 == x1)) | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.Reference.gather'"
] | [] | false | false | false | false | false | let gather =
| gather' | false |
Pulse.Typing.Combinators.fst | Pulse.Typing.Combinators.apply_frame | val apply_frame (#g:env)
(#t:st_term)
(#ctxt:term)
(ctxt_typing: tot_typing g ctxt tm_vprop)
(#c:comp { stateful_comp c })
(t_typing: st_typing g t c)
(frame_t:frame_for_req_in_ctxt g ctxt (comp_pre c))
: Tot (c':comp_st { comp_pre c' == ctxt /\
comp_res c' == comp_res c /\
comp_u c' == comp_u c /\
comp_post c' == tm_star (comp_post c) (frame_of frame_t) } &
st_typing g t c') | val apply_frame (#g:env)
(#t:st_term)
(#ctxt:term)
(ctxt_typing: tot_typing g ctxt tm_vprop)
(#c:comp { stateful_comp c })
(t_typing: st_typing g t c)
(frame_t:frame_for_req_in_ctxt g ctxt (comp_pre c))
: Tot (c':comp_st { comp_pre c' == ctxt /\
comp_res c' == comp_res c /\
comp_u c' == comp_u c /\
comp_post c' == tm_star (comp_post c) (frame_of frame_t) } &
st_typing g t c') | let apply_frame (#g:env)
(#t:st_term)
(#ctxt:term)
(ctxt_typing: tot_typing g ctxt tm_vprop)
(#c:comp { stateful_comp c })
(t_typing: st_typing g t c)
(frame_t:frame_for_req_in_ctxt g ctxt (comp_pre c))
: Tot (c':comp_st { comp_pre c' == ctxt /\
comp_res c' == comp_res c /\
comp_u c' == comp_u c /\
comp_post c' == tm_star (comp_post c) (frame_of frame_t) } &
st_typing g t c')
= let s = st_comp_of_comp c in
let (| frame, frame_typing, ve |) = frame_t in
let t_typing
: st_typing g t (Pulse.Typing.add_frame c frame)
= T_Frame g t c frame frame_typing t_typing in
let c' = Pulse.Typing.add_frame c frame in
let c'_typing = Metatheory.st_typing_correctness t_typing in
let s' = st_comp_of_comp c' in
let ve: vprop_equiv g s'.pre ctxt = ve in
let s'' = { s' with pre = ctxt } in
let c'' = c' `with_st_comp` s'' in
assert (comp_post c' == comp_post c'');
let ve: vprop_equiv g (comp_pre c') (comp_pre c'') = ve in
let st_typing = fst <| Metatheory.comp_typing_inversion c'_typing in
let (| res_typing, pre_typing, x, post_typing |) = Metatheory.st_comp_typing_inversion st_typing in
let st_equiv = ST_VPropEquiv g c' c'' x pre_typing res_typing post_typing (RT.Rel_refl _ _ _) ve (VE_Refl _ _) in
let t_typing = T_Equiv _ _ _ _ t_typing st_equiv in
(| c'', t_typing |) | {
"file_name": "lib/steel/pulse/Pulse.Typing.Combinators.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 23,
"end_line": 455,
"start_col": 0,
"start_line": 426
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Typing.Combinators
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
assume
val invert_forall_typing
(#g #u #b #body:_)
(d:tot_typing g (tm_forall_sl u b body) tm_vprop)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
: GTot (
tot_typing g b.binder_ty (tm_type u) &
tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop
)
assume
val construct_forall_typing
(#g #u #b #body:_)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
(dt:tot_typing g b.binder_ty (tm_type u))
(db:tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop)
: GTot (tot_typing g (tm_forall_sl u b body) tm_vprop)
let rec vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1)
: GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop))
(decreases v)
= match v with
| VE_Refl _ _ -> (fun x -> x), (fun x -> x)
| VE_Sym _ _ _ v' ->
let f, g = vprop_equiv_typing v' in
g, f
| VE_Trans g t0 t2 t1 v02 v21 ->
let f02, f20 = vprop_equiv_typing v02 in
let f21, f12 = vprop_equiv_typing v21 in
(fun x -> f21 (f02 x)),
(fun x -> f20 (f12 x))
| VE_Ctxt g s0 s1 s0' s1' v0 v1 ->
let f0, f0' = vprop_equiv_typing v0 in
let f1, f1' = vprop_equiv_typing v1 in
let ff (x:tot_typing g (tm_star s0 s1) tm_vprop)
: tot_typing g (tm_star s0' s1') tm_vprop
= let s0_typing = star_typing_inversion_l x in
let s1_typing = star_typing_inversion_r x in
let s0'_typing, s1'_typing = f0 s0_typing, f1 s1_typing in
star_typing s0'_typing s1'_typing
in
let gg (x:tot_typing g (tm_star s0' s1') tm_vprop)
: tot_typing g (tm_star s0 s1) tm_vprop
= let s0'_typing = star_typing_inversion_l x in
let s1'_typing = star_typing_inversion_r x in
star_typing (f0' s0'_typing) (f1' s1'_typing)
in
ff, gg
| VE_Unit g t ->
let fwd (x:tot_typing g (tm_star tm_emp t) tm_vprop)
: tot_typing g t tm_vprop
= let r = star_typing_inversion_r x in
r
in
let bk (x:tot_typing g t tm_vprop)
: tot_typing g (tm_star tm_emp t) tm_vprop
= star_typing emp_typing x
in
fwd, bk
| VE_Comm g t0 t1 ->
let f t0 t1 (x:tot_typing g (tm_star t0 t1) tm_vprop)
: tot_typing g (tm_star t1 t0) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt1 = star_typing_inversion_r x in
star_typing tt1 tt0
in
f t0 t1, f t1 t0
| VE_Assoc g t0 t1 t2 ->
let fwd (x:tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop)
: tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt12 = star_typing_inversion_r x in
let tt1 = star_typing_inversion_l tt12 in
let tt2 = star_typing_inversion_r tt12 in
star_typing (star_typing tt0 tt1) tt2
in
let bk (x : tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop)
: tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop
= let tt01 = star_typing_inversion_l x in
let tt2 = star_typing_inversion_r x in
let tt0 = star_typing_inversion_l tt01 in
let tt1 = star_typing_inversion_r tt01 in
star_typing tt0 (star_typing tt1 tt2)
in
fwd, bk
| VE_Ext g t0 t1 token ->
let d1, d2 = vprop_eq_typing_inversion g t0 t1 token in
(fun _ -> d2),
(fun _ -> d1)
| VE_Fa g x u b t0 t1 d ->
let d0, d1 = vprop_equiv_typing d in
(fun fa0_typing ->
let b_typing, t0_typing = invert_forall_typing fa0_typing x in
let t1_typing = d0 t0_typing in
construct_forall_typing #g #u x b_typing t1_typing),
(fun fa1_typing ->
let b_typing, t1_typing = invert_forall_typing fa1_typing x in
let t0_typing = d1 t1_typing in
construct_forall_typing #g #u #b #t0 x b_typing t0_typing)
#push-options "--z3rlimit_factor 8 --ifuel 1 --fuel 2 --query_stats"
let bind_t (case_c1 case_c2:comp_st -> bool) =
(g:env) ->
(pre:term) ->
(e1:st_term) ->
(e2:st_term) ->
(c1:comp_st{ case_c1 c1 }) ->
(c2:comp_st{ case_c2 c2 }) ->
(px:nvar { ~ (Set.mem (snd px) (dom g)) }) ->
(d_e1:st_typing g e1 c1) ->
(d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1))) ->
(d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2) ->
(res_typing:universe_of g (comp_res c2) (comp_u c2)) ->
(post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop) ->
(bias_towards_continuation:bool) ->
T.TacH (t:st_term &
c:comp_st { st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires fun _ ->
let _, x = px in
comp_pre c1 == pre /\
None? (lookup g x) /\
(~(x `Set.mem` freevars_st e2)) /\
open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))))
(ensures fun _ _ -> True)
let mk_bind_st_st
: bind_t C_ST? C_ST?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
let inames_of (c:comp_st) : term =
match c with
| C_ST _
| C_STGhost _ -> tm_emp_inames
| C_STAtomic inames _ _ -> inames
let with_inames (c:comp_st) (i:term) =
match c with
| C_ST _ -> c
| C_STGhost sc -> C_STGhost sc
| C_STAtomic _ obs sc -> C_STAtomic i obs sc
let weaken_comp_inames (#g:env) (#e:st_term) (#c:comp_st) (d_e:st_typing g e c) (new_inames:term)
: T.Tac (c':comp_st { with_inames c new_inames == c' } &
st_typing g e c')
= match c with
| C_ST _
| C_STGhost _ -> (| c, d_e |)
| C_STAtomic inames obs sc ->
let d_e = T_Sub _ _ _ _ d_e (STS_AtomicInvs _ sc inames new_inames obs obs (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
(| with_inames c new_inames, d_e |)
let st_ghost_as_atomic (c:comp_st { C_STGhost? c }) =
C_STAtomic tm_emp_inames Neutral (st_comp_of_comp c)
let try_lift_ghost_atomic (#g:env) (#e:st_term) (#c:comp_st { C_STGhost? c }) (d:st_typing g e c)
: T.Tac (option (st_typing g e (st_ghost_as_atomic c)))
= let w = try_get_non_informative_witness g (comp_u c) (comp_res c) in
match w with
| None -> None
| Some w ->
let d = T_Lift _ _ _ _ d (Lift_Ghost_Neutral _ c w) in
Some d
let lift_ghost_atomic (#g:env) (#e:st_term) (#c:comp_st { C_STGhost? c }) (d:st_typing g e c)
: T.Tac (st_typing g e (st_ghost_as_atomic c))
= let w = try_lift_ghost_atomic d in
match w with
| None ->
let open Pulse.PP in
let t = comp_res c in
fail_doc g (Some t.range) [
text "Expected a term with a non-informative (e.g., erased) type; got"
^/^ pp t
]
| Some d ->
d
let mk_bind_ghost_ghost
: bind_t C_STGhost? C_STGhost?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
#push-options "--query_stats"
let mk_bind_atomic_atomic
: bind_t C_STAtomic? C_STAtomic?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_k ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let C_STAtomic inames1 obs1 sc1 = c1 in
let C_STAtomic inames2 obs2 sc2 = c2 in
if at_most_one_observable obs1 obs2
then (
if eq_tm inames1 inames2
then begin
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
end
else if bias_k
then (
let d_e1 = T_Sub _ _ _ _ d_e1 (STS_AtomicInvs _ sc1 inames1 inames2 obs1 obs1 (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
let c1 = C_STAtomic inames2 obs1 sc1 in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
)
else begin
let new_inames = tm_join_inames inames1 inames2 in
let d_e1 = T_Sub _ _ _ _ d_e1 (STS_AtomicInvs _ sc1 inames1 new_inames obs1 obs1 (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
let d_e2 = T_Sub _ _ _ _ d_e2 (STS_AtomicInvs _ sc2 inames2 new_inames obs2 obs2 (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
let c1 = C_STAtomic new_inames obs1 sc1 in
let c2 = C_STAtomic new_inames obs2 sc2 in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
end
)
else (
T.fail "Should have been handled separately"
)
let rec mk_bind (g:env)
(pre:term)
(e1:st_term)
(e2:st_term)
(c1:comp_st)
(c2:comp_st)
(px:nvar { ~ (Set.mem (snd px) (dom g)) })
(d_e1:st_typing g e1 c1)
(d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1)))
(d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2)
(res_typing:universe_of g (comp_res c2) (comp_u c2))
(post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop)
(bias_towards_continuation:bool)
: T.TacH (t:st_term &
c:comp_st {
st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires fun _ ->
let _, x = px in
comp_pre c1 == pre /\
None? (lookup g x) /\
(~(x `Set.mem` freevars_st e2)) /\
open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))))
(ensures fun _ _ -> True) =
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let fail_bias (#a:Type) tag
: T.TacH a (requires fun _ -> True) (ensures fun _ r -> FStar.Tactics.Result.Failed? r)
= let open Pulse.PP in
fail_doc g (Some e1.range)
[text "Cannot compose computations in this " ^/^ text tag ^/^ text " block:";
prefix 4 1 (text "This computation has effect: ") (pp (effect_annot_of_comp c1));
prefix 4 1 (text "The continuation has effect: ") (pp (effect_annot_of_comp c2))]
in
match c1, c2 with
| C_ST _, C_ST _ ->
mk_bind_st_st g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
| C_STGhost _, C_STGhost _ ->
mk_bind_ghost_ghost g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
| C_STAtomic inames1 obs1 sc1, C_STAtomic inames2 obs2 sc2 ->
if at_most_one_observable obs1 obs2
then (
mk_bind_atomic_atomic g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
)
else if bias_towards_continuation
then fail_bias "atomic"
else (
let d_e1 = T_Lift _ _ _ _ d_e1 (Lift_STAtomic_ST _ c1) in
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
)
| C_STAtomic inames _ _, C_ST _ ->
let d_e1 = T_Lift _ _ _ _ d_e1 (Lift_STAtomic_ST _ c1) in
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
| C_ST _, C_STAtomic inames _ _ ->
if bias_towards_continuation
then fail_bias "atomic"
else (
let d_e2 = T_Lift _ _ _ _ d_e2 (Lift_STAtomic_ST _ c2) in
let (| t, c, d |) = mk_bind g pre e1 e2 _ _ px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation in
(| t, c, d |)
)
| C_STGhost _, C_STAtomic _ Neutral _ -> (
match try_lift_ghost_atomic d_e1 with
| Some d_e1 ->
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
| None ->
if bias_towards_continuation
then fail_bias "atomic"
else (
let d_e2 = T_Lift _ _ _ _ d_e2 (Lift_Neutral_Ghost _ c2) in
let (| t, c, d |) = mk_bind g pre e1 e2 _ _ px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation in
(| t, c, d |)
)
)
| C_STAtomic _ Neutral _, C_STGhost _ -> (
if bias_towards_continuation
then (
let d_e1 = T_Lift _ _ _ _ d_e1 (Lift_Neutral_Ghost _ c1) in
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
)
else (
match try_lift_ghost_atomic d_e2 with
| Some d_e2 ->
let (| t, c, d |) = mk_bind g pre e1 e2 _ _ px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation in
(| t, c, d |)
| None ->
let d_e1 = T_Lift _ _ _ _ d_e1 (Lift_Neutral_Ghost _ c1) in
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
)
)
| C_STGhost _, C_ST _
| C_STGhost _, C_STAtomic _ _ _ ->
let d_e1 = lift_ghost_atomic d_e1 in
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
| C_ST _, C_STGhost _
| C_STAtomic _ _ _, C_STGhost _ ->
if bias_towards_continuation
then fail_bias "ghost"
else (
let d_e2 = lift_ghost_atomic d_e2 in
let (| t, c, d |) = mk_bind g pre e1 e2 _ _ px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation in
(| t, c, d |)
)
#pop-options
let bind_res_and_post_typing g c2 x post_hint
= let s2 = st_comp_of_comp c2 in
match post_hint with
| None ->
(* We're inferring a post, so these checks are unavoidable *)
(* since we need to type the result in a smaller env g *)
let (| u, res_typing |) = check_universe g s2.res in
if not (eq_univ u s2.u)
then fail g None "Unexpected universe for result type"
else if x `Set.mem` freevars s2.post
then fail g None (Printf.sprintf "Bound variable %d escapes scope in postcondition %s" x (P.term_to_string s2.post))
else (
let y = x in //fresh g in
let s2_post_opened = open_term_nv s2.post (v_as_nv y) in
let post_typing =
check_vprop_with_core (push_binding g y ppname_default s2.res) s2_post_opened in
res_typing, post_typing
)
| Some post ->
if x `Set.mem` freevars s2.post
then fail g None "Unexpected mismatched postcondition in bind" //exclude with a stronger type on check'
else (
let pr = post_hint_typing g post x in
pr.ty_typing, pr.post_typing
)
let add_frame (#g:env) (#t:st_term) (#c:comp_st) (t_typing:st_typing g t c)
(#frame:vprop)
(frame_typing:tot_typing g frame tm_vprop)
: t':st_term &
c':comp_st { c' == add_frame c frame } &
st_typing g t' c' =
(| t, add_frame c frame, T_Frame _ _ _ _ frame_typing t_typing |) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.PP.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Result.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Typing.Combinators.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
ctxt_typing: Pulse.Typing.tot_typing g ctxt Pulse.Syntax.Base.tm_vprop ->
t_typing: Pulse.Typing.st_typing g t c ->
frame_t: Pulse.Typing.Combinators.frame_for_req_in_ctxt g ctxt (Pulse.Syntax.Base.comp_pre c)
-> Prims.dtuple2 (c':
Pulse.Syntax.Base.comp_st
{ Pulse.Syntax.Base.comp_pre c' == ctxt /\
Pulse.Syntax.Base.comp_res c' == Pulse.Syntax.Base.comp_res c /\
Pulse.Syntax.Base.comp_u c' == Pulse.Syntax.Base.comp_u c /\
Pulse.Syntax.Base.comp_post c' ==
Pulse.Syntax.Base.tm_star (Pulse.Syntax.Base.comp_post c)
(Pulse.Typing.Combinators.frame_of frame_t) })
(fun c' -> Pulse.Typing.st_typing g t c') | Prims.Tot | [
"total"
] | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.st_term",
"Pulse.Syntax.Base.term",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.tm_vprop",
"Pulse.Syntax.Base.comp",
"Prims.b2t",
"Pulse.Syntax.Base.stateful_comp",
"Pulse.Typing.st_typing",
"Pulse.Typing.Combinators.frame_for_req_in_ctxt",
"Pulse.Syntax.Base.comp_pre",
"Pulse.Typing.vprop_equiv",
"Pulse.Syntax.Base.tm_star",
"Pulse.Typing.universe_of",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__res",
"Pulse.Syntax.Base.st_comp_of_comp",
"Pulse.Typing.add_frame",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__u",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__pre",
"Pulse.Syntax.Base.var",
"Pulse.Typing.fresh_wrt",
"Pulse.Syntax.Naming.freevars",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__post",
"Pulse.Typing.Env.push_binding",
"Pulse.Syntax.Base.ppname_default",
"Pulse.Syntax.Naming.open_term",
"Prims.Mkdtuple2",
"Pulse.Syntax.Base.comp_st",
"Prims.l_and",
"Prims.eq2",
"Pulse.Syntax.Base.comp_res",
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.comp_u",
"Pulse.Syntax.Base.comp_post",
"Pulse.Typing.Combinators.frame_of",
"Pulse.Typing.T_Equiv",
"Pulse.Typing.st_equiv",
"Pulse.Typing.ST_VPropEquiv",
"FStar.Reflection.Typing.Rel_refl",
"Pulse.Typing.elab_env",
"Pulse.Elaborate.Pure.elab_term",
"FStar.Reflection.Typing.R_Eq",
"Pulse.Typing.VE_Refl",
"Prims.dtuple2",
"FStar.Pervasives.dtuple4",
"Pulse.Typing.Metatheory.Base.st_comp_typing_inversion",
"Pulse.Typing.st_comp_typing",
"FStar.Pervasives.Native.fst",
"Pulse.Typing.Metatheory.Base.iname_typing",
"Pulse.Typing.Metatheory.Base.comp_typing_inversion",
"Prims.unit",
"Prims._assert",
"Pulse.Syntax.Base.vprop",
"Pulse.Syntax.Base.with_st_comp",
"Pulse.Syntax.Base.st_comp",
"Pulse.Syntax.Base.Mkst_comp",
"Pulse.Typing.comp_typing_u",
"Pulse.Typing.Metatheory.Base.st_typing_correctness",
"Pulse.Typing.T_Frame"
] | [] | false | false | false | false | false | let apply_frame
(#g: env)
(#t: st_term)
(#ctxt: term)
(ctxt_typing: tot_typing g ctxt tm_vprop)
(#c: comp{stateful_comp c})
(t_typing: st_typing g t c)
(frame_t: frame_for_req_in_ctxt g ctxt (comp_pre c))
: Tot
(c':
comp_st
{ comp_pre c' == ctxt /\ comp_res c' == comp_res c /\ comp_u c' == comp_u c /\
comp_post c' == tm_star (comp_post c) (frame_of frame_t) } &
st_typing g t c') =
| let s = st_comp_of_comp c in
let (| frame , frame_typing , ve |) = frame_t in
let t_typing:st_typing g t (Pulse.Typing.add_frame c frame) =
T_Frame g t c frame frame_typing t_typing
in
let c' = Pulse.Typing.add_frame c frame in
let c'_typing = Metatheory.st_typing_correctness t_typing in
let s' = st_comp_of_comp c' in
let ve:vprop_equiv g s'.pre ctxt = ve in
let s'' = { s' with pre = ctxt } in
let c'' = c' `with_st_comp` s'' in
assert (comp_post c' == comp_post c'');
let ve:vprop_equiv g (comp_pre c') (comp_pre c'') = ve in
let st_typing = fst <| Metatheory.comp_typing_inversion c'_typing in
let (| res_typing , pre_typing , x , post_typing |) =
Metatheory.st_comp_typing_inversion st_typing
in
let st_equiv =
ST_VPropEquiv g c' c'' x pre_typing res_typing post_typing (RT.Rel_refl _ _ _) ve (VE_Refl _ _)
in
let t_typing = T_Equiv _ _ _ _ t_typing st_equiv in
(| c'', t_typing |) | false |
Hacl.Streaming.Blake2s_128.fst | Hacl.Streaming.Blake2s_128.digest | val digest : Hacl.Streaming.Functor.digest_st (Hacl.Streaming.Blake2s_128.blake2s_128 0)
()
(Hacl.Streaming.Blake2.Common.s Spec.Blake2.Definitions.Blake2S Hacl.Impl.Blake2.Core.M128)
(Hacl.Streaming.Blake2.Common.empty_key Spec.Blake2.Definitions.Blake2S) | let digest =
F.digest (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | {
"file_name": "code/streaming/Hacl.Streaming.Blake2s_128.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 95,
"end_line": 42,
"start_col": 0,
"start_line": 41
} | module Hacl.Streaming.Blake2s_128
module Blake2s128 = Hacl.Blake2s_128
module Common = Hacl.Streaming.Blake2.Common
module Core = Hacl.Impl.Blake2.Core
module F = Hacl.Streaming.Functor
module G = FStar.Ghost
module Impl = Hacl.Impl.Blake2.Generic
module Spec = Spec.Blake2
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// The functor
inline_for_extraction noextract
let blake2s_128 kk =
Common.blake2 Spec.Blake2S Core.M128 kk Blake2s128.init Blake2s128.update_multi
Blake2s128.update_last Blake2s128.finish
/// Type abbreviations
let block_state_t = Common.s Spec.Blake2S Core.M128
let state_t = F.state_s (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
/// No key
inline_for_extraction noextract
let alloca =
F.alloca (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
[@ (Comment " State allocation function when there is no key")]
let malloc =
F.malloc (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
[@ (Comment " Re-initialization function when there is no key")]
let reset =
F.reset (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
[@ (Comment " Update function when there is no key; 0 = success, 1 = max length exceeded")]
let update =
F.update (blake2s_128 0) (G.hide ()) (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Streaming.Blake2.Common.fst.checked",
"Hacl.Impl.Blake2.Generic.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Blake2s_128.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Blake2s_128.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Generic",
"short_module": "Impl"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Core"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Blake2.Common",
"short_module": "Common"
},
{
"abbrev": true,
"full_module": "Hacl.Blake2s_128",
"short_module": "Blake2s128"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Hacl.Streaming.Functor.digest_st (Hacl.Streaming.Blake2s_128.blake2s_128 0)
()
(Hacl.Streaming.Blake2.Common.s Spec.Blake2.Definitions.Blake2S Hacl.Impl.Blake2.Core.M128)
(Hacl.Streaming.Blake2.Common.empty_key Spec.Blake2.Definitions.Blake2S) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Functor.digest",
"Prims.unit",
"Hacl.Streaming.Blake2s_128.blake2s_128",
"Hacl.Streaming.Blake2.Common.s",
"Spec.Blake2.Definitions.Blake2S",
"Hacl.Impl.Blake2.Core.M128",
"Hacl.Streaming.Blake2.Common.empty_key"
] | [] | false | false | false | false | false | let digest =
| F.digest (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | false |
|
Hacl.Streaming.Blake2s_128.fst | Hacl.Streaming.Blake2s_128.reset | val reset : Hacl.Streaming.Functor.reset_st (Hacl.Streaming.Blake2s_128.blake2s_128 0)
(FStar.Ghost.hide (FStar.Ghost.reveal (FStar.Ghost.hide ())))
(Hacl.Streaming.Blake2.Common.s Spec.Blake2.Definitions.Blake2S Hacl.Impl.Blake2.Core.M128)
(Hacl.Streaming.Blake2.Common.empty_key Spec.Blake2.Definitions.Blake2S) | let reset =
F.reset (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | {
"file_name": "code/streaming/Hacl.Streaming.Blake2s_128.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 94,
"end_line": 34,
"start_col": 0,
"start_line": 33
} | module Hacl.Streaming.Blake2s_128
module Blake2s128 = Hacl.Blake2s_128
module Common = Hacl.Streaming.Blake2.Common
module Core = Hacl.Impl.Blake2.Core
module F = Hacl.Streaming.Functor
module G = FStar.Ghost
module Impl = Hacl.Impl.Blake2.Generic
module Spec = Spec.Blake2
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// The functor
inline_for_extraction noextract
let blake2s_128 kk =
Common.blake2 Spec.Blake2S Core.M128 kk Blake2s128.init Blake2s128.update_multi
Blake2s128.update_last Blake2s128.finish
/// Type abbreviations
let block_state_t = Common.s Spec.Blake2S Core.M128
let state_t = F.state_s (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
/// No key
inline_for_extraction noextract
let alloca =
F.alloca (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
[@ (Comment " State allocation function when there is no key")]
let malloc =
F.malloc (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Streaming.Blake2.Common.fst.checked",
"Hacl.Impl.Blake2.Generic.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Blake2s_128.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Blake2s_128.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Generic",
"short_module": "Impl"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Core"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Blake2.Common",
"short_module": "Common"
},
{
"abbrev": true,
"full_module": "Hacl.Blake2s_128",
"short_module": "Blake2s128"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Hacl.Streaming.Functor.reset_st (Hacl.Streaming.Blake2s_128.blake2s_128 0)
(FStar.Ghost.hide (FStar.Ghost.reveal (FStar.Ghost.hide ())))
(Hacl.Streaming.Blake2.Common.s Spec.Blake2.Definitions.Blake2S Hacl.Impl.Blake2.Core.M128)
(Hacl.Streaming.Blake2.Common.empty_key Spec.Blake2.Definitions.Blake2S) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Functor.reset",
"Prims.unit",
"Hacl.Streaming.Blake2s_128.blake2s_128",
"FStar.Ghost.hide",
"Hacl.Streaming.Blake2.Common.s",
"Spec.Blake2.Definitions.Blake2S",
"Hacl.Impl.Blake2.Core.M128",
"Hacl.Streaming.Blake2.Common.empty_key"
] | [] | false | false | false | false | false | let reset =
| F.reset (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | false |
|
Pulse.Typing.Combinators.fst | Pulse.Typing.Combinators.bind_res_and_post_typing | val bind_res_and_post_typing (g:env) (s2:comp_st) (x:var { fresh_wrt x g (freevars (comp_post s2)) })
(post_hint:post_hint_opt g { comp_post_matches_hint s2 post_hint })
: T.Tac (universe_of g (comp_res s2) (comp_u s2) &
tot_typing (push_binding g x ppname_default (comp_res s2)) (open_term_nv (comp_post s2) (v_as_nv x)) tm_vprop) | val bind_res_and_post_typing (g:env) (s2:comp_st) (x:var { fresh_wrt x g (freevars (comp_post s2)) })
(post_hint:post_hint_opt g { comp_post_matches_hint s2 post_hint })
: T.Tac (universe_of g (comp_res s2) (comp_u s2) &
tot_typing (push_binding g x ppname_default (comp_res s2)) (open_term_nv (comp_post s2) (v_as_nv x)) tm_vprop) | let bind_res_and_post_typing g c2 x post_hint
= let s2 = st_comp_of_comp c2 in
match post_hint with
| None ->
(* We're inferring a post, so these checks are unavoidable *)
(* since we need to type the result in a smaller env g *)
let (| u, res_typing |) = check_universe g s2.res in
if not (eq_univ u s2.u)
then fail g None "Unexpected universe for result type"
else if x `Set.mem` freevars s2.post
then fail g None (Printf.sprintf "Bound variable %d escapes scope in postcondition %s" x (P.term_to_string s2.post))
else (
let y = x in //fresh g in
let s2_post_opened = open_term_nv s2.post (v_as_nv y) in
let post_typing =
check_vprop_with_core (push_binding g y ppname_default s2.res) s2_post_opened in
res_typing, post_typing
)
| Some post ->
if x `Set.mem` freevars s2.post
then fail g None "Unexpected mismatched postcondition in bind" //exclude with a stronger type on check'
else (
let pr = post_hint_typing g post x in
pr.ty_typing, pr.post_typing
) | {
"file_name": "lib/steel/pulse/Pulse.Typing.Combinators.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 7,
"end_line": 415,
"start_col": 0,
"start_line": 391
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Typing.Combinators
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
assume
val invert_forall_typing
(#g #u #b #body:_)
(d:tot_typing g (tm_forall_sl u b body) tm_vprop)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
: GTot (
tot_typing g b.binder_ty (tm_type u) &
tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop
)
assume
val construct_forall_typing
(#g #u #b #body:_)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
(dt:tot_typing g b.binder_ty (tm_type u))
(db:tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop)
: GTot (tot_typing g (tm_forall_sl u b body) tm_vprop)
let rec vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1)
: GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop))
(decreases v)
= match v with
| VE_Refl _ _ -> (fun x -> x), (fun x -> x)
| VE_Sym _ _ _ v' ->
let f, g = vprop_equiv_typing v' in
g, f
| VE_Trans g t0 t2 t1 v02 v21 ->
let f02, f20 = vprop_equiv_typing v02 in
let f21, f12 = vprop_equiv_typing v21 in
(fun x -> f21 (f02 x)),
(fun x -> f20 (f12 x))
| VE_Ctxt g s0 s1 s0' s1' v0 v1 ->
let f0, f0' = vprop_equiv_typing v0 in
let f1, f1' = vprop_equiv_typing v1 in
let ff (x:tot_typing g (tm_star s0 s1) tm_vprop)
: tot_typing g (tm_star s0' s1') tm_vprop
= let s0_typing = star_typing_inversion_l x in
let s1_typing = star_typing_inversion_r x in
let s0'_typing, s1'_typing = f0 s0_typing, f1 s1_typing in
star_typing s0'_typing s1'_typing
in
let gg (x:tot_typing g (tm_star s0' s1') tm_vprop)
: tot_typing g (tm_star s0 s1) tm_vprop
= let s0'_typing = star_typing_inversion_l x in
let s1'_typing = star_typing_inversion_r x in
star_typing (f0' s0'_typing) (f1' s1'_typing)
in
ff, gg
| VE_Unit g t ->
let fwd (x:tot_typing g (tm_star tm_emp t) tm_vprop)
: tot_typing g t tm_vprop
= let r = star_typing_inversion_r x in
r
in
let bk (x:tot_typing g t tm_vprop)
: tot_typing g (tm_star tm_emp t) tm_vprop
= star_typing emp_typing x
in
fwd, bk
| VE_Comm g t0 t1 ->
let f t0 t1 (x:tot_typing g (tm_star t0 t1) tm_vprop)
: tot_typing g (tm_star t1 t0) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt1 = star_typing_inversion_r x in
star_typing tt1 tt0
in
f t0 t1, f t1 t0
| VE_Assoc g t0 t1 t2 ->
let fwd (x:tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop)
: tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt12 = star_typing_inversion_r x in
let tt1 = star_typing_inversion_l tt12 in
let tt2 = star_typing_inversion_r tt12 in
star_typing (star_typing tt0 tt1) tt2
in
let bk (x : tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop)
: tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop
= let tt01 = star_typing_inversion_l x in
let tt2 = star_typing_inversion_r x in
let tt0 = star_typing_inversion_l tt01 in
let tt1 = star_typing_inversion_r tt01 in
star_typing tt0 (star_typing tt1 tt2)
in
fwd, bk
| VE_Ext g t0 t1 token ->
let d1, d2 = vprop_eq_typing_inversion g t0 t1 token in
(fun _ -> d2),
(fun _ -> d1)
| VE_Fa g x u b t0 t1 d ->
let d0, d1 = vprop_equiv_typing d in
(fun fa0_typing ->
let b_typing, t0_typing = invert_forall_typing fa0_typing x in
let t1_typing = d0 t0_typing in
construct_forall_typing #g #u x b_typing t1_typing),
(fun fa1_typing ->
let b_typing, t1_typing = invert_forall_typing fa1_typing x in
let t0_typing = d1 t1_typing in
construct_forall_typing #g #u #b #t0 x b_typing t0_typing)
#push-options "--z3rlimit_factor 8 --ifuel 1 --fuel 2 --query_stats"
let bind_t (case_c1 case_c2:comp_st -> bool) =
(g:env) ->
(pre:term) ->
(e1:st_term) ->
(e2:st_term) ->
(c1:comp_st{ case_c1 c1 }) ->
(c2:comp_st{ case_c2 c2 }) ->
(px:nvar { ~ (Set.mem (snd px) (dom g)) }) ->
(d_e1:st_typing g e1 c1) ->
(d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1))) ->
(d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2) ->
(res_typing:universe_of g (comp_res c2) (comp_u c2)) ->
(post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop) ->
(bias_towards_continuation:bool) ->
T.TacH (t:st_term &
c:comp_st { st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires fun _ ->
let _, x = px in
comp_pre c1 == pre /\
None? (lookup g x) /\
(~(x `Set.mem` freevars_st e2)) /\
open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))))
(ensures fun _ _ -> True)
let mk_bind_st_st
: bind_t C_ST? C_ST?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
let inames_of (c:comp_st) : term =
match c with
| C_ST _
| C_STGhost _ -> tm_emp_inames
| C_STAtomic inames _ _ -> inames
let with_inames (c:comp_st) (i:term) =
match c with
| C_ST _ -> c
| C_STGhost sc -> C_STGhost sc
| C_STAtomic _ obs sc -> C_STAtomic i obs sc
let weaken_comp_inames (#g:env) (#e:st_term) (#c:comp_st) (d_e:st_typing g e c) (new_inames:term)
: T.Tac (c':comp_st { with_inames c new_inames == c' } &
st_typing g e c')
= match c with
| C_ST _
| C_STGhost _ -> (| c, d_e |)
| C_STAtomic inames obs sc ->
let d_e = T_Sub _ _ _ _ d_e (STS_AtomicInvs _ sc inames new_inames obs obs (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
(| with_inames c new_inames, d_e |)
let st_ghost_as_atomic (c:comp_st { C_STGhost? c }) =
C_STAtomic tm_emp_inames Neutral (st_comp_of_comp c)
let try_lift_ghost_atomic (#g:env) (#e:st_term) (#c:comp_st { C_STGhost? c }) (d:st_typing g e c)
: T.Tac (option (st_typing g e (st_ghost_as_atomic c)))
= let w = try_get_non_informative_witness g (comp_u c) (comp_res c) in
match w with
| None -> None
| Some w ->
let d = T_Lift _ _ _ _ d (Lift_Ghost_Neutral _ c w) in
Some d
let lift_ghost_atomic (#g:env) (#e:st_term) (#c:comp_st { C_STGhost? c }) (d:st_typing g e c)
: T.Tac (st_typing g e (st_ghost_as_atomic c))
= let w = try_lift_ghost_atomic d in
match w with
| None ->
let open Pulse.PP in
let t = comp_res c in
fail_doc g (Some t.range) [
text "Expected a term with a non-informative (e.g., erased) type; got"
^/^ pp t
]
| Some d ->
d
let mk_bind_ghost_ghost
: bind_t C_STGhost? C_STGhost?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
#push-options "--query_stats"
let mk_bind_atomic_atomic
: bind_t C_STAtomic? C_STAtomic?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_k ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let C_STAtomic inames1 obs1 sc1 = c1 in
let C_STAtomic inames2 obs2 sc2 = c2 in
if at_most_one_observable obs1 obs2
then (
if eq_tm inames1 inames2
then begin
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
end
else if bias_k
then (
let d_e1 = T_Sub _ _ _ _ d_e1 (STS_AtomicInvs _ sc1 inames1 inames2 obs1 obs1 (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
let c1 = C_STAtomic inames2 obs1 sc1 in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
)
else begin
let new_inames = tm_join_inames inames1 inames2 in
let d_e1 = T_Sub _ _ _ _ d_e1 (STS_AtomicInvs _ sc1 inames1 new_inames obs1 obs1 (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
let d_e2 = T_Sub _ _ _ _ d_e2 (STS_AtomicInvs _ sc2 inames2 new_inames obs2 obs2 (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
let c1 = C_STAtomic new_inames obs1 sc1 in
let c2 = C_STAtomic new_inames obs2 sc2 in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
end
)
else (
T.fail "Should have been handled separately"
)
let rec mk_bind (g:env)
(pre:term)
(e1:st_term)
(e2:st_term)
(c1:comp_st)
(c2:comp_st)
(px:nvar { ~ (Set.mem (snd px) (dom g)) })
(d_e1:st_typing g e1 c1)
(d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1)))
(d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2)
(res_typing:universe_of g (comp_res c2) (comp_u c2))
(post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop)
(bias_towards_continuation:bool)
: T.TacH (t:st_term &
c:comp_st {
st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires fun _ ->
let _, x = px in
comp_pre c1 == pre /\
None? (lookup g x) /\
(~(x `Set.mem` freevars_st e2)) /\
open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))))
(ensures fun _ _ -> True) =
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let fail_bias (#a:Type) tag
: T.TacH a (requires fun _ -> True) (ensures fun _ r -> FStar.Tactics.Result.Failed? r)
= let open Pulse.PP in
fail_doc g (Some e1.range)
[text "Cannot compose computations in this " ^/^ text tag ^/^ text " block:";
prefix 4 1 (text "This computation has effect: ") (pp (effect_annot_of_comp c1));
prefix 4 1 (text "The continuation has effect: ") (pp (effect_annot_of_comp c2))]
in
match c1, c2 with
| C_ST _, C_ST _ ->
mk_bind_st_st g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
| C_STGhost _, C_STGhost _ ->
mk_bind_ghost_ghost g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
| C_STAtomic inames1 obs1 sc1, C_STAtomic inames2 obs2 sc2 ->
if at_most_one_observable obs1 obs2
then (
mk_bind_atomic_atomic g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
)
else if bias_towards_continuation
then fail_bias "atomic"
else (
let d_e1 = T_Lift _ _ _ _ d_e1 (Lift_STAtomic_ST _ c1) in
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
)
| C_STAtomic inames _ _, C_ST _ ->
let d_e1 = T_Lift _ _ _ _ d_e1 (Lift_STAtomic_ST _ c1) in
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
| C_ST _, C_STAtomic inames _ _ ->
if bias_towards_continuation
then fail_bias "atomic"
else (
let d_e2 = T_Lift _ _ _ _ d_e2 (Lift_STAtomic_ST _ c2) in
let (| t, c, d |) = mk_bind g pre e1 e2 _ _ px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation in
(| t, c, d |)
)
| C_STGhost _, C_STAtomic _ Neutral _ -> (
match try_lift_ghost_atomic d_e1 with
| Some d_e1 ->
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
| None ->
if bias_towards_continuation
then fail_bias "atomic"
else (
let d_e2 = T_Lift _ _ _ _ d_e2 (Lift_Neutral_Ghost _ c2) in
let (| t, c, d |) = mk_bind g pre e1 e2 _ _ px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation in
(| t, c, d |)
)
)
| C_STAtomic _ Neutral _, C_STGhost _ -> (
if bias_towards_continuation
then (
let d_e1 = T_Lift _ _ _ _ d_e1 (Lift_Neutral_Ghost _ c1) in
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
)
else (
match try_lift_ghost_atomic d_e2 with
| Some d_e2 ->
let (| t, c, d |) = mk_bind g pre e1 e2 _ _ px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation in
(| t, c, d |)
| None ->
let d_e1 = T_Lift _ _ _ _ d_e1 (Lift_Neutral_Ghost _ c1) in
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
)
)
| C_STGhost _, C_ST _
| C_STGhost _, C_STAtomic _ _ _ ->
let d_e1 = lift_ghost_atomic d_e1 in
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
| C_ST _, C_STGhost _
| C_STAtomic _ _ _, C_STGhost _ ->
if bias_towards_continuation
then fail_bias "ghost"
else (
let d_e2 = lift_ghost_atomic d_e2 in
let (| t, c, d |) = mk_bind g pre e1 e2 _ _ px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation in
(| t, c, d |)
)
#pop-options | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.PP.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Result.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Typing.Combinators.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
g: Pulse.Typing.Env.env ->
s2: Pulse.Syntax.Base.comp_st ->
x:
Pulse.Syntax.Base.var
{Pulse.Typing.fresh_wrt x g (Pulse.Syntax.Naming.freevars (Pulse.Syntax.Base.comp_post s2))} ->
post_hint: Pulse.Typing.post_hint_opt g {Pulse.Typing.comp_post_matches_hint s2 post_hint}
-> FStar.Tactics.Effect.Tac
(Pulse.Typing.universe_of g (Pulse.Syntax.Base.comp_res s2) (Pulse.Syntax.Base.comp_u s2) *
Pulse.Typing.tot_typing (Pulse.Typing.Env.push_binding g
x
Pulse.Syntax.Base.ppname_default
(Pulse.Syntax.Base.comp_res s2))
(Pulse.Syntax.Naming.open_term_nv (Pulse.Syntax.Base.comp_post s2)
(Pulse.Syntax.Base.v_as_nv x))
Pulse.Syntax.Base.tm_vprop) | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.comp_st",
"Pulse.Syntax.Base.var",
"Pulse.Typing.fresh_wrt",
"Pulse.Syntax.Naming.freevars",
"Pulse.Syntax.Base.comp_post",
"Pulse.Typing.post_hint_opt",
"Pulse.Typing.comp_post_matches_hint",
"Pulse.Syntax.Base.universe",
"Pulse.Typing.universe_of",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__res",
"Prims.op_Negation",
"Pulse.Syntax.Base.eq_univ",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__u",
"Pulse.Typing.Env.fail",
"FStar.Pervasives.Native.tuple2",
"Pulse.Syntax.Base.comp_res",
"Pulse.Syntax.Base.comp_u",
"Pulse.Typing.tot_typing",
"Pulse.Typing.Env.push_binding",
"Pulse.Syntax.Base.ppname_default",
"Pulse.Syntax.Naming.open_term_nv",
"Pulse.Syntax.Base.v_as_nv",
"Pulse.Syntax.Base.tm_vprop",
"FStar.Pervasives.Native.None",
"Pulse.Syntax.Base.range",
"Prims.bool",
"FStar.Set.mem",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__post",
"Prims.string",
"FStar.Printf.sprintf",
"Pulse.Syntax.Printer.term_to_string",
"FStar.Pervasives.Native.Mktuple2",
"Pulse.Checker.Pure.check_vprop_with_core",
"Pulse.Syntax.Base.term",
"Prims.dtuple2",
"Pulse.Checker.Pure.check_universe",
"Pulse.Typing.post_hint_t",
"Pulse.Typing.__proj__Mkpost_hint_typing_t__item__ty_typing",
"Pulse.Typing.__proj__Mkpost_hint_typing_t__item__post_typing",
"Pulse.Typing.post_hint_typing_t",
"Pulse.Typing.post_hint_typing",
"Pulse.Syntax.Base.st_comp",
"Pulse.Syntax.Base.st_comp_of_comp"
] | [] | false | true | false | false | false | let bind_res_and_post_typing g c2 x post_hint =
| let s2 = st_comp_of_comp c2 in
match post_hint with
| None ->
let (| u , res_typing |) = check_universe g s2.res in
if not (eq_univ u s2.u)
then fail g None "Unexpected universe for result type"
else
if x `Set.mem` (freevars s2.post)
then
fail g
None
(Printf.sprintf "Bound variable %d escapes scope in postcondition %s"
x
(P.term_to_string s2.post))
else
(let y = x in
let s2_post_opened = open_term_nv s2.post (v_as_nv y) in
let post_typing =
check_vprop_with_core (push_binding g y ppname_default s2.res) s2_post_opened
in
res_typing, post_typing)
| Some post ->
if x `Set.mem` (freevars s2.post)
then fail g None "Unexpected mismatched postcondition in bind"
else
(let pr = post_hint_typing g post x in
pr.ty_typing, pr.post_typing) | false |
Hacl.Streaming.Blake2s_128.fst | Hacl.Streaming.Blake2s_128.update | val update : Hacl.Streaming.Functor.update_st (Hacl.Streaming.Blake2s_128.blake2s_128 0)
(FStar.Ghost.reveal (FStar.Ghost.hide ()))
(Hacl.Streaming.Blake2.Common.s Spec.Blake2.Definitions.Blake2S Hacl.Impl.Blake2.Core.M128)
(Hacl.Streaming.Blake2.Common.empty_key Spec.Blake2.Definitions.Blake2S) | let update =
F.update (blake2s_128 0) (G.hide ()) (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | {
"file_name": "code/streaming/Hacl.Streaming.Blake2s_128.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 104,
"end_line": 38,
"start_col": 0,
"start_line": 37
} | module Hacl.Streaming.Blake2s_128
module Blake2s128 = Hacl.Blake2s_128
module Common = Hacl.Streaming.Blake2.Common
module Core = Hacl.Impl.Blake2.Core
module F = Hacl.Streaming.Functor
module G = FStar.Ghost
module Impl = Hacl.Impl.Blake2.Generic
module Spec = Spec.Blake2
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// The functor
inline_for_extraction noextract
let blake2s_128 kk =
Common.blake2 Spec.Blake2S Core.M128 kk Blake2s128.init Blake2s128.update_multi
Blake2s128.update_last Blake2s128.finish
/// Type abbreviations
let block_state_t = Common.s Spec.Blake2S Core.M128
let state_t = F.state_s (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
/// No key
inline_for_extraction noextract
let alloca =
F.alloca (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
[@ (Comment " State allocation function when there is no key")]
let malloc =
F.malloc (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
[@ (Comment " Re-initialization function when there is no key")]
let reset =
F.reset (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Streaming.Blake2.Common.fst.checked",
"Hacl.Impl.Blake2.Generic.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Blake2s_128.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Blake2s_128.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Generic",
"short_module": "Impl"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Core"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Blake2.Common",
"short_module": "Common"
},
{
"abbrev": true,
"full_module": "Hacl.Blake2s_128",
"short_module": "Blake2s128"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Hacl.Streaming.Functor.update_st (Hacl.Streaming.Blake2s_128.blake2s_128 0)
(FStar.Ghost.reveal (FStar.Ghost.hide ()))
(Hacl.Streaming.Blake2.Common.s Spec.Blake2.Definitions.Blake2S Hacl.Impl.Blake2.Core.M128)
(Hacl.Streaming.Blake2.Common.empty_key Spec.Blake2.Definitions.Blake2S) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Functor.update",
"Prims.unit",
"Hacl.Streaming.Blake2s_128.blake2s_128",
"FStar.Ghost.hide",
"Hacl.Streaming.Blake2.Common.s",
"Spec.Blake2.Definitions.Blake2S",
"Hacl.Impl.Blake2.Core.M128",
"Hacl.Streaming.Blake2.Common.empty_key"
] | [] | false | false | false | false | false | let update =
| F.update (blake2s_128 0)
(G.hide ())
(Common.s Spec.Blake2S Core.M128)
(Common.empty_key Spec.Blake2S) | false |
|
Pulse.Lib.Reference.fst | Pulse.Lib.Reference.pts_to_injective_eq | val pts_to_injective_eq (#a:_)
(#p #q:_)
(#v0 #v1:a)
(r:ref a)
: stt_ghost unit
(pts_to r #p v0 ** pts_to r #q v1)
(fun _ -> pts_to r #p v0 ** pts_to r #q v1 ** pure (v0 == v1)) | val pts_to_injective_eq (#a:_)
(#p #q:_)
(#v0 #v1:a)
(r:ref a)
: stt_ghost unit
(pts_to r #p v0 ** pts_to r #q v1)
(fun _ -> pts_to r #p v0 ** pts_to r #q v1 ** pure (v0 == v1)) | let pts_to_injective_eq = pts_to_injective_eq' | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Reference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 46,
"end_line": 234,
"start_col": 0,
"start_line": 234
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.Reference
open Pulse.Lib.Core
open Pulse.Main
module H = Pulse.Lib.HigherReference
module U = FStar.Universe
let ref a = H.ref (U.raise_t a)
let pts_to
(#a:Type u#0)
(r:ref a)
(#[exact (`full_perm)] [@@@equate_by_smt] p:perm)
([@@@equate_by_smt] v:a)
= H.pts_to r #p (U.raise_val v)
```pulse
fn alloc' (#a:Type u#0) (v:a)
requires emp
returns r:ref a
ensures pts_to r v
{
let r = H.alloc (U.raise_val v);
fold (pts_to r #full_perm v);
r
}
```
let alloc = alloc'
```pulse
fn read (#a:Type) (r:ref a) (#n:erased a) (#p:perm)
requires pts_to r #p n
returns x:a
ensures pts_to r #p n ** pure (eq2 #a (reveal n) x)
{
unfold (pts_to r #p n);
let k = H.( !r );
fold (pts_to r #p n);
U.downgrade_val k
}
```
let ( ! ) #a = read #a
```pulse
fn write (#a:Type) (r:ref a) (x:a) (#n:erased a)
requires pts_to r #full_perm n
ensures pts_to r #full_perm x
{
unfold (pts_to r #full_perm n);
H.(r := (U.raise_val x));
fold (pts_to r #full_perm x)
}
```
let ( := ) #a r x #n = write #a r x #n
```pulse
fn free' #a (r:ref a) (#n:erased a)
requires pts_to r #full_perm n
ensures emp
{
unfold (pts_to r #full_perm n);
H.free r;
}
```
let free = free'
```pulse
ghost
fn share' (#a:Type) (r:ref a) (#v:erased a) (#p:perm)
requires pts_to r #p v
ensures pts_to r #(half_perm p) v ** pts_to r #(half_perm p) v
{
unfold pts_to r #p v;
H.share r;
fold pts_to r #(half_perm p) v;
fold pts_to r #(half_perm p) v
}
```
let share = share'
```pulse
ghost
fn raise_inj (a:Type u#0) (x0 x1:a)
requires pure (U.raise_val u#0 u#1 x0 == U.raise_val u#0 u#1 x1)
ensures pure (x0 == x1)
{
assert pure (U.downgrade_val (U.raise_val u#0 u#1 x0) == x0);
assert pure (U.downgrade_val (U.raise_val u#0 u#1 x1) == x1);
}
```
```pulse
ghost
fn gather' (#a:Type) (r:ref a) (#x0 #x1:erased a) (#p0 #p1:perm)
requires pts_to r #p0 x0 ** pts_to r #p1 x1
ensures pts_to r #(sum_perm p0 p1) x0 ** pure (x0 == x1)
{
unfold pts_to r #p0 x0;
unfold pts_to r #p1 x1;
H.gather r;
fold (pts_to r #(sum_perm p1 p0) x0);
let qq = sum_perm p0 p1; //hack! prevent the unifier from structurally matching sum_perm p0 p1 with sum_perm p1 p0
rewrite (pts_to r #(sum_perm p1 p0) x0)
as (pts_to r #qq x0);
raise_inj a x0 x1;
}
```
let gather = gather'
let share2 (#a:Type) (r:ref a) (#v:erased a)
: stt_ghost unit
(pts_to r v)
(fun _ -> pts_to r #one_half v ** pts_to r #one_half v)
= share #a r #v
let gather2 (#a:Type) (r:ref a) (#x0 #x1:erased a)
: stt_ghost unit
(pts_to r #one_half x0 ** pts_to r #one_half x1)
(fun () -> pts_to r x0 ** pure (x0 == x1))
= gather r
let read_atomic (r:ref U32.t) (#n:erased U32.t) (#p:perm)
: stt_atomic U32.t emp_inames
(pts_to r #p n)
(fun x -> pts_to r #p n ** pure (reveal n == x))
= Pulse.Lib.Core.as_atomic _ _ (read r #n #p)
let write_atomic (r:ref U32.t) (x:U32.t) (#n:erased U32.t)
= Pulse.Lib.Core.as_atomic _ _ (write r x #n)
```pulse
fn cas_impl
(r:ref U32.t)
(u v:U32.t)
(#i:erased U32.t)
requires
pts_to r i
returns b:bool
ensures
cond b (pts_to r v ** pure (reveal i == u))
(pts_to r i)
{
let u' = read r;
if (u = u')
{
write r v;
fold (cond true (pts_to r v ** pure (reveal i == u)) (pts_to r i));
true
}
else
{
fold cond false (pts_to r v ** pure (reveal i == u)) (pts_to r i);
false
}
}
```
let cas r u v #i = Pulse.Lib.Core.as_atomic _ _ (cas_impl r u v #i)
```pulse
fn
raise_exists (#a:Type u#0) (frame:vprop) (p: U.raise_t u#0 u#1 a -> vprop)
requires frame ** (exists* (x:a). p (U.raise_val x))
ensures frame ** (exists* (x:U.raise_t a). p x)
{
()
}
```
let with_local
(#a:Type0)
(init:a)
(#pre:vprop)
(#ret_t:Type)
(#post:ret_t -> vprop)
(body:(r:ref a) -> stt ret_t (pre ** pts_to r init)
(fun v -> post v ** op_exists_Star (pts_to r #full_perm)))
: stt ret_t pre post
= let body (r:H.ref (U.raise_t a))
: stt ret_t (pre ** H.pts_to r #full_perm (U.raise_val init))
(fun v -> post v ** (exists* (x:U.raise_t a). H.pts_to r #full_perm x))
= let m
: stt ret_t (pre ** H.pts_to r #full_perm (U.raise_val init))
(fun v -> post v ** (exists* (x:a). H.pts_to r #full_perm (U.raise_val x)))
= body r
in
let m0 (v:ret_t)
: stt ret_t
(post v ** (exists* (x:a). H.pts_to r #full_perm (U.raise_val x)))
(fun v -> post v ** (exists* (x:U.raise_t a). H.pts_to r #full_perm x))
= bind_stt (raise_exists (post v) (H.pts_to r #full_perm))
(fun _ -> return_stt_noeq v (fun v -> post v ** (exists* (x:U.raise_t a). H.pts_to r #full_perm x)))
in
bind_stt m m0
in
H.with_local (U.raise_val init) body
```pulse
ghost
fn pts_to_injective_eq'
(#a:Type0)
(#p #q:perm)
(#v0 #v1:a)
(r:ref a)
requires
pts_to r #p v0 ** pts_to r #q v1
ensures
pts_to r #p v0 ** pts_to r #q v1 ** pure (v0 == v1)
{
unfold pts_to r #p v0;
unfold pts_to r #q v1;
H.pts_to_injective_eq r;
fold pts_to r #p v0;
fold pts_to r #q v1;
raise_inj _ v0 v1;
} | {
"checked_file": "/",
"dependencies": [
"Pulse.Main.fsti.checked",
"Pulse.Lib.HigherReference.fsti.checked",
"Pulse.Lib.Core.fsti.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Lib.Reference.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Pulse.Lib.HigherReference",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Pulse.Main",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.Observability",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"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: Pulse.Lib.Reference.ref a
-> Pulse.Lib.Core.stt_ghost Prims.unit
(Pulse.Lib.Reference.pts_to r v0 ** Pulse.Lib.Reference.pts_to r v1)
(fun _ ->
(Pulse.Lib.Reference.pts_to r v0 ** Pulse.Lib.Reference.pts_to r v1) **
Pulse.Lib.Core.pure (v0 == v1)) | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.Reference.pts_to_injective_eq'"
] | [] | false | false | false | false | false | let pts_to_injective_eq =
| pts_to_injective_eq' | false |
Pulse.Lib.Reference.fst | Pulse.Lib.Reference.pts_to_perm_bound | val pts_to_perm_bound (#a:_) (#p:_) (r:ref a) (#v:a)
: stt_ghost unit
(pts_to r #p v)
(fun _ -> pts_to r #p v ** pure (p `lesser_equal_perm` full_perm)) | val pts_to_perm_bound (#a:_) (#p:_) (r:ref a) (#v:a)
: stt_ghost unit
(pts_to r #p v)
(fun _ -> pts_to r #p v ** pure (p `lesser_equal_perm` full_perm)) | let pts_to_perm_bound = pts_to_perm_bound' | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Reference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 42,
"end_line": 247,
"start_col": 0,
"start_line": 247
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.Reference
open Pulse.Lib.Core
open Pulse.Main
module H = Pulse.Lib.HigherReference
module U = FStar.Universe
let ref a = H.ref (U.raise_t a)
let pts_to
(#a:Type u#0)
(r:ref a)
(#[exact (`full_perm)] [@@@equate_by_smt] p:perm)
([@@@equate_by_smt] v:a)
= H.pts_to r #p (U.raise_val v)
```pulse
fn alloc' (#a:Type u#0) (v:a)
requires emp
returns r:ref a
ensures pts_to r v
{
let r = H.alloc (U.raise_val v);
fold (pts_to r #full_perm v);
r
}
```
let alloc = alloc'
```pulse
fn read (#a:Type) (r:ref a) (#n:erased a) (#p:perm)
requires pts_to r #p n
returns x:a
ensures pts_to r #p n ** pure (eq2 #a (reveal n) x)
{
unfold (pts_to r #p n);
let k = H.( !r );
fold (pts_to r #p n);
U.downgrade_val k
}
```
let ( ! ) #a = read #a
```pulse
fn write (#a:Type) (r:ref a) (x:a) (#n:erased a)
requires pts_to r #full_perm n
ensures pts_to r #full_perm x
{
unfold (pts_to r #full_perm n);
H.(r := (U.raise_val x));
fold (pts_to r #full_perm x)
}
```
let ( := ) #a r x #n = write #a r x #n
```pulse
fn free' #a (r:ref a) (#n:erased a)
requires pts_to r #full_perm n
ensures emp
{
unfold (pts_to r #full_perm n);
H.free r;
}
```
let free = free'
```pulse
ghost
fn share' (#a:Type) (r:ref a) (#v:erased a) (#p:perm)
requires pts_to r #p v
ensures pts_to r #(half_perm p) v ** pts_to r #(half_perm p) v
{
unfold pts_to r #p v;
H.share r;
fold pts_to r #(half_perm p) v;
fold pts_to r #(half_perm p) v
}
```
let share = share'
```pulse
ghost
fn raise_inj (a:Type u#0) (x0 x1:a)
requires pure (U.raise_val u#0 u#1 x0 == U.raise_val u#0 u#1 x1)
ensures pure (x0 == x1)
{
assert pure (U.downgrade_val (U.raise_val u#0 u#1 x0) == x0);
assert pure (U.downgrade_val (U.raise_val u#0 u#1 x1) == x1);
}
```
```pulse
ghost
fn gather' (#a:Type) (r:ref a) (#x0 #x1:erased a) (#p0 #p1:perm)
requires pts_to r #p0 x0 ** pts_to r #p1 x1
ensures pts_to r #(sum_perm p0 p1) x0 ** pure (x0 == x1)
{
unfold pts_to r #p0 x0;
unfold pts_to r #p1 x1;
H.gather r;
fold (pts_to r #(sum_perm p1 p0) x0);
let qq = sum_perm p0 p1; //hack! prevent the unifier from structurally matching sum_perm p0 p1 with sum_perm p1 p0
rewrite (pts_to r #(sum_perm p1 p0) x0)
as (pts_to r #qq x0);
raise_inj a x0 x1;
}
```
let gather = gather'
let share2 (#a:Type) (r:ref a) (#v:erased a)
: stt_ghost unit
(pts_to r v)
(fun _ -> pts_to r #one_half v ** pts_to r #one_half v)
= share #a r #v
let gather2 (#a:Type) (r:ref a) (#x0 #x1:erased a)
: stt_ghost unit
(pts_to r #one_half x0 ** pts_to r #one_half x1)
(fun () -> pts_to r x0 ** pure (x0 == x1))
= gather r
let read_atomic (r:ref U32.t) (#n:erased U32.t) (#p:perm)
: stt_atomic U32.t emp_inames
(pts_to r #p n)
(fun x -> pts_to r #p n ** pure (reveal n == x))
= Pulse.Lib.Core.as_atomic _ _ (read r #n #p)
let write_atomic (r:ref U32.t) (x:U32.t) (#n:erased U32.t)
= Pulse.Lib.Core.as_atomic _ _ (write r x #n)
```pulse
fn cas_impl
(r:ref U32.t)
(u v:U32.t)
(#i:erased U32.t)
requires
pts_to r i
returns b:bool
ensures
cond b (pts_to r v ** pure (reveal i == u))
(pts_to r i)
{
let u' = read r;
if (u = u')
{
write r v;
fold (cond true (pts_to r v ** pure (reveal i == u)) (pts_to r i));
true
}
else
{
fold cond false (pts_to r v ** pure (reveal i == u)) (pts_to r i);
false
}
}
```
let cas r u v #i = Pulse.Lib.Core.as_atomic _ _ (cas_impl r u v #i)
```pulse
fn
raise_exists (#a:Type u#0) (frame:vprop) (p: U.raise_t u#0 u#1 a -> vprop)
requires frame ** (exists* (x:a). p (U.raise_val x))
ensures frame ** (exists* (x:U.raise_t a). p x)
{
()
}
```
let with_local
(#a:Type0)
(init:a)
(#pre:vprop)
(#ret_t:Type)
(#post:ret_t -> vprop)
(body:(r:ref a) -> stt ret_t (pre ** pts_to r init)
(fun v -> post v ** op_exists_Star (pts_to r #full_perm)))
: stt ret_t pre post
= let body (r:H.ref (U.raise_t a))
: stt ret_t (pre ** H.pts_to r #full_perm (U.raise_val init))
(fun v -> post v ** (exists* (x:U.raise_t a). H.pts_to r #full_perm x))
= let m
: stt ret_t (pre ** H.pts_to r #full_perm (U.raise_val init))
(fun v -> post v ** (exists* (x:a). H.pts_to r #full_perm (U.raise_val x)))
= body r
in
let m0 (v:ret_t)
: stt ret_t
(post v ** (exists* (x:a). H.pts_to r #full_perm (U.raise_val x)))
(fun v -> post v ** (exists* (x:U.raise_t a). H.pts_to r #full_perm x))
= bind_stt (raise_exists (post v) (H.pts_to r #full_perm))
(fun _ -> return_stt_noeq v (fun v -> post v ** (exists* (x:U.raise_t a). H.pts_to r #full_perm x)))
in
bind_stt m m0
in
H.with_local (U.raise_val init) body
```pulse
ghost
fn pts_to_injective_eq'
(#a:Type0)
(#p #q:perm)
(#v0 #v1:a)
(r:ref a)
requires
pts_to r #p v0 ** pts_to r #q v1
ensures
pts_to r #p v0 ** pts_to r #q v1 ** pure (v0 == v1)
{
unfold pts_to r #p v0;
unfold pts_to r #q v1;
H.pts_to_injective_eq r;
fold pts_to r #p v0;
fold pts_to r #q v1;
raise_inj _ v0 v1;
}
```
let pts_to_injective_eq = pts_to_injective_eq'
```pulse
ghost
fn pts_to_perm_bound' (#a:_) (#p:_) (r:ref a) (#v:a)
requires pts_to r #p v
ensures pts_to r #p v ** pure (p `lesser_equal_perm` full_perm)
{
unfold pts_to r #p v;
H.pts_to_perm_bound r;
fold pts_to r #p v;
} | {
"checked_file": "/",
"dependencies": [
"Pulse.Main.fsti.checked",
"Pulse.Lib.HigherReference.fsti.checked",
"Pulse.Lib.Core.fsti.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Lib.Reference.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Pulse.Lib.HigherReference",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Pulse.Main",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.Observability",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"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: Pulse.Lib.Reference.ref a
-> Pulse.Lib.Core.stt_ghost Prims.unit
(Pulse.Lib.Reference.pts_to r v)
(fun _ ->
Pulse.Lib.Reference.pts_to r v **
Pulse.Lib.Core.pure (PulseCore.FractionalPermission.lesser_equal_perm p
PulseCore.FractionalPermission.full_perm)) | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.Reference.pts_to_perm_bound'"
] | [] | false | false | false | false | false | let pts_to_perm_bound =
| pts_to_perm_bound' | false |
Hacl.Streaming.Blake2s_128.fst | Hacl.Streaming.Blake2s_128.malloc | val malloc : Hacl.Streaming.Functor.malloc_st (Hacl.Streaming.Blake2s_128.blake2s_128 0)
()
(Hacl.Streaming.Blake2.Common.s Spec.Blake2.Definitions.Blake2S Hacl.Impl.Blake2.Core.M128)
(Hacl.Streaming.Blake2.Common.empty_key Spec.Blake2.Definitions.Blake2S) | let malloc =
F.malloc (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | {
"file_name": "code/streaming/Hacl.Streaming.Blake2s_128.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 95,
"end_line": 30,
"start_col": 0,
"start_line": 29
} | module Hacl.Streaming.Blake2s_128
module Blake2s128 = Hacl.Blake2s_128
module Common = Hacl.Streaming.Blake2.Common
module Core = Hacl.Impl.Blake2.Core
module F = Hacl.Streaming.Functor
module G = FStar.Ghost
module Impl = Hacl.Impl.Blake2.Generic
module Spec = Spec.Blake2
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// The functor
inline_for_extraction noextract
let blake2s_128 kk =
Common.blake2 Spec.Blake2S Core.M128 kk Blake2s128.init Blake2s128.update_multi
Blake2s128.update_last Blake2s128.finish
/// Type abbreviations
let block_state_t = Common.s Spec.Blake2S Core.M128
let state_t = F.state_s (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
/// No key
inline_for_extraction noextract
let alloca =
F.alloca (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Streaming.Blake2.Common.fst.checked",
"Hacl.Impl.Blake2.Generic.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Blake2s_128.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Blake2s_128.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Generic",
"short_module": "Impl"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Core"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Blake2.Common",
"short_module": "Common"
},
{
"abbrev": true,
"full_module": "Hacl.Blake2s_128",
"short_module": "Blake2s128"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Hacl.Streaming.Functor.malloc_st (Hacl.Streaming.Blake2s_128.blake2s_128 0)
()
(Hacl.Streaming.Blake2.Common.s Spec.Blake2.Definitions.Blake2S Hacl.Impl.Blake2.Core.M128)
(Hacl.Streaming.Blake2.Common.empty_key Spec.Blake2.Definitions.Blake2S) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Functor.malloc",
"Prims.unit",
"Hacl.Streaming.Blake2s_128.blake2s_128",
"Hacl.Streaming.Blake2.Common.s",
"Spec.Blake2.Definitions.Blake2S",
"Hacl.Impl.Blake2.Core.M128",
"Hacl.Streaming.Blake2.Common.empty_key"
] | [] | false | false | false | false | false | let malloc =
| F.malloc (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | false |
|
Hacl.Streaming.Blake2s_128.fst | Hacl.Streaming.Blake2s_128.blake2s_128 | val blake2s_128 : kk: Hacl.Streaming.Blake2.Common.key_size Spec.Blake2.Definitions.Blake2S
-> Hacl.Streaming.Interface.block Prims.unit | let blake2s_128 kk =
Common.blake2 Spec.Blake2S Core.M128 kk Blake2s128.init Blake2s128.update_multi
Blake2s128.update_last Blake2s128.finish | {
"file_name": "code/streaming/Hacl.Streaming.Blake2s_128.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 49,
"end_line": 17,
"start_col": 0,
"start_line": 15
} | module Hacl.Streaming.Blake2s_128
module Blake2s128 = Hacl.Blake2s_128
module Common = Hacl.Streaming.Blake2.Common
module Core = Hacl.Impl.Blake2.Core
module F = Hacl.Streaming.Functor
module G = FStar.Ghost
module Impl = Hacl.Impl.Blake2.Generic
module Spec = Spec.Blake2
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// The functor | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Streaming.Blake2.Common.fst.checked",
"Hacl.Impl.Blake2.Generic.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Blake2s_128.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Blake2s_128.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Generic",
"short_module": "Impl"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Core"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Blake2.Common",
"short_module": "Common"
},
{
"abbrev": true,
"full_module": "Hacl.Blake2s_128",
"short_module": "Blake2s128"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | kk: Hacl.Streaming.Blake2.Common.key_size Spec.Blake2.Definitions.Blake2S
-> Hacl.Streaming.Interface.block Prims.unit | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Blake2.Common.key_size",
"Spec.Blake2.Definitions.Blake2S",
"Hacl.Streaming.Blake2.Common.blake2",
"Hacl.Impl.Blake2.Core.M128",
"Hacl.Blake2s_128.init",
"Hacl.Blake2s_128.update_multi",
"Hacl.Blake2s_128.update_last",
"Hacl.Blake2s_128.finish",
"Hacl.Streaming.Interface.block",
"Prims.unit"
] | [] | false | false | false | true | false | let blake2s_128 kk =
| Common.blake2 Spec.Blake2S
Core.M128
kk
Blake2s128.init
Blake2s128.update_multi
Blake2s128.update_last
Blake2s128.finish | false |
|
Pulse.Lib.Reference.fst | Pulse.Lib.Reference.replace | val replace (#a:Type0) (r:ref a) (x:a) (#v:erased a)
: stt a
(pts_to r v)
(fun res -> pts_to r x ** pure (res == reveal v)) | val replace (#a:Type0) (r:ref a) (x:a) (#v:erased a)
: stt a
(pts_to r v)
(fun res -> pts_to r x ** pure (res == reveal v)) | let replace = replace' | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Reference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 22,
"end_line": 261,
"start_col": 0,
"start_line": 261
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.Reference
open Pulse.Lib.Core
open Pulse.Main
module H = Pulse.Lib.HigherReference
module U = FStar.Universe
let ref a = H.ref (U.raise_t a)
let pts_to
(#a:Type u#0)
(r:ref a)
(#[exact (`full_perm)] [@@@equate_by_smt] p:perm)
([@@@equate_by_smt] v:a)
= H.pts_to r #p (U.raise_val v)
```pulse
fn alloc' (#a:Type u#0) (v:a)
requires emp
returns r:ref a
ensures pts_to r v
{
let r = H.alloc (U.raise_val v);
fold (pts_to r #full_perm v);
r
}
```
let alloc = alloc'
```pulse
fn read (#a:Type) (r:ref a) (#n:erased a) (#p:perm)
requires pts_to r #p n
returns x:a
ensures pts_to r #p n ** pure (eq2 #a (reveal n) x)
{
unfold (pts_to r #p n);
let k = H.( !r );
fold (pts_to r #p n);
U.downgrade_val k
}
```
let ( ! ) #a = read #a
```pulse
fn write (#a:Type) (r:ref a) (x:a) (#n:erased a)
requires pts_to r #full_perm n
ensures pts_to r #full_perm x
{
unfold (pts_to r #full_perm n);
H.(r := (U.raise_val x));
fold (pts_to r #full_perm x)
}
```
let ( := ) #a r x #n = write #a r x #n
```pulse
fn free' #a (r:ref a) (#n:erased a)
requires pts_to r #full_perm n
ensures emp
{
unfold (pts_to r #full_perm n);
H.free r;
}
```
let free = free'
```pulse
ghost
fn share' (#a:Type) (r:ref a) (#v:erased a) (#p:perm)
requires pts_to r #p v
ensures pts_to r #(half_perm p) v ** pts_to r #(half_perm p) v
{
unfold pts_to r #p v;
H.share r;
fold pts_to r #(half_perm p) v;
fold pts_to r #(half_perm p) v
}
```
let share = share'
```pulse
ghost
fn raise_inj (a:Type u#0) (x0 x1:a)
requires pure (U.raise_val u#0 u#1 x0 == U.raise_val u#0 u#1 x1)
ensures pure (x0 == x1)
{
assert pure (U.downgrade_val (U.raise_val u#0 u#1 x0) == x0);
assert pure (U.downgrade_val (U.raise_val u#0 u#1 x1) == x1);
}
```
```pulse
ghost
fn gather' (#a:Type) (r:ref a) (#x0 #x1:erased a) (#p0 #p1:perm)
requires pts_to r #p0 x0 ** pts_to r #p1 x1
ensures pts_to r #(sum_perm p0 p1) x0 ** pure (x0 == x1)
{
unfold pts_to r #p0 x0;
unfold pts_to r #p1 x1;
H.gather r;
fold (pts_to r #(sum_perm p1 p0) x0);
let qq = sum_perm p0 p1; //hack! prevent the unifier from structurally matching sum_perm p0 p1 with sum_perm p1 p0
rewrite (pts_to r #(sum_perm p1 p0) x0)
as (pts_to r #qq x0);
raise_inj a x0 x1;
}
```
let gather = gather'
let share2 (#a:Type) (r:ref a) (#v:erased a)
: stt_ghost unit
(pts_to r v)
(fun _ -> pts_to r #one_half v ** pts_to r #one_half v)
= share #a r #v
let gather2 (#a:Type) (r:ref a) (#x0 #x1:erased a)
: stt_ghost unit
(pts_to r #one_half x0 ** pts_to r #one_half x1)
(fun () -> pts_to r x0 ** pure (x0 == x1))
= gather r
let read_atomic (r:ref U32.t) (#n:erased U32.t) (#p:perm)
: stt_atomic U32.t emp_inames
(pts_to r #p n)
(fun x -> pts_to r #p n ** pure (reveal n == x))
= Pulse.Lib.Core.as_atomic _ _ (read r #n #p)
let write_atomic (r:ref U32.t) (x:U32.t) (#n:erased U32.t)
= Pulse.Lib.Core.as_atomic _ _ (write r x #n)
```pulse
fn cas_impl
(r:ref U32.t)
(u v:U32.t)
(#i:erased U32.t)
requires
pts_to r i
returns b:bool
ensures
cond b (pts_to r v ** pure (reveal i == u))
(pts_to r i)
{
let u' = read r;
if (u = u')
{
write r v;
fold (cond true (pts_to r v ** pure (reveal i == u)) (pts_to r i));
true
}
else
{
fold cond false (pts_to r v ** pure (reveal i == u)) (pts_to r i);
false
}
}
```
let cas r u v #i = Pulse.Lib.Core.as_atomic _ _ (cas_impl r u v #i)
```pulse
fn
raise_exists (#a:Type u#0) (frame:vprop) (p: U.raise_t u#0 u#1 a -> vprop)
requires frame ** (exists* (x:a). p (U.raise_val x))
ensures frame ** (exists* (x:U.raise_t a). p x)
{
()
}
```
let with_local
(#a:Type0)
(init:a)
(#pre:vprop)
(#ret_t:Type)
(#post:ret_t -> vprop)
(body:(r:ref a) -> stt ret_t (pre ** pts_to r init)
(fun v -> post v ** op_exists_Star (pts_to r #full_perm)))
: stt ret_t pre post
= let body (r:H.ref (U.raise_t a))
: stt ret_t (pre ** H.pts_to r #full_perm (U.raise_val init))
(fun v -> post v ** (exists* (x:U.raise_t a). H.pts_to r #full_perm x))
= let m
: stt ret_t (pre ** H.pts_to r #full_perm (U.raise_val init))
(fun v -> post v ** (exists* (x:a). H.pts_to r #full_perm (U.raise_val x)))
= body r
in
let m0 (v:ret_t)
: stt ret_t
(post v ** (exists* (x:a). H.pts_to r #full_perm (U.raise_val x)))
(fun v -> post v ** (exists* (x:U.raise_t a). H.pts_to r #full_perm x))
= bind_stt (raise_exists (post v) (H.pts_to r #full_perm))
(fun _ -> return_stt_noeq v (fun v -> post v ** (exists* (x:U.raise_t a). H.pts_to r #full_perm x)))
in
bind_stt m m0
in
H.with_local (U.raise_val init) body
```pulse
ghost
fn pts_to_injective_eq'
(#a:Type0)
(#p #q:perm)
(#v0 #v1:a)
(r:ref a)
requires
pts_to r #p v0 ** pts_to r #q v1
ensures
pts_to r #p v0 ** pts_to r #q v1 ** pure (v0 == v1)
{
unfold pts_to r #p v0;
unfold pts_to r #q v1;
H.pts_to_injective_eq r;
fold pts_to r #p v0;
fold pts_to r #q v1;
raise_inj _ v0 v1;
}
```
let pts_to_injective_eq = pts_to_injective_eq'
```pulse
ghost
fn pts_to_perm_bound' (#a:_) (#p:_) (r:ref a) (#v:a)
requires pts_to r #p v
ensures pts_to r #p v ** pure (p `lesser_equal_perm` full_perm)
{
unfold pts_to r #p v;
H.pts_to_perm_bound r;
fold pts_to r #p v;
}
```
let pts_to_perm_bound = pts_to_perm_bound'
```pulse
fn replace' (#a:Type0) (r:ref a) (x:a) (#v:erased a)
requires pts_to r v
returns y:a
ensures pts_to r x ** pure (y == reveal v)
{
let y = !r;
r := x;
y
}
``` | {
"checked_file": "/",
"dependencies": [
"Pulse.Main.fsti.checked",
"Pulse.Lib.HigherReference.fsti.checked",
"Pulse.Lib.Core.fsti.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Lib.Reference.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Pulse.Lib.HigherReference",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Pulse.Main",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.Observability",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"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: Pulse.Lib.Reference.ref a -> x: a
-> Pulse.Lib.Core.stt a
(Pulse.Lib.Reference.pts_to r (FStar.Ghost.reveal v))
(fun res ->
Pulse.Lib.Reference.pts_to r x ** Pulse.Lib.Core.pure (res == FStar.Ghost.reveal v)) | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.Reference.replace'"
] | [] | false | false | false | false | false | let replace =
| replace' | false |
Hacl.Streaming.Blake2s_128.fst | Hacl.Streaming.Blake2s_128.free | val free : Hacl.Streaming.Functor.free_st (Hacl.Streaming.Blake2s_128.blake2s_128 0)
(FStar.Ghost.reveal (FStar.Ghost.hide ()))
(Hacl.Streaming.Blake2.Common.s Spec.Blake2.Definitions.Blake2S Hacl.Impl.Blake2.Core.M128)
(Hacl.Streaming.Blake2.Common.empty_key Spec.Blake2.Definitions.Blake2S) | let free =
F.free (blake2s_128 0) (G.hide ()) (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | {
"file_name": "code/streaming/Hacl.Streaming.Blake2s_128.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 102,
"end_line": 46,
"start_col": 0,
"start_line": 45
} | module Hacl.Streaming.Blake2s_128
module Blake2s128 = Hacl.Blake2s_128
module Common = Hacl.Streaming.Blake2.Common
module Core = Hacl.Impl.Blake2.Core
module F = Hacl.Streaming.Functor
module G = FStar.Ghost
module Impl = Hacl.Impl.Blake2.Generic
module Spec = Spec.Blake2
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// The functor
inline_for_extraction noextract
let blake2s_128 kk =
Common.blake2 Spec.Blake2S Core.M128 kk Blake2s128.init Blake2s128.update_multi
Blake2s128.update_last Blake2s128.finish
/// Type abbreviations
let block_state_t = Common.s Spec.Blake2S Core.M128
let state_t = F.state_s (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
/// No key
inline_for_extraction noextract
let alloca =
F.alloca (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
[@ (Comment " State allocation function when there is no key")]
let malloc =
F.malloc (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
[@ (Comment " Re-initialization function when there is no key")]
let reset =
F.reset (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
[@ (Comment " Update function when there is no key; 0 = success, 1 = max length exceeded")]
let update =
F.update (blake2s_128 0) (G.hide ()) (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
[@ (Comment " Finish function when there is no key")]
let digest =
F.digest (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Streaming.Blake2.Common.fst.checked",
"Hacl.Impl.Blake2.Generic.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Blake2s_128.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Blake2s_128.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Generic",
"short_module": "Impl"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Core"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Blake2.Common",
"short_module": "Common"
},
{
"abbrev": true,
"full_module": "Hacl.Blake2s_128",
"short_module": "Blake2s128"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Hacl.Streaming.Functor.free_st (Hacl.Streaming.Blake2s_128.blake2s_128 0)
(FStar.Ghost.reveal (FStar.Ghost.hide ()))
(Hacl.Streaming.Blake2.Common.s Spec.Blake2.Definitions.Blake2S Hacl.Impl.Blake2.Core.M128)
(Hacl.Streaming.Blake2.Common.empty_key Spec.Blake2.Definitions.Blake2S) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Functor.free",
"Prims.unit",
"Hacl.Streaming.Blake2s_128.blake2s_128",
"FStar.Ghost.hide",
"Hacl.Streaming.Blake2.Common.s",
"Spec.Blake2.Definitions.Blake2S",
"Hacl.Impl.Blake2.Core.M128",
"Hacl.Streaming.Blake2.Common.empty_key"
] | [] | false | false | false | false | false | let free =
| F.free (blake2s_128 0) (G.hide ()) (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | false |
|
Pulse.Lib.Reference.fst | Pulse.Lib.Reference.with_local | val with_local
(#a:Type0)
(init:a)
(#pre:vprop)
(#ret_t:Type)
(#post:ret_t -> vprop)
(body:(r:ref a) -> stt ret_t (pre ** pts_to r init)
(fun v -> post v ** op_exists_Star (pts_to r)))
: stt ret_t pre post | val with_local
(#a:Type0)
(init:a)
(#pre:vprop)
(#ret_t:Type)
(#post:ret_t -> vprop)
(body:(r:ref a) -> stt ret_t (pre ** pts_to r init)
(fun v -> post v ** op_exists_Star (pts_to r)))
: stt ret_t pre post | let with_local
(#a:Type0)
(init:a)
(#pre:vprop)
(#ret_t:Type)
(#post:ret_t -> vprop)
(body:(r:ref a) -> stt ret_t (pre ** pts_to r init)
(fun v -> post v ** op_exists_Star (pts_to r #full_perm)))
: stt ret_t pre post
= let body (r:H.ref (U.raise_t a))
: stt ret_t (pre ** H.pts_to r #full_perm (U.raise_val init))
(fun v -> post v ** (exists* (x:U.raise_t a). H.pts_to r #full_perm x))
= let m
: stt ret_t (pre ** H.pts_to r #full_perm (U.raise_val init))
(fun v -> post v ** (exists* (x:a). H.pts_to r #full_perm (U.raise_val x)))
= body r
in
let m0 (v:ret_t)
: stt ret_t
(post v ** (exists* (x:a). H.pts_to r #full_perm (U.raise_val x)))
(fun v -> post v ** (exists* (x:U.raise_t a). H.pts_to r #full_perm x))
= bind_stt (raise_exists (post v) (H.pts_to r #full_perm))
(fun _ -> return_stt_noeq v (fun v -> post v ** (exists* (x:U.raise_t a). H.pts_to r #full_perm x)))
in
bind_stt m m0
in
H.with_local (U.raise_val init) body | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Reference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 38,
"end_line": 212,
"start_col": 0,
"start_line": 186
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Lib.Reference
open Pulse.Lib.Core
open Pulse.Main
module H = Pulse.Lib.HigherReference
module U = FStar.Universe
let ref a = H.ref (U.raise_t a)
let pts_to
(#a:Type u#0)
(r:ref a)
(#[exact (`full_perm)] [@@@equate_by_smt] p:perm)
([@@@equate_by_smt] v:a)
= H.pts_to r #p (U.raise_val v)
```pulse
fn alloc' (#a:Type u#0) (v:a)
requires emp
returns r:ref a
ensures pts_to r v
{
let r = H.alloc (U.raise_val v);
fold (pts_to r #full_perm v);
r
}
```
let alloc = alloc'
```pulse
fn read (#a:Type) (r:ref a) (#n:erased a) (#p:perm)
requires pts_to r #p n
returns x:a
ensures pts_to r #p n ** pure (eq2 #a (reveal n) x)
{
unfold (pts_to r #p n);
let k = H.( !r );
fold (pts_to r #p n);
U.downgrade_val k
}
```
let ( ! ) #a = read #a
```pulse
fn write (#a:Type) (r:ref a) (x:a) (#n:erased a)
requires pts_to r #full_perm n
ensures pts_to r #full_perm x
{
unfold (pts_to r #full_perm n);
H.(r := (U.raise_val x));
fold (pts_to r #full_perm x)
}
```
let ( := ) #a r x #n = write #a r x #n
```pulse
fn free' #a (r:ref a) (#n:erased a)
requires pts_to r #full_perm n
ensures emp
{
unfold (pts_to r #full_perm n);
H.free r;
}
```
let free = free'
```pulse
ghost
fn share' (#a:Type) (r:ref a) (#v:erased a) (#p:perm)
requires pts_to r #p v
ensures pts_to r #(half_perm p) v ** pts_to r #(half_perm p) v
{
unfold pts_to r #p v;
H.share r;
fold pts_to r #(half_perm p) v;
fold pts_to r #(half_perm p) v
}
```
let share = share'
```pulse
ghost
fn raise_inj (a:Type u#0) (x0 x1:a)
requires pure (U.raise_val u#0 u#1 x0 == U.raise_val u#0 u#1 x1)
ensures pure (x0 == x1)
{
assert pure (U.downgrade_val (U.raise_val u#0 u#1 x0) == x0);
assert pure (U.downgrade_val (U.raise_val u#0 u#1 x1) == x1);
}
```
```pulse
ghost
fn gather' (#a:Type) (r:ref a) (#x0 #x1:erased a) (#p0 #p1:perm)
requires pts_to r #p0 x0 ** pts_to r #p1 x1
ensures pts_to r #(sum_perm p0 p1) x0 ** pure (x0 == x1)
{
unfold pts_to r #p0 x0;
unfold pts_to r #p1 x1;
H.gather r;
fold (pts_to r #(sum_perm p1 p0) x0);
let qq = sum_perm p0 p1; //hack! prevent the unifier from structurally matching sum_perm p0 p1 with sum_perm p1 p0
rewrite (pts_to r #(sum_perm p1 p0) x0)
as (pts_to r #qq x0);
raise_inj a x0 x1;
}
```
let gather = gather'
let share2 (#a:Type) (r:ref a) (#v:erased a)
: stt_ghost unit
(pts_to r v)
(fun _ -> pts_to r #one_half v ** pts_to r #one_half v)
= share #a r #v
let gather2 (#a:Type) (r:ref a) (#x0 #x1:erased a)
: stt_ghost unit
(pts_to r #one_half x0 ** pts_to r #one_half x1)
(fun () -> pts_to r x0 ** pure (x0 == x1))
= gather r
let read_atomic (r:ref U32.t) (#n:erased U32.t) (#p:perm)
: stt_atomic U32.t emp_inames
(pts_to r #p n)
(fun x -> pts_to r #p n ** pure (reveal n == x))
= Pulse.Lib.Core.as_atomic _ _ (read r #n #p)
let write_atomic (r:ref U32.t) (x:U32.t) (#n:erased U32.t)
= Pulse.Lib.Core.as_atomic _ _ (write r x #n)
```pulse
fn cas_impl
(r:ref U32.t)
(u v:U32.t)
(#i:erased U32.t)
requires
pts_to r i
returns b:bool
ensures
cond b (pts_to r v ** pure (reveal i == u))
(pts_to r i)
{
let u' = read r;
if (u = u')
{
write r v;
fold (cond true (pts_to r v ** pure (reveal i == u)) (pts_to r i));
true
}
else
{
fold cond false (pts_to r v ** pure (reveal i == u)) (pts_to r i);
false
}
}
```
let cas r u v #i = Pulse.Lib.Core.as_atomic _ _ (cas_impl r u v #i)
```pulse
fn
raise_exists (#a:Type u#0) (frame:vprop) (p: U.raise_t u#0 u#1 a -> vprop)
requires frame ** (exists* (x:a). p (U.raise_val x))
ensures frame ** (exists* (x:U.raise_t a). p x)
{
()
}
``` | {
"checked_file": "/",
"dependencies": [
"Pulse.Main.fsti.checked",
"Pulse.Lib.HigherReference.fsti.checked",
"Pulse.Lib.Core.fsti.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Lib.Reference.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Pulse.Lib.HigherReference",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Pulse.Main",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.Observability",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
init: a ->
body:
(r: Pulse.Lib.Reference.ref a
-> Pulse.Lib.Core.stt ret_t
(pre ** Pulse.Lib.Reference.pts_to r init)
(fun v -> post v ** (exists . Pulse.Lib.Reference.pts_to r)))
-> Pulse.Lib.Core.stt ret_t pre post | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.Core.vprop",
"Pulse.Lib.Reference.ref",
"Pulse.Lib.Core.stt",
"Pulse.Lib.Core.op_Star_Star",
"Pulse.Lib.Reference.pts_to",
"PulseCore.FractionalPermission.full_perm",
"Pulse.Lib.Core.op_exists_Star",
"Pulse.Lib.HigherReference.with_local",
"FStar.Universe.raise_t",
"FStar.Universe.raise_val",
"Pulse.Lib.HigherReference.ref",
"Pulse.Lib.HigherReference.pts_to",
"Pulse.Lib.Core.bind_stt",
"Prims.unit",
"Pulse.Lib.Reference.raise_exists",
"Pulse.Lib.Core.return_stt_noeq"
] | [] | false | false | false | false | false | let with_local
(#a: Type0)
(init: a)
(#pre: vprop)
(#ret_t: Type)
(#post: (ret_t -> vprop))
(body:
(r: ref a
-> stt ret_t
(pre ** pts_to r init)
(fun v -> post v ** op_exists_Star (pts_to r #full_perm))))
: stt ret_t pre post =
| let body (r: H.ref (U.raise_t a))
: stt ret_t
(pre ** H.pts_to r #full_perm (U.raise_val init))
(fun v -> post v ** (exists* (x: U.raise_t a). H.pts_to r #full_perm x)) =
let m:stt ret_t
(pre ** H.pts_to r #full_perm (U.raise_val init))
(fun v -> post v ** (exists* (x: a). H.pts_to r #full_perm (U.raise_val x))) =
body r
in
let m0 (v: ret_t)
: stt ret_t
(post v ** (exists* (x: a). H.pts_to r #full_perm (U.raise_val x)))
(fun v -> post v ** (exists* (x: U.raise_t a). H.pts_to r #full_perm x)) =
bind_stt (raise_exists (post v) (H.pts_to r #full_perm))
(fun _ ->
return_stt_noeq v (fun v -> post v ** (exists* (x: U.raise_t a). H.pts_to r #full_perm x))
)
in
bind_stt m m0
in
H.with_local (U.raise_val init) body | false |
Pulse.Checker.Prover.Base.fsti | Pulse.Checker.Prover.Base.ss_extends | val ss_extends : ss1: Pulse.Checker.Prover.Substs.ss_t -> ss2: Pulse.Checker.Prover.Substs.ss_t -> Prims.logical | let ss_extends (ss1 ss2:PS.ss_t) =
Set.subset (PS.dom ss2) (PS.dom ss1) /\
(forall (x:var). PS.contains ss2 x ==> PS.sel ss1 x == PS.sel ss2 x) | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Base.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 70,
"end_line": 124,
"start_col": 0,
"start_line": 122
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Checker.Prover.Base
open Pulse.Syntax
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Base
module T = FStar.Tactics.V2
module PS = Pulse.Checker.Prover.Substs
let vprop_typing (g:env) (t:term) = tot_typing g t tm_vprop
//
// Scaffolding for adding elims
//
// Given a function f : vprop -> T.Tac bool that decides whether a vprop
// should be elim-ed,
// and an mk function to create the elim term, comp, and typing,
// add_elims will create a continuation_elaborator
//
type mk_t =
#g:env ->
#v:vprop ->
tot_typing g v tm_vprop ->
T.Tac (option (x:ppname &
t:st_term &
c:comp { stateful_comp c /\ comp_pre c == v } &
st_typing g t c))
val add_elims (#g:env) (#ctxt:term) (#frame:term)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(ctxt_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame))
//
// Prover state
//
noeq type preamble = {
g0 : env;
ctxt : vprop;
frame : vprop;
ctxt_frame_typing : vprop_typing g0 (tm_star ctxt frame);
goals : vprop;
}
let op_Array_Access (ss:PS.ss_t) (t:term) =
PS.ss_term t ss
let op_Star = tm_star
noeq
type prover_state (preamble:preamble) = {
pg : g:env { g `env_extends` preamble.g0 };
remaining_ctxt : list vprop;
remaining_ctxt_frame_typing : vprop_typing pg (list_as_vprop remaining_ctxt * preamble.frame);
uvs : uvs:env { disjoint uvs pg };
ss : PS.ss_t;
//
// these are the typed ss
// sometimes a step in the prover (e.g., intro exists) may compute these
// in such cases, the prover doesn't need to compute again
// so we cache them here
//
nts : option (nts:PS.nt_substs & effect_labels:list T.tot_or_ghost {
PS.well_typed_nt_substs pg uvs nts effect_labels /\
PS.is_permutation nts ss
});
solved : vprop;
unsolved : list vprop;
k : continuation_elaborator preamble.g0 (preamble.ctxt * preamble.frame)
pg ((list_as_vprop remaining_ctxt * preamble.frame) * ss.(solved));
goals_inv : vprop_equiv (push_env pg uvs) preamble.goals (list_as_vprop unsolved * solved);
solved_inv : squash (freevars ss.(solved) `Set.subset` dom pg);
}
let is_terminal (#preamble:_) (st:prover_state preamble) =
st.unsolved == []
irreducible
let extend_post_hint_opt_g (g:env) (post_hint:post_hint_opt g) (g1:env { g1 `env_extends` g })
: p:post_hint_opt g1 { p == post_hint } =
match post_hint with
| None -> None
| Some post_hint ->
assert (g `env_extends` post_hint.g);
assert (g1 `env_extends` g);
assert (g1 `env_extends` post_hint.g);
Some post_hint | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Checker.Prover.Base.fsti"
} | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": 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 | ss1: Pulse.Checker.Prover.Substs.ss_t -> ss2: Pulse.Checker.Prover.Substs.ss_t -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Pulse.Checker.Prover.Substs.ss_t",
"Prims.l_and",
"FStar.Set.subset",
"Pulse.Syntax.Base.var",
"Pulse.Checker.Prover.Substs.dom",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.b2t",
"Pulse.Checker.Prover.Substs.contains",
"Prims.eq2",
"Pulse.Syntax.Base.term",
"Pulse.Checker.Prover.Substs.sel",
"Prims.logical"
] | [] | false | false | false | true | true | let ss_extends (ss1 ss2: PS.ss_t) =
| Set.subset (PS.dom ss2) (PS.dom ss1) /\
(forall (x: var). PS.contains ss2 x ==> PS.sel ss1 x == PS.sel ss2 x) | false |
|
Hacl.Streaming.Blake2s_128.fst | Hacl.Streaming.Blake2s_128.alloca | val alloca : Hacl.Streaming.Functor.alloca_st (Hacl.Streaming.Blake2s_128.blake2s_128 0)
()
(Hacl.Streaming.Blake2.Common.s Spec.Blake2.Definitions.Blake2S Hacl.Impl.Blake2.Core.M128)
(Hacl.Streaming.Blake2.Common.empty_key Spec.Blake2.Definitions.Blake2S) | let alloca =
F.alloca (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | {
"file_name": "code/streaming/Hacl.Streaming.Blake2s_128.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 95,
"end_line": 26,
"start_col": 0,
"start_line": 25
} | module Hacl.Streaming.Blake2s_128
module Blake2s128 = Hacl.Blake2s_128
module Common = Hacl.Streaming.Blake2.Common
module Core = Hacl.Impl.Blake2.Core
module F = Hacl.Streaming.Functor
module G = FStar.Ghost
module Impl = Hacl.Impl.Blake2.Generic
module Spec = Spec.Blake2
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// The functor
inline_for_extraction noextract
let blake2s_128 kk =
Common.blake2 Spec.Blake2S Core.M128 kk Blake2s128.init Blake2s128.update_multi
Blake2s128.update_last Blake2s128.finish
/// Type abbreviations
let block_state_t = Common.s Spec.Blake2S Core.M128
let state_t = F.state_s (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S)
/// No key | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Streaming.Blake2.Common.fst.checked",
"Hacl.Impl.Blake2.Generic.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Blake2s_128.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Blake2s_128.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Generic",
"short_module": "Impl"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Core"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Blake2.Common",
"short_module": "Common"
},
{
"abbrev": true,
"full_module": "Hacl.Blake2s_128",
"short_module": "Blake2s128"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Hacl.Streaming.Functor.alloca_st (Hacl.Streaming.Blake2s_128.blake2s_128 0)
()
(Hacl.Streaming.Blake2.Common.s Spec.Blake2.Definitions.Blake2S Hacl.Impl.Blake2.Core.M128)
(Hacl.Streaming.Blake2.Common.empty_key Spec.Blake2.Definitions.Blake2S) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Functor.alloca",
"Prims.unit",
"Hacl.Streaming.Blake2s_128.blake2s_128",
"Hacl.Streaming.Blake2.Common.s",
"Spec.Blake2.Definitions.Blake2S",
"Hacl.Impl.Blake2.Core.M128",
"Hacl.Streaming.Blake2.Common.empty_key"
] | [] | false | false | false | false | false | let alloca =
| F.alloca (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | false |
|
LowParse.Spec.Combinators.fst | LowParse.Spec.Combinators.and_then | val and_then
(#k: parser_kind)
(#t:Type)
(p:parser k t)
(#k': parser_kind)
(#t':Type)
(p': (t -> Tot (parser k' t')))
: Pure (parser (and_then_kind k k') t')
(requires (
and_then_cases_injective p'
))
(ensures (fun _ -> True)) | val and_then
(#k: parser_kind)
(#t:Type)
(p:parser k t)
(#k': parser_kind)
(#t':Type)
(p': (t -> Tot (parser k' t')))
: Pure (parser (and_then_kind k k') t')
(requires (
and_then_cases_injective p'
))
(ensures (fun _ -> True)) | let and_then #k #t p #k' #t' p' =
let f : bare_parser t' = and_then_bare p p' in
and_then_correct p p' ;
f | {
"file_name": "src/lowparse/LowParse.Spec.Combinators.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 3,
"end_line": 15,
"start_col": 0,
"start_line": 12
} | module LowParse.Spec.Combinators
include LowParse.Spec.Base
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module T = FStar.Tactics
#reset-options "--using_facts_from '* -FStar.Tactis -FStar.Reflection'" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.Combinators.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": 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: LowParse.Spec.Base.parser k t -> p': (_: t -> LowParse.Spec.Base.parser k' t')
-> Prims.Pure (LowParse.Spec.Base.parser (LowParse.Spec.Combinators.and_then_kind k k') t') | Prims.Pure | [] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"Prims.unit",
"LowParse.Spec.Combinators.and_then_correct",
"LowParse.Spec.Base.bare_parser",
"LowParse.Spec.Combinators.and_then_bare",
"LowParse.Spec.Combinators.and_then_kind"
] | [] | false | false | false | false | false | let and_then #k #t p #k' #t' p' =
| let f:bare_parser t' = and_then_bare p p' in
and_then_correct p p';
f | false |
Hacl.Streaming.Blake2s_128.fst | Hacl.Streaming.Blake2s_128.state_t | val state_t : Type0 | let state_t = F.state_s (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | {
"file_name": "code/streaming/Hacl.Streaming.Blake2s_128.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 108,
"end_line": 21,
"start_col": 0,
"start_line": 21
} | module Hacl.Streaming.Blake2s_128
module Blake2s128 = Hacl.Blake2s_128
module Common = Hacl.Streaming.Blake2.Common
module Core = Hacl.Impl.Blake2.Core
module F = Hacl.Streaming.Functor
module G = FStar.Ghost
module Impl = Hacl.Impl.Blake2.Generic
module Spec = Spec.Blake2
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// The functor
inline_for_extraction noextract
let blake2s_128 kk =
Common.blake2 Spec.Blake2S Core.M128 kk Blake2s128.init Blake2s128.update_multi
Blake2s128.update_last Blake2s128.finish
/// Type abbreviations | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Streaming.Blake2.Common.fst.checked",
"Hacl.Impl.Blake2.Generic.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Blake2s_128.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Blake2s_128.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Generic",
"short_module": "Impl"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Core"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Blake2.Common",
"short_module": "Common"
},
{
"abbrev": true,
"full_module": "Hacl.Blake2s_128",
"short_module": "Blake2s128"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Functor.state_s",
"Prims.unit",
"Hacl.Streaming.Blake2s_128.blake2s_128",
"Hacl.Streaming.Blake2.Common.s",
"Spec.Blake2.Definitions.Blake2S",
"Hacl.Impl.Blake2.Core.M128",
"Hacl.Streaming.Blake2.Common.empty_key"
] | [] | false | false | false | true | true | let state_t =
| F.state_s (blake2s_128 0) () (Common.s Spec.Blake2S Core.M128) (Common.empty_key Spec.Blake2S) | false |
|
LowParse.Spec.Combinators.fst | LowParse.Spec.Combinators.parse_tagged_union | val parse_tagged_union
(#kt: parser_kind)
(#tag_t: Type)
(pt: parser kt tag_t)
(#data_t: Type)
(tag_of_data: (data_t -> GTot tag_t))
(#k: parser_kind)
(p: (t: tag_t) -> Tot (parser k (refine_with_tag tag_of_data t)))
: Tot (parser (and_then_kind kt k) data_t) | val parse_tagged_union
(#kt: parser_kind)
(#tag_t: Type)
(pt: parser kt tag_t)
(#data_t: Type)
(tag_of_data: (data_t -> GTot tag_t))
(#k: parser_kind)
(p: (t: tag_t) -> Tot (parser k (refine_with_tag tag_of_data t)))
: Tot (parser (and_then_kind kt k) data_t) | let parse_tagged_union #kt #tag_t pt #data_t tag_of_data #k p =
parse_tagged_union_payload_and_then_cases_injective tag_of_data p;
pt `and_then` parse_tagged_union_payload tag_of_data p | {
"file_name": "src/lowparse/LowParse.Spec.Combinators.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 56,
"end_line": 202,
"start_col": 0,
"start_line": 200
} | module LowParse.Spec.Combinators
include LowParse.Spec.Base
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module T = FStar.Tactics
#reset-options "--using_facts_from '* -FStar.Tactis -FStar.Reflection'"
let and_then #k #t p #k' #t' p' =
let f : bare_parser t' = and_then_bare p p' in
and_then_correct p p' ;
f
let and_then_eq
(#k: parser_kind)
(#t:Type)
(p:parser k t)
(#k': parser_kind)
(#t':Type)
(p': (t -> Tot (parser k' t')))
(input: bytes)
: Lemma
(requires (and_then_cases_injective p'))
(ensures (parse (and_then p p') input == and_then_bare p p' input))
= ()
let tot_and_then_bare (#t:Type) (#t':Type)
(p:tot_bare_parser t)
(p': (t -> Tot (tot_bare_parser t'))) :
Tot (tot_bare_parser t') =
fun (b: bytes) ->
match p b with
| Some (v, l) ->
begin
let p'v = p' v in
let s' : bytes = Seq.slice b l (Seq.length b) in
match p'v s' with
| Some (v', l') ->
let res : consumed_length b = l + l' in
Some (v', res)
| None -> None
end
| None -> None
let tot_and_then #k #t p #k' #t' p' =
let f : tot_bare_parser t' = tot_and_then_bare p p' in
and_then_correct #k p #k' p' ;
parser_kind_prop_ext (and_then_kind k k') (and_then_bare p p') f;
f
let parse_synth
(#k: parser_kind)
(#t1: Type)
(#t2: Type)
(p1: parser k t1)
(f2: t1 -> GTot t2)
: Pure (parser k t2)
(requires (
synth_injective f2
))
(ensures (fun _ -> True))
= coerce (parser k t2) (and_then p1 (fun v1 -> parse_fret f2 v1))
let parse_synth_eq
(#k: parser_kind)
(#t1: Type)
(#t2: Type)
(p1: parser k t1)
(f2: t1 -> GTot t2)
(b: bytes)
: Lemma
(requires (synth_injective f2))
(ensures (parse (parse_synth p1 f2) b == parse_synth' p1 f2 b))
= ()
unfold
let tot_parse_fret' (#t #t':Type) (f: t -> Tot t') (v:t) : Tot (tot_bare_parser t') =
fun (b: bytes) -> Some (f v, (0 <: consumed_length b))
unfold
let tot_parse_fret (#t #t':Type) (f: t -> Tot t') (v:t) : Tot (tot_parser parse_ret_kind t') =
[@inline_let] let _ = parser_kind_prop_equiv parse_ret_kind (tot_parse_fret' f v) in
tot_parse_fret' f v
let tot_parse_synth
#k #t1 #t2 p1 f2
= coerce (tot_parser k t2) (tot_and_then p1 (fun v1 -> tot_parse_fret f2 v1))
let bare_serialize_synth_correct #k #t1 #t2 p1 f2 s1 g1 =
()
let serialize_synth
(#k: parser_kind)
(#t1: Type)
(#t2: Type)
(p1: parser k t1)
(f2: t1 -> GTot t2)
(s1: serializer p1)
(g1: t2 -> GTot t1)
(u: unit {
synth_inverse f2 g1 /\
synth_injective f2
})
: Tot (serializer (parse_synth p1 f2))
= bare_serialize_synth_correct p1 f2 s1 g1;
bare_serialize_synth p1 f2 s1 g1
let serialize_synth_eq
(#k: parser_kind)
(#t1: Type)
(#t2: Type)
(p1: parser k t1)
(f2: t1 -> GTot t2)
(s1: serializer p1)
(g1: t2 -> GTot t1)
(u: unit {
synth_inverse f2 g1 /\
synth_injective f2
})
(x: t2)
: Lemma
(serialize (serialize_synth p1 f2 s1 g1 u) x == serialize s1 (g1 x))
= ()
let serialize_synth_upd_chain
(#k: parser_kind)
(#t1: Type)
(#t2: Type)
(p1: parser k t1)
(f2: t1 -> GTot t2)
(s1: serializer p1)
(g1: t2 -> GTot t1)
(u: unit {
synth_inverse f2 g1 /\
synth_injective f2
})
(x1: t1)
(x2: t2)
(y1: t1)
(y2: t2)
(i': nat)
(s' : bytes)
: Lemma
(requires (
let s = serialize s1 x1 in
i' + Seq.length s' <= Seq.length s /\
serialize s1 y1 == seq_upd_seq s i' s' /\
x2 == f2 x1 /\
y2 == f2 y1
))
(ensures (
let s = serialize (serialize_synth p1 f2 s1 g1 u) x2 in
i' + Seq.length s' <= Seq.length s /\
Seq.length s == Seq.length (serialize s1 x1) /\
serialize (serialize_synth p1 f2 s1 g1 u) y2 == seq_upd_seq s i' s'
))
= (* I don't know which are THE terms to exhibit among x1, x2, y1, y2 to make the patterns trigger *)
assert (forall w w' . f2 w == f2 w' ==> w == w');
assert (forall w . f2 (g1 w) == w)
let serialize_synth_upd_bw_chain
(#k: parser_kind)
(#t1: Type)
(#t2: Type)
(p1: parser k t1)
(f2: t1 -> GTot t2)
(s1: serializer p1)
(g1: t2 -> GTot t1)
(u: unit {
synth_inverse f2 g1 /\
synth_injective f2
})
(x1: t1)
(x2: t2)
(y1: t1)
(y2: t2)
(i': nat)
(s' : bytes)
: Lemma
(requires (
let s = serialize s1 x1 in
i' + Seq.length s' <= Seq.length s /\
serialize s1 y1 == seq_upd_bw_seq s i' s' /\
x2 == f2 x1 /\
y2 == f2 y1
))
(ensures (
let s = serialize (serialize_synth p1 f2 s1 g1 u) x2 in
i' + Seq.length s' <= Seq.length s /\
Seq.length s == Seq.length (serialize s1 x1) /\
serialize (serialize_synth p1 f2 s1 g1 u) y2 == seq_upd_bw_seq s i' s'
))
= (* I don't know which are THE terms to exhibit among x1, x2, y1, y2 to make the patterns trigger *)
assert (forall w w' . f2 w == f2 w' ==> w == w');
assert (forall w . f2 (g1 w) == w) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.Combinators.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": 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 |
pt: LowParse.Spec.Base.parser kt tag_t ->
tag_of_data: (_: data_t -> Prims.GTot tag_t) ->
p: (t: tag_t -> LowParse.Spec.Base.parser k (LowParse.Spec.Base.refine_with_tag tag_of_data t))
-> LowParse.Spec.Base.parser (LowParse.Spec.Combinators.and_then_kind kt k) data_t | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.refine_with_tag",
"LowParse.Spec.Combinators.and_then",
"LowParse.Spec.Combinators.parse_tagged_union_payload",
"Prims.unit",
"LowParse.Spec.Combinators.parse_tagged_union_payload_and_then_cases_injective",
"LowParse.Spec.Combinators.and_then_kind"
] | [] | false | false | false | false | false | let parse_tagged_union #kt #tag_t pt #data_t tag_of_data #k p =
| parse_tagged_union_payload_and_then_cases_injective tag_of_data p;
pt `and_then` (parse_tagged_union_payload tag_of_data p) | false |
Pulse.Checker.Prover.Base.fsti | Pulse.Checker.Prover.Base.extend_post_hint_opt_g | val extend_post_hint_opt_g (g: env) (post_hint: post_hint_opt g) (g1: env{g1 `env_extends` g})
: p: post_hint_opt g1 {p == post_hint} | val extend_post_hint_opt_g (g: env) (post_hint: post_hint_opt g) (g1: env{g1 `env_extends` g})
: p: post_hint_opt g1 {p == post_hint} | let extend_post_hint_opt_g (g:env) (post_hint:post_hint_opt g) (g1:env { g1 `env_extends` g })
: p:post_hint_opt g1 { p == post_hint } =
match post_hint with
| None -> None
| Some post_hint ->
assert (g `env_extends` post_hint.g);
assert (g1 `env_extends` g);
assert (g1 `env_extends` post_hint.g);
Some post_hint | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Base.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 18,
"end_line": 120,
"start_col": 0,
"start_line": 112
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Checker.Prover.Base
open Pulse.Syntax
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Base
module T = FStar.Tactics.V2
module PS = Pulse.Checker.Prover.Substs
let vprop_typing (g:env) (t:term) = tot_typing g t tm_vprop
//
// Scaffolding for adding elims
//
// Given a function f : vprop -> T.Tac bool that decides whether a vprop
// should be elim-ed,
// and an mk function to create the elim term, comp, and typing,
// add_elims will create a continuation_elaborator
//
type mk_t =
#g:env ->
#v:vprop ->
tot_typing g v tm_vprop ->
T.Tac (option (x:ppname &
t:st_term &
c:comp { stateful_comp c /\ comp_pre c == v } &
st_typing g t c))
val add_elims (#g:env) (#ctxt:term) (#frame:term)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(ctxt_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame))
//
// Prover state
//
noeq type preamble = {
g0 : env;
ctxt : vprop;
frame : vprop;
ctxt_frame_typing : vprop_typing g0 (tm_star ctxt frame);
goals : vprop;
}
let op_Array_Access (ss:PS.ss_t) (t:term) =
PS.ss_term t ss
let op_Star = tm_star
noeq
type prover_state (preamble:preamble) = {
pg : g:env { g `env_extends` preamble.g0 };
remaining_ctxt : list vprop;
remaining_ctxt_frame_typing : vprop_typing pg (list_as_vprop remaining_ctxt * preamble.frame);
uvs : uvs:env { disjoint uvs pg };
ss : PS.ss_t;
//
// these are the typed ss
// sometimes a step in the prover (e.g., intro exists) may compute these
// in such cases, the prover doesn't need to compute again
// so we cache them here
//
nts : option (nts:PS.nt_substs & effect_labels:list T.tot_or_ghost {
PS.well_typed_nt_substs pg uvs nts effect_labels /\
PS.is_permutation nts ss
});
solved : vprop;
unsolved : list vprop;
k : continuation_elaborator preamble.g0 (preamble.ctxt * preamble.frame)
pg ((list_as_vprop remaining_ctxt * preamble.frame) * ss.(solved));
goals_inv : vprop_equiv (push_env pg uvs) preamble.goals (list_as_vprop unsolved * solved);
solved_inv : squash (freevars ss.(solved) `Set.subset` dom pg);
}
let is_terminal (#preamble:_) (st:prover_state preamble) =
st.unsolved == [] | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Checker.Prover.Base.fsti"
} | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
g: Pulse.Typing.Env.env ->
post_hint: Pulse.Typing.post_hint_opt g ->
g1: Pulse.Typing.Env.env{Pulse.Typing.Env.env_extends g1 g}
-> p: Pulse.Typing.post_hint_opt g1 {p == post_hint} | Prims.Tot | [
"total"
] | [] | [
"Pulse.Typing.Env.env",
"Pulse.Typing.post_hint_opt",
"Pulse.Typing.Env.env_extends",
"FStar.Pervasives.Native.None",
"Pulse.Typing.post_hint_t",
"FStar.Pervasives.Native.Some",
"Prims.unit",
"Prims._assert",
"Pulse.Typing.__proj__Mkpost_hint_t__item__g",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"Prims.l_or",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_None",
"Pulse.Typing.post_hint_for_env_p",
"FStar.Pervasives.Native.__proj__Some__item__v"
] | [] | false | false | false | false | false | let extend_post_hint_opt_g (g: env) (post_hint: post_hint_opt g) (g1: env{g1 `env_extends` g})
: p: post_hint_opt g1 {p == post_hint} =
| match post_hint with
| None -> None
| Some post_hint ->
assert (g `env_extends` post_hint.g);
assert (g1 `env_extends` g);
assert (g1 `env_extends` post_hint.g);
Some post_hint | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.