effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lowstar_fmul2_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul2
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul2 fmul_dom [] (fmul2_lemma code_Fmul2 IA.win)) | let lowstar_fmul2_t = | false | null | false | assert_norm (List.length fmul_dom + List.length ([] <: list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall code_Fmul2
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul2 fmul_dom [] (fmul2_lemma code_Fmul2 IA.win)) | {
"checked_file": "Vale.Stdcalls.X64.Fmul.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fmul.fsti"
} | [
"total"
] | [
"Vale.Interop.X64.as_lowstar_sig_t_weak_stdcall",
"Vale.Stdcalls.X64.Fmul.code_Fmul2",
"Vale.Stdcalls.X64.Fmul.fmul_dom",
"Prims.Nil",
"Vale.Interop.Base.arg",
"Vale.AsLowStar.Wrapper.pre_rel_generic",
"Vale.Interop.X64.max_stdcall",
"Vale.Interop.X64.arg_reg_stdcall",
"Vale.Stdcalls.X64.Fmul.fmul2_pre",
"Vale.AsLowStar.Wrapper.post_rel_generic",
"Vale.Stdcalls.X64.Fmul.fmul2_post",
"Vale.AsLowStar.Wrapper.mk_prediction",
"Vale.Interop.X64.regs_modified_stdcall",
"Vale.Interop.X64.xmms_modified_stdcall",
"Vale.Stdcalls.X64.Fmul.fmul2_lemma",
"Vale.Interop.Assumptions.win",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.List.Tot.Base.length",
"Vale.Interop.Base.td",
"Prims.list"
] | [] | module Vale.Stdcalls.X64.Fmul
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AsLowStar.MemoryHelpers
module FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let fmul_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_mod; t64_no_mod] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul_lemma' has the required type *)
noextract
let fmul_lemma = as_t #(VSig.vale_sig_stdcall fmul_pre fmul_post) fmul_lemma'
noextract
let code_Fmul = FW.va_code_Fmul_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract
let lowstar_fmul_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul fmul_dom [] (fmul_lemma code_Fmul IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul2_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul2_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul2_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul2_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul2_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul2_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul2_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul2_lemma' has the required type *)
noextract
let fmul2_lemma = as_t #(VSig.vale_sig_stdcall fmul2_pre fmul2_post) fmul2_lemma'
noextract
let code_Fmul2 = FW.va_code_Fmul2_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract | false | true | Vale.Stdcalls.X64.Fmul.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lowstar_fmul2_t : Type0 | [] | Vale.Stdcalls.X64.Fmul.lowstar_fmul2_t | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fmul.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 76,
"end_line": 209,
"start_col": 2,
"start_line": 202
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lowstar_fmul1_t =
assert_norm (List.length fmul1_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul1
fmul1_dom
[]
_
_
(W.mk_prediction code_Fmul1 fmul1_dom [] (fmul1_lemma code_Fmul1 IA.win)) | let lowstar_fmul1_t = | false | null | false | assert_norm (List.length fmul1_dom + List.length ([] <: list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall code_Fmul1
fmul1_dom
[]
_
_
(W.mk_prediction code_Fmul1 fmul1_dom [] (fmul1_lemma code_Fmul1 IA.win)) | {
"checked_file": "Vale.Stdcalls.X64.Fmul.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fmul.fsti"
} | [
"total"
] | [
"Vale.Interop.X64.as_lowstar_sig_t_weak_stdcall",
"Vale.Stdcalls.X64.Fmul.code_Fmul1",
"Vale.Stdcalls.X64.Fmul.fmul1_dom",
"Prims.Nil",
"Vale.Interop.Base.arg",
"Vale.AsLowStar.Wrapper.pre_rel_generic",
"Vale.Interop.X64.max_stdcall",
"Vale.Interop.X64.arg_reg_stdcall",
"Vale.Stdcalls.X64.Fmul.fmul1_pre",
"Vale.AsLowStar.Wrapper.post_rel_generic",
"Vale.Stdcalls.X64.Fmul.fmul1_post",
"Vale.AsLowStar.Wrapper.mk_prediction",
"Vale.Interop.X64.regs_modified_stdcall",
"Vale.Interop.X64.xmms_modified_stdcall",
"Vale.Stdcalls.X64.Fmul.fmul1_lemma",
"Vale.Interop.Assumptions.win",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.List.Tot.Base.length",
"Vale.Interop.Base.td",
"Prims.list"
] | [] | module Vale.Stdcalls.X64.Fmul
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AsLowStar.MemoryHelpers
module FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let fmul_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_mod; t64_no_mod] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul_lemma' has the required type *)
noextract
let fmul_lemma = as_t #(VSig.vale_sig_stdcall fmul_pre fmul_post) fmul_lemma'
noextract
let code_Fmul = FW.va_code_Fmul_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract
let lowstar_fmul_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul fmul_dom [] (fmul_lemma code_Fmul IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul2_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul2_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul2_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul2_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul2_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul2_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul2_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul2_lemma' has the required type *)
noextract
let fmul2_lemma = as_t #(VSig.vale_sig_stdcall fmul2_pre fmul2_post) fmul2_lemma'
noextract
let code_Fmul2 = FW.va_code_Fmul2_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract
let lowstar_fmul2_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul2
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul2 fmul_dom [] (fmul2_lemma code_Fmul2 IA.win))
[@__reduce__] noextract
let fmul1_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul1_pre : VSig.vale_pre fmul1_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state) ->
FH.va_req_Fmul1_stdcall c va_s0 IA.win
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__] noextract
let fmul1_post : VSig.vale_post fmul1_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FH.va_ens_Fmul1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#set-options "--z3rlimit 50"
[@__reduce__] noextract
let fmul1_lemma'
(code:V.va_code)
(_win:bool)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul1_pre code out f1 f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul1_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FH.va_lemma_Fmul1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
let s0 = va_s0 in
let s1 = va_s1 in
let regs_modified = IX64.regs_modified_stdcall in
let xmms_modified = IX64.xmms_modified_stdcall in
let open MS in
let open Vale.AsLowStar.ValeSig in
assert (forall (r:MS.reg_64).{:pattern vale_save_reg r s0 s1} not (regs_modified r) ==> vale_save_reg r s0 s1);
assert (forall (x:MS.reg_xmm).{:pattern vale_save_xmm x s0 s1} not (xmms_modified x) ==> vale_save_xmm x s0 s1);
(va_s1, f)
(* Prove that fmul1_lemma' has the required type *)
noextract
let fmul1_lemma = as_t #(VSig.vale_sig_stdcall fmul1_pre fmul1_post) fmul1_lemma'
noextract
let code_Fmul1 = FH.va_code_Fmul1_stdcall IA.win
(* Here's the type expected for the fmul1 wrapper *)
[@__reduce__] noextract | false | true | Vale.Stdcalls.X64.Fmul.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lowstar_fmul1_t : Type0 | [] | Vale.Stdcalls.X64.Fmul.lowstar_fmul1_t | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fmul.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 77,
"end_line": 292,
"start_col": 2,
"start_line": 285
} |
|
Prims.Tot | val fmul1_dom:IX64.arity_ok_stdcall td | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul1_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64] in
assert_norm (List.length y = 3);
y | val fmul1_dom:IX64.arity_ok_stdcall td
let fmul1_dom:IX64.arity_ok_stdcall td = | false | null | false | let y = [t64_mod; t64_no_mod; tuint64] in
assert_norm (List.length y = 3);
y | {
"checked_file": "Vale.Stdcalls.X64.Fmul.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fmul.fsti"
} | [
"total"
] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"Vale.Interop.Base.td",
"Prims.list",
"Prims.Cons",
"Vale.Stdcalls.X64.Fmul.t64_mod",
"Vale.Stdcalls.X64.Fmul.t64_no_mod",
"Vale.Stdcalls.X64.Fmul.tuint64",
"Prims.Nil"
] | [] | module Vale.Stdcalls.X64.Fmul
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AsLowStar.MemoryHelpers
module FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let fmul_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_mod; t64_no_mod] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul_lemma' has the required type *)
noextract
let fmul_lemma = as_t #(VSig.vale_sig_stdcall fmul_pre fmul_post) fmul_lemma'
noextract
let code_Fmul = FW.va_code_Fmul_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract
let lowstar_fmul_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul fmul_dom [] (fmul_lemma code_Fmul IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul2_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul2_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul2_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul2_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul2_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul2_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul2_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul2_lemma' has the required type *)
noextract
let fmul2_lemma = as_t #(VSig.vale_sig_stdcall fmul2_pre fmul2_post) fmul2_lemma'
noextract
let code_Fmul2 = FW.va_code_Fmul2_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract
let lowstar_fmul2_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul2
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul2 fmul_dom [] (fmul2_lemma code_Fmul2 IA.win)) | false | true | Vale.Stdcalls.X64.Fmul.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fmul1_dom:IX64.arity_ok_stdcall td | [] | Vale.Stdcalls.X64.Fmul.fmul1_dom | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fmul.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.Interop.X64.arity_ok_stdcall Vale.Interop.Base.td | {
"end_col": 3,
"end_line": 215,
"start_col": 41,
"start_line": 212
} |
Prims.Tot | val fmul1_pre:VSig.vale_pre fmul1_dom | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul1_pre : VSig.vale_pre fmul1_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state) ->
FH.va_req_Fmul1_stdcall c va_s0 IA.win
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) | val fmul1_pre:VSig.vale_pre fmul1_dom
let fmul1_pre:VSig.vale_pre fmul1_dom = | false | null | false | fun (c: V.va_code) (out: b64) (f1: b64) (f2: uint64) (va_s0: V.va_state) ->
FH.va_req_Fmul1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) | {
"checked_file": "Vale.Stdcalls.X64.Fmul.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fmul.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_code",
"Vale.Stdcalls.X64.Fmul.b64",
"Vale.Stdcalls.X64.Fmul.uint64",
"Vale.X64.Decls.va_state",
"Vale.Curve25519.X64.FastHybrid.va_req_Fmul1_stdcall",
"Vale.Interop.Assumptions.win",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Arch.HeapTypes_s.TUInt64",
"FStar.UInt64.v",
"Prims.prop"
] | [] | module Vale.Stdcalls.X64.Fmul
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AsLowStar.MemoryHelpers
module FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let fmul_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_mod; t64_no_mod] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul_lemma' has the required type *)
noextract
let fmul_lemma = as_t #(VSig.vale_sig_stdcall fmul_pre fmul_post) fmul_lemma'
noextract
let code_Fmul = FW.va_code_Fmul_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract
let lowstar_fmul_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul fmul_dom [] (fmul_lemma code_Fmul IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul2_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul2_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul2_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul2_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul2_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul2_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul2_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul2_lemma' has the required type *)
noextract
let fmul2_lemma = as_t #(VSig.vale_sig_stdcall fmul2_pre fmul2_post) fmul2_lemma'
noextract
let code_Fmul2 = FW.va_code_Fmul2_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract
let lowstar_fmul2_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul2
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul2 fmul_dom [] (fmul2_lemma code_Fmul2 IA.win))
[@__reduce__] noextract
let fmul1_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract | false | true | Vale.Stdcalls.X64.Fmul.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fmul1_pre:VSig.vale_pre fmul1_dom | [] | Vale.Stdcalls.X64.Fmul.fmul1_pre | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fmul.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.AsLowStar.ValeSig.vale_pre Vale.Stdcalls.X64.Fmul.fmul1_dom | {
"end_col": 62,
"end_line": 226,
"start_col": 2,
"start_line": 220
} |
Prims.Tot | val fmul1_post:VSig.vale_post fmul1_dom | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul1_post : VSig.vale_post fmul1_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FH.va_ens_Fmul1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f | val fmul1_post:VSig.vale_post fmul1_dom
let fmul1_post:VSig.vale_post fmul1_dom = | false | null | false | fun
(c: V.va_code)
(out: b64)
(f1: b64)
(f2: uint64)
(va_s0: V.va_state)
(va_s1: V.va_state)
(f: V.va_fuel)
->
FH.va_ens_Fmul1_stdcall c
va_s0
IA.win
(as_vale_buffer out)
(as_vale_buffer f1)
(UInt64.v f2)
va_s1
f | {
"checked_file": "Vale.Stdcalls.X64.Fmul.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fmul.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_code",
"Vale.Stdcalls.X64.Fmul.b64",
"Vale.Stdcalls.X64.Fmul.uint64",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"Vale.Curve25519.X64.FastHybrid.va_ens_Fmul1_stdcall",
"Vale.Interop.Assumptions.win",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Arch.HeapTypes_s.TUInt64",
"FStar.UInt64.v",
"Prims.prop"
] | [] | module Vale.Stdcalls.X64.Fmul
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AsLowStar.MemoryHelpers
module FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let fmul_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_mod; t64_no_mod] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul_lemma' has the required type *)
noextract
let fmul_lemma = as_t #(VSig.vale_sig_stdcall fmul_pre fmul_post) fmul_lemma'
noextract
let code_Fmul = FW.va_code_Fmul_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract
let lowstar_fmul_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul fmul_dom [] (fmul_lemma code_Fmul IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul2_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul2_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul2_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul2_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul2_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul2_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul2_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul2_lemma' has the required type *)
noextract
let fmul2_lemma = as_t #(VSig.vale_sig_stdcall fmul2_pre fmul2_post) fmul2_lemma'
noextract
let code_Fmul2 = FW.va_code_Fmul2_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract
let lowstar_fmul2_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul2
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul2 fmul_dom [] (fmul2_lemma code_Fmul2 IA.win))
[@__reduce__] noextract
let fmul1_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul1_pre : VSig.vale_pre fmul1_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state) ->
FH.va_req_Fmul1_stdcall c va_s0 IA.win
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__] noextract | false | true | Vale.Stdcalls.X64.Fmul.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fmul1_post:VSig.vale_post fmul1_dom | [] | Vale.Stdcalls.X64.Fmul.fmul1_post | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fmul.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.AsLowStar.ValeSig.vale_post Vale.Stdcalls.X64.Fmul.fmul1_dom | {
"end_col": 107,
"end_line": 237,
"start_col": 2,
"start_line": 230
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul1_lemma = as_t #(VSig.vale_sig_stdcall fmul1_pre fmul1_post) fmul1_lemma' | let fmul1_lemma = | false | null | false | as_t #(VSig.vale_sig_stdcall fmul1_pre fmul1_post) fmul1_lemma' | {
"checked_file": "Vale.Stdcalls.X64.Fmul.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fmul.fsti"
} | [
"total"
] | [
"Vale.Stdcalls.X64.Fmul.as_t",
"Vale.AsLowStar.ValeSig.vale_sig_stdcall",
"Vale.Stdcalls.X64.Fmul.fmul1_dom",
"Vale.Stdcalls.X64.Fmul.fmul1_pre",
"Vale.Stdcalls.X64.Fmul.fmul1_post",
"Vale.Stdcalls.X64.Fmul.fmul1_lemma'"
] | [] | module Vale.Stdcalls.X64.Fmul
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AsLowStar.MemoryHelpers
module FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let fmul_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_mod; t64_no_mod] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul_lemma' has the required type *)
noextract
let fmul_lemma = as_t #(VSig.vale_sig_stdcall fmul_pre fmul_post) fmul_lemma'
noextract
let code_Fmul = FW.va_code_Fmul_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract
let lowstar_fmul_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul fmul_dom [] (fmul_lemma code_Fmul IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul2_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul2_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul2_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul2_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul2_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul2_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul2_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul2_lemma' has the required type *)
noextract
let fmul2_lemma = as_t #(VSig.vale_sig_stdcall fmul2_pre fmul2_post) fmul2_lemma'
noextract
let code_Fmul2 = FW.va_code_Fmul2_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract
let lowstar_fmul2_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul2
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul2 fmul_dom [] (fmul2_lemma code_Fmul2 IA.win))
[@__reduce__] noextract
let fmul1_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul1_pre : VSig.vale_pre fmul1_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state) ->
FH.va_req_Fmul1_stdcall c va_s0 IA.win
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__] noextract
let fmul1_post : VSig.vale_post fmul1_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FH.va_ens_Fmul1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#set-options "--z3rlimit 50"
[@__reduce__] noextract
let fmul1_lemma'
(code:V.va_code)
(_win:bool)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul1_pre code out f1 f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul1_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FH.va_lemma_Fmul1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
let s0 = va_s0 in
let s1 = va_s1 in
let regs_modified = IX64.regs_modified_stdcall in
let xmms_modified = IX64.xmms_modified_stdcall in
let open MS in
let open Vale.AsLowStar.ValeSig in
assert (forall (r:MS.reg_64).{:pattern vale_save_reg r s0 s1} not (regs_modified r) ==> vale_save_reg r s0 s1);
assert (forall (x:MS.reg_xmm).{:pattern vale_save_xmm x s0 s1} not (xmms_modified x) ==> vale_save_xmm x s0 s1);
(va_s1, f)
(* Prove that fmul1_lemma' has the required type *) | false | true | Vale.Stdcalls.X64.Fmul.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fmul1_lemma : Vale.AsLowStar.ValeSig.vale_sig_stdcall Vale.Stdcalls.X64.Fmul.fmul1_pre
Vale.Stdcalls.X64.Fmul.fmul1_post | [] | Vale.Stdcalls.X64.Fmul.fmul1_lemma | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fmul.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.AsLowStar.ValeSig.vale_sig_stdcall Vale.Stdcalls.X64.Fmul.fmul1_pre
Vale.Stdcalls.X64.Fmul.fmul1_post | {
"end_col": 81,
"end_line": 278,
"start_col": 18,
"start_line": 278
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul_lemma = as_t #(VSig.vale_sig_stdcall fmul_pre fmul_post) fmul_lemma' | let fmul_lemma = | false | null | false | as_t #(VSig.vale_sig_stdcall fmul_pre fmul_post) fmul_lemma' | {
"checked_file": "Vale.Stdcalls.X64.Fmul.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fmul.fsti"
} | [
"total"
] | [
"Vale.Stdcalls.X64.Fmul.as_t",
"Vale.AsLowStar.ValeSig.vale_sig_stdcall",
"Vale.Stdcalls.X64.Fmul.fmul_dom",
"Vale.Stdcalls.X64.Fmul.fmul_pre",
"Vale.Stdcalls.X64.Fmul.fmul_post",
"Vale.Stdcalls.X64.Fmul.fmul_lemma'"
] | [] | module Vale.Stdcalls.X64.Fmul
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AsLowStar.MemoryHelpers
module FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let fmul_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_mod; t64_no_mod] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul_lemma' has the required type *) | false | true | Vale.Stdcalls.X64.Fmul.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fmul_lemma : Vale.AsLowStar.ValeSig.vale_sig_stdcall Vale.Stdcalls.X64.Fmul.fmul_pre
Vale.Stdcalls.X64.Fmul.fmul_post | [] | Vale.Stdcalls.X64.Fmul.fmul_lemma | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fmul.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.AsLowStar.ValeSig.vale_sig_stdcall Vale.Stdcalls.X64.Fmul.fmul_pre
Vale.Stdcalls.X64.Fmul.fmul_post | {
"end_col": 77,
"end_line": 116,
"start_col": 17,
"start_line": 116
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul2_lemma = as_t #(VSig.vale_sig_stdcall fmul2_pre fmul2_post) fmul2_lemma' | let fmul2_lemma = | false | null | false | as_t #(VSig.vale_sig_stdcall fmul2_pre fmul2_post) fmul2_lemma' | {
"checked_file": "Vale.Stdcalls.X64.Fmul.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fmul.fsti"
} | [
"total"
] | [
"Vale.Stdcalls.X64.Fmul.as_t",
"Vale.AsLowStar.ValeSig.vale_sig_stdcall",
"Vale.Stdcalls.X64.Fmul.fmul_dom",
"Vale.Stdcalls.X64.Fmul.fmul2_pre",
"Vale.Stdcalls.X64.Fmul.fmul2_post",
"Vale.Stdcalls.X64.Fmul.fmul2_lemma'"
] | [] | module Vale.Stdcalls.X64.Fmul
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AsLowStar.MemoryHelpers
module FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let fmul_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_mod; t64_no_mod] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul_lemma' has the required type *)
noextract
let fmul_lemma = as_t #(VSig.vale_sig_stdcall fmul_pre fmul_post) fmul_lemma'
noextract
let code_Fmul = FW.va_code_Fmul_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract
let lowstar_fmul_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul fmul_dom [] (fmul_lemma code_Fmul IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul2_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul2_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul2_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul2_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul2_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul2_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul2_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul2_lemma' has the required type *) | false | true | Vale.Stdcalls.X64.Fmul.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fmul2_lemma : Vale.AsLowStar.ValeSig.vale_sig_stdcall Vale.Stdcalls.X64.Fmul.fmul2_pre
Vale.Stdcalls.X64.Fmul.fmul2_post | [] | Vale.Stdcalls.X64.Fmul.fmul2_lemma | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fmul.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.AsLowStar.ValeSig.vale_sig_stdcall Vale.Stdcalls.X64.Fmul.fmul2_pre
Vale.Stdcalls.X64.Fmul.fmul2_post | {
"end_col": 81,
"end_line": 195,
"start_col": 18,
"start_line": 195
} |
|
Prims.Ghost | val fmul_lemma' (code: V.va_code) (_win: bool) (tmp f1 out f2: b64) (va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires fmul_pre code tmp f1 out f2 va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\ ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp)) ME.loc_none))
(VS.vs_get_vale_heap va_s0)
(VS.vs_get_vale_heap va_s1))) | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f) | val fmul_lemma' (code: V.va_code) (_win: bool) (tmp f1 out f2: b64) (va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires fmul_pre code tmp f1 out f2 va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\ ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp)) ME.loc_none))
(VS.vs_get_vale_heap va_s0)
(VS.vs_get_vale_heap va_s1)))
let fmul_lemma' (code: V.va_code) (_win: bool) (tmp f1 out f2: b64) (va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires fmul_pre code tmp f1 out f2 va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\ ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp)) ME.loc_none))
(VS.vs_get_vale_heap va_s0)
(VS.vs_get_vale_heap va_s1))) = | false | null | false | let va_s1, f =
FW.va_lemma_Fmul_stdcall code
va_s0
IA.win
(as_vale_buffer tmp)
(as_vale_buffer f1)
(as_vale_buffer out)
(as_vale_buffer f2)
in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f) | {
"checked_file": "Vale.Stdcalls.X64.Fmul.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fmul.fsti"
} | [] | [
"Vale.X64.Decls.va_code",
"Prims.bool",
"Vale.Stdcalls.X64.Fmul.b64",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal",
"Vale.Arch.HeapTypes_s.TUInt64",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.Curve25519.X64.FastWide.va_lemma_Fmul_stdcall",
"Vale.Interop.Assumptions.win",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Stdcalls.X64.Fmul.fmul_pre",
"Prims.l_and",
"Vale.X64.Decls.eval_code",
"Vale.AsLowStar.ValeSig.vale_calling_conventions_stdcall",
"Vale.Stdcalls.X64.Fmul.fmul_post",
"Vale.X64.Memory.buffer_readable",
"Vale.X64.State.vs_get_vale_heap",
"Vale.X64.Memory.buffer_writeable",
"Vale.X64.Memory.modifies",
"Vale.X64.Memory.loc_union",
"Vale.X64.Memory.loc_buffer",
"Vale.X64.Memory.loc_none"
] | [] | module Vale.Stdcalls.X64.Fmul
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AsLowStar.MemoryHelpers
module FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let fmul_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_mod; t64_no_mod] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp)) | false | false | Vale.Stdcalls.X64.Fmul.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fmul_lemma' (code: V.va_code) (_win: bool) (tmp f1 out f2: b64) (va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires fmul_pre code tmp f1 out f2 va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\ ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp)) ME.loc_none))
(VS.vs_get_vale_heap va_s0)
(VS.vs_get_vale_heap va_s1))) | [] | Vale.Stdcalls.X64.Fmul.fmul_lemma' | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fmul.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
code: Vale.X64.Decls.va_code ->
_win: Prims.bool ->
tmp: Vale.Stdcalls.X64.Fmul.b64 ->
f1: Vale.Stdcalls.X64.Fmul.b64 ->
out: Vale.Stdcalls.X64.Fmul.b64 ->
f2: Vale.Stdcalls.X64.Fmul.b64 ->
va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 13,
"end_line": 112,
"start_col": 5,
"start_line": 106
} |
Prims.Ghost | val fmul2_lemma' (code: V.va_code) (_win: bool) (tmp f1 out f2: b64) (va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires fmul2_pre code tmp f1 out f2 va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul2_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\ ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp)) ME.loc_none))
(VS.vs_get_vale_heap va_s0)
(VS.vs_get_vale_heap va_s1))) | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul2_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul2_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul2_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul2_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f) | val fmul2_lemma' (code: V.va_code) (_win: bool) (tmp f1 out f2: b64) (va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires fmul2_pre code tmp f1 out f2 va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul2_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\ ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp)) ME.loc_none))
(VS.vs_get_vale_heap va_s0)
(VS.vs_get_vale_heap va_s1)))
let fmul2_lemma' (code: V.va_code) (_win: bool) (tmp f1 out f2: b64) (va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires fmul2_pre code tmp f1 out f2 va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul2_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\ ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp)) ME.loc_none))
(VS.vs_get_vale_heap va_s0)
(VS.vs_get_vale_heap va_s1))) = | false | null | false | let va_s1, f =
FW.va_lemma_Fmul2_stdcall code
va_s0
IA.win
(as_vale_buffer tmp)
(as_vale_buffer f1)
(as_vale_buffer out)
(as_vale_buffer f2)
in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f) | {
"checked_file": "Vale.Stdcalls.X64.Fmul.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fmul.fsti"
} | [] | [
"Vale.X64.Decls.va_code",
"Prims.bool",
"Vale.Stdcalls.X64.Fmul.b64",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal",
"Vale.Arch.HeapTypes_s.TUInt64",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.Curve25519.X64.FastWide.va_lemma_Fmul2_stdcall",
"Vale.Interop.Assumptions.win",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Stdcalls.X64.Fmul.fmul2_pre",
"Prims.l_and",
"Vale.X64.Decls.eval_code",
"Vale.AsLowStar.ValeSig.vale_calling_conventions_stdcall",
"Vale.Stdcalls.X64.Fmul.fmul2_post",
"Vale.X64.Memory.buffer_readable",
"Vale.X64.State.vs_get_vale_heap",
"Vale.X64.Memory.buffer_writeable",
"Vale.X64.Memory.modifies",
"Vale.X64.Memory.loc_union",
"Vale.X64.Memory.loc_buffer",
"Vale.X64.Memory.loc_none"
] | [] | module Vale.Stdcalls.X64.Fmul
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AsLowStar.MemoryHelpers
module FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let fmul_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_mod; t64_no_mod] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul_lemma' has the required type *)
noextract
let fmul_lemma = as_t #(VSig.vale_sig_stdcall fmul_pre fmul_post) fmul_lemma'
noextract
let code_Fmul = FW.va_code_Fmul_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract
let lowstar_fmul_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul fmul_dom [] (fmul_lemma code_Fmul IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul2_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul2_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul2_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul2_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul2_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul2_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp)) | false | false | Vale.Stdcalls.X64.Fmul.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fmul2_lemma' (code: V.va_code) (_win: bool) (tmp f1 out f2: b64) (va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires fmul2_pre code tmp f1 out f2 va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul2_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\ ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp)) ME.loc_none))
(VS.vs_get_vale_heap va_s0)
(VS.vs_get_vale_heap va_s1))) | [] | Vale.Stdcalls.X64.Fmul.fmul2_lemma' | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fmul.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
code: Vale.X64.Decls.va_code ->
_win: Prims.bool ->
tmp: Vale.Stdcalls.X64.Fmul.b64 ->
f1: Vale.Stdcalls.X64.Fmul.b64 ->
out: Vale.Stdcalls.X64.Fmul.b64 ->
f2: Vale.Stdcalls.X64.Fmul.b64 ->
va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 13,
"end_line": 191,
"start_col": 5,
"start_line": 185
} |
Prims.Ghost | val fmul1_lemma' (code: V.va_code) (_win: bool) (out f1: b64) (f2: uint64) (va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires fmul1_pre code out f1 f2 va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul1_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none)
(VS.vs_get_vale_heap va_s0)
(VS.vs_get_vale_heap va_s1))) | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul1_lemma'
(code:V.va_code)
(_win:bool)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul1_pre code out f1 f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul1_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FH.va_lemma_Fmul1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
let s0 = va_s0 in
let s1 = va_s1 in
let regs_modified = IX64.regs_modified_stdcall in
let xmms_modified = IX64.xmms_modified_stdcall in
let open MS in
let open Vale.AsLowStar.ValeSig in
assert (forall (r:MS.reg_64).{:pattern vale_save_reg r s0 s1} not (regs_modified r) ==> vale_save_reg r s0 s1);
assert (forall (x:MS.reg_xmm).{:pattern vale_save_xmm x s0 s1} not (xmms_modified x) ==> vale_save_xmm x s0 s1);
(va_s1, f) | val fmul1_lemma' (code: V.va_code) (_win: bool) (out f1: b64) (f2: uint64) (va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires fmul1_pre code out f1 f2 va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul1_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none)
(VS.vs_get_vale_heap va_s0)
(VS.vs_get_vale_heap va_s1)))
let fmul1_lemma' (code: V.va_code) (_win: bool) (out f1: b64) (f2: uint64) (va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires fmul1_pre code out f1 f2 va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul1_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none)
(VS.vs_get_vale_heap va_s0)
(VS.vs_get_vale_heap va_s1))) = | false | null | false | let va_s1, f =
FH.va_lemma_Fmul1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
let s0 = va_s0 in
let s1 = va_s1 in
let regs_modified = IX64.regs_modified_stdcall in
let xmms_modified = IX64.xmms_modified_stdcall in
let open MS in
let open Vale.AsLowStar.ValeSig in
assert (forall (r: MS.reg_64). {:pattern vale_save_reg r s0 s1}
not (regs_modified r) ==> vale_save_reg r s0 s1);
assert (forall (x: MS.reg_xmm). {:pattern vale_save_xmm x s0 s1}
not (xmms_modified x) ==> vale_save_xmm x s0 s1);
(va_s1, f) | {
"checked_file": "Vale.Stdcalls.X64.Fmul.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fmul.fsti"
} | [] | [
"Vale.X64.Decls.va_code",
"Prims.bool",
"Vale.Stdcalls.X64.Fmul.b64",
"Vale.Stdcalls.X64.Fmul.uint64",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"Prims._assert",
"Prims.l_Forall",
"Vale.X64.Machine_s.reg_xmm",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_Negation",
"Vale.AsLowStar.ValeSig.vale_save_xmm",
"Vale.X64.Machine_s.reg_64",
"Vale.AsLowStar.ValeSig.vale_save_reg",
"Vale.Interop.X64.xmms_modified_stdcall",
"Vale.Interop.X64.regs_modified_stdcall",
"Vale.X64.State.vale_state",
"Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal",
"Vale.Arch.HeapTypes_s.TUInt64",
"FStar.Pervasives.Native.tuple2",
"Vale.Curve25519.X64.FastHybrid.va_lemma_Fmul1_stdcall",
"Vale.Interop.Assumptions.win",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"FStar.UInt64.v",
"Vale.Stdcalls.X64.Fmul.fmul1_pre",
"Prims.l_and",
"Vale.X64.Decls.eval_code",
"Vale.AsLowStar.ValeSig.vale_calling_conventions_stdcall",
"Vale.Stdcalls.X64.Fmul.fmul1_post",
"Vale.X64.Memory.buffer_readable",
"Vale.X64.State.vs_get_vale_heap",
"Vale.X64.Memory.buffer_writeable",
"Vale.X64.Memory.modifies",
"Vale.X64.Memory.loc_union",
"Vale.X64.Memory.loc_buffer",
"Vale.X64.Memory.loc_none"
] | [] | module Vale.Stdcalls.X64.Fmul
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AsLowStar.MemoryHelpers
module FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let fmul_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_mod; t64_no_mod] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul_lemma' has the required type *)
noextract
let fmul_lemma = as_t #(VSig.vale_sig_stdcall fmul_pre fmul_post) fmul_lemma'
noextract
let code_Fmul = FW.va_code_Fmul_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract
let lowstar_fmul_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul fmul_dom [] (fmul_lemma code_Fmul IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul2_pre : VSig.vale_pre fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state) ->
FW.va_req_Fmul2_stdcall c va_s0 IA.win
(as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2)
[@__reduce__] noextract
let fmul2_post : VSig.vale_post fmul_dom =
fun (c:V.va_code)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FW.va_ens_Fmul2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
[@__reduce__] noextract
let fmul2_lemma'
(code:V.va_code)
(_win:bool)
(tmp:b64)
(f1:b64)
(out:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul2_pre code tmp f1 out f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul2_post code tmp f1 out f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer tmp) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
(ME.loc_union (ME.loc_buffer (as_vale_buffer tmp))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FW.va_lemma_Fmul2_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp;
(va_s1, f)
(* Prove that fmul2_lemma' has the required type *)
noextract
let fmul2_lemma = as_t #(VSig.vale_sig_stdcall fmul2_pre fmul2_post) fmul2_lemma'
noextract
let code_Fmul2 = FW.va_code_Fmul2_stdcall IA.win
(* Here's the type expected for the fmul wrapper *)
[@__reduce__] noextract
let lowstar_fmul2_t =
assert_norm (List.length fmul_dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_Fmul2
fmul_dom
[]
_
_
(W.mk_prediction code_Fmul2 fmul_dom [] (fmul2_lemma code_Fmul2 IA.win))
[@__reduce__] noextract
let fmul1_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fmul1_pre : VSig.vale_pre fmul1_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state) ->
FH.va_req_Fmul1_stdcall c va_s0 IA.win
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__] noextract
let fmul1_post : VSig.vale_post fmul1_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FH.va_ens_Fmul1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#set-options "--z3rlimit 50"
[@__reduce__] noextract
let fmul1_lemma'
(code:V.va_code)
(_win:bool)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fmul1_pre code out f1 f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul1_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) | false | false | Vale.Stdcalls.X64.Fmul.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fmul1_lemma' (code: V.va_code) (_win: bool) (out f1: b64) (f2: uint64) (va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires fmul1_pre code out f1 f2 va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
fmul1_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none)
(VS.vs_get_vale_heap va_s0)
(VS.vs_get_vale_heap va_s1))) | [] | Vale.Stdcalls.X64.Fmul.fmul1_lemma' | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fmul.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
code: Vale.X64.Decls.va_code ->
_win: Prims.bool ->
out: Vale.Stdcalls.X64.Fmul.b64 ->
f1: Vale.Stdcalls.X64.Fmul.b64 ->
f2: Vale.Stdcalls.X64.Fmul.uint64 ->
va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 13,
"end_line": 274,
"start_col": 5,
"start_line": 262
} |
FStar.Pervasives.Lemma | val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)] | [
{
"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
}
] | false | let lemma_label_bool r msg b = lemma_label_Type0 r msg b | val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
let lemma_label_bool r msg b = | false | null | true | lemma_label_Type0 r msg b | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
"lemma"
] | [
"FStar.Range.range",
"Prims.string",
"Prims.bool",
"Vale.PPC64LE.QuickCodes.lemma_label_Type0",
"Prims.b2t",
"Prims.unit"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= () | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)] | [] | Vale.PPC64LE.QuickCodes.lemma_label_bool | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | r: FStar.Range.range -> msg: Prims.string -> b: Prims.bool
-> FStar.Pervasives.Lemma (requires Vale.PPC64LE.QuickCodes.label r msg b)
(ensures b)
[SMTPat (Vale.PPC64LE.QuickCodes.label r msg b)] | {
"end_col": 56,
"end_line": 14,
"start_col": 31,
"start_line": 14
} |
Prims.Ghost | 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
) | [
{
"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
}
] | false | let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
if b then
(
let (sM, f0, g) = QProc?.proof qc1 s0 k in
update_state_mods_weaken qc1.mods mods sM s0;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s0 k in
update_state_mods_weaken qc2.mods mods sM s0;
(sM, f0, g)
) | 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
)
let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = | false | null | false | if b
then
(let sM, f0, g = QProc?.proof qc1 s0 k in
update_state_mods_weaken qc1.mods mods sM s0;
(sM, f0, g))
else
(let sM, f0, g = QProc?.proof qc2 s0 k in
update_state_mods_weaken qc2.mods mods sM s0;
(sM, f0, g)) | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Prims.bool",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.State.state",
"Vale.PPC64LE.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Prims.unit",
"Vale.PPC64LE.QuickCodes.update_state_mods_weaken",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__proof"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
()
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
=
update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0
let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
=
match mods with
| [] -> ()
| _::mods ->
if mods_contains mods' mods && mods_contains1 mods m0 then
update_state_mods_weaken1 mods mods' s' s m0
let update_state_mods_weaken (mods mods':mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s')
=
update_state_mods_from mods s' s;
let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') =
update_state_mods_weaken1 mods mods' s' s m0
in
FStar.Classical.forall_intro f1;
update_state_mods_to mods' s' s
let call_QPURE
(#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:state -> a -> Type0) (s0:state)
: Lemma
(requires
(forall (p:unit -> GTot Type0).{:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p)))
(ensures wp cs qcs mods k s0)
=
l ()
(*
let call_QBindPURE
(#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0))
(l:unit -> PURE b pre) (qcs:state -> b -> GTot (quickCodes a cs)) (mods:mods_t)
(k:state -> a -> Type0) (s0:state)
: Ghost b
(requires
(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)))
(ensures fun g -> (wp cs (qcs s0 g) mods k s0))
=
l ()
*)
let rec wp_sound #a cs qcs mods k s0 =
let qcs0 = qcs in
match qcs with
| QEmpty g ->
update_state_mods_refl mods s0;
let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g)
| QSeq _ _ qc qcs ->
let QProc _ _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Seq cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs qcs mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QBind _ _ qc qcs ->
let QProc c' _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Bind cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QGetState f ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QPURE r msg pre l qcs' ->
call_QPURE r msg pre l qcs' mods k s0;
wp_sound cs qcs' mods k s0
(*
| QBindPURE b r msg pre l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = call_QBindPURE r msg pre l qcs' mods k s0 in
let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
*)
| QLemma _ _ pre post l qcs' ->
l ();
wp_sound cs qcs' mods k s0
| QGhost b _ _ pre post l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = l () in
let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in
wp_sound cs qcs mods k s0
let qblock_proof #a #cs qcs mods s0 k =
wp_sound cs (qcs s0) mods k s0 | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val 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
) | [] | Vale.PPC64LE.QuickCodes.qInlineIf_proof | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Prims.bool ->
qc1: Vale.PPC64LE.QuickCode.quickCode a c1 ->
qc2: Vale.PPC64LE.QuickCode.quickCode a c2 ->
mods: Vale.PPC64LE.QuickCode.mods_t ->
s0: Vale.PPC64LE.Decls.va_state ->
k: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0)
-> Prims.Ghost ((Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) * a) | {
"end_col": 3,
"end_line": 248,
"start_col": 2,
"start_line": 237
} |
Prims.Ghost | val wp_sound_code_wrap
(#a: Type0)
(c: code)
(qc: quickCode a c)
(s0: state)
(k: (s0': state{s0 == s0'} -> state -> a -> Type0))
: Ghost (state & fuel & a)
(t_require s0 /\ wp_sound_code_pre qc s0 k)
(wp_sound_code_post qc s0 k) | [
{
"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
}
] | false | let wp_sound_code_wrap (#a:Type0) (c:code) (qc:quickCode a c) (s0:state) (k:(s0':state{s0 == s0'}) -> state -> a -> Type0) :
Ghost (state & fuel & a)
(t_require s0 /\ wp_sound_code_pre qc s0 k)
(wp_sound_code_post qc s0 k)
=
wp_sound_code c qc (k s0) s0 | val wp_sound_code_wrap
(#a: Type0)
(c: code)
(qc: quickCode a c)
(s0: state)
(k: (s0': state{s0 == s0'} -> state -> a -> Type0))
: Ghost (state & fuel & a)
(t_require s0 /\ wp_sound_code_pre qc s0 k)
(wp_sound_code_post qc s0 k)
let wp_sound_code_wrap
(#a: Type0)
(c: code)
(qc: quickCode a c)
(s0: state)
(k: (s0': state{s0 == s0'} -> state -> a -> Type0))
: Ghost (state & fuel & a)
(t_require s0 /\ wp_sound_code_pre qc s0 k)
(wp_sound_code_post qc s0 k) = | false | null | false | wp_sound_code c qc (k s0) s0 | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.State.state",
"Prims.eq2",
"Vale.PPC64LE.QuickCodes.wp_sound_code",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.QuickCodes.fuel",
"Prims.l_and",
"Vale.PPC64LE.QuickCode.t_require",
"Vale.PPC64LE.QuickCodes.wp_sound_code_pre",
"Vale.PPC64LE.QuickCodes.wp_sound_code_post"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
()
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
=
update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0
let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
=
match mods with
| [] -> ()
| _::mods ->
if mods_contains mods' mods && mods_contains1 mods m0 then
update_state_mods_weaken1 mods mods' s' s m0
let update_state_mods_weaken (mods mods':mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s')
=
update_state_mods_from mods s' s;
let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') =
update_state_mods_weaken1 mods mods' s' s m0
in
FStar.Classical.forall_intro f1;
update_state_mods_to mods' s' s
let call_QPURE
(#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:state -> a -> Type0) (s0:state)
: Lemma
(requires
(forall (p:unit -> GTot Type0).{:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p)))
(ensures wp cs qcs mods k s0)
=
l ()
(*
let call_QBindPURE
(#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0))
(l:unit -> PURE b pre) (qcs:state -> b -> GTot (quickCodes a cs)) (mods:mods_t)
(k:state -> a -> Type0) (s0:state)
: Ghost b
(requires
(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)))
(ensures fun g -> (wp cs (qcs s0 g) mods k s0))
=
l ()
*)
let rec wp_sound #a cs qcs mods k s0 =
let qcs0 = qcs in
match qcs with
| QEmpty g ->
update_state_mods_refl mods s0;
let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g)
| QSeq _ _ qc qcs ->
let QProc _ _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Seq cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs qcs mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QBind _ _ qc qcs ->
let QProc c' _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Bind cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QGetState f ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QPURE r msg pre l qcs' ->
call_QPURE r msg pre l qcs' mods k s0;
wp_sound cs qcs' mods k s0
(*
| QBindPURE b r msg pre l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = call_QBindPURE r msg pre l qcs' mods k s0 in
let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
*)
| QLemma _ _ pre post l qcs' ->
l ();
wp_sound cs qcs' mods k s0
| QGhost b _ _ pre post l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = l () in
let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in
wp_sound cs qcs mods k s0
let qblock_proof #a #cs qcs mods s0 k =
wp_sound cs (qcs s0) mods k s0
let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
if b then
(
let (sM, f0, g) = QProc?.proof qc1 s0 k in
update_state_mods_weaken qc1.mods mods sM s0;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s0 k in
update_state_mods_weaken qc2.mods mods sM s0;
(sM, f0, g)
)
let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
( match b with
| Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2
| Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2
| Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2
| Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2
| Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2
| Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2
);
let s1 = {s0 with cr0 = eval_cmp_cr0 s0 (cmp_to_ocmp b)} in
update_state_mods_to mods s1 s0;
if eval_cmp s0 b then
(
let (sM, f0, g) = QProc?.proof qc1 s1 k in
va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc1.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s1 k in
va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc2.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
)
let rec qWhile_proof_rec
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:state -> a -> Type0)
(dec:state -> a -> d) (s0 s1:state) (g1:a) (f1:fuel) (k:state -> a -> Type0)
: Ghost (state & va_fuel & a)
(requires
state_inv s1 /\
wp_While b qc mods inv dec g1 s1 k /\
eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\
update_state_mods mods s1 s0 == s1)
(ensures fun (s2, f2, g2) ->
eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\
update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2
)
(decreases (dec s1 g1))
=
let ob = cmp_to_ocmp b in
let s1' = {s1 with cr0 = eval_cmp_cr0 s1 (cmp_to_ocmp b)} in
update_state_mods_to mods s1' s1;
update_state_mods_trans mods s0 s1 s1';
if eval_cmp s1 b then
(
let inv2 = wp_While_inv qc mods inv dec s1 g1 in
let wp = QProc?.wp (qc g1) in
let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in
let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in
let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in
update_state_mods_weaken (qc g1).mods mods sc s2;
update_state_mods_trans mods s0 s2 sc;
qWhile_proof_rec b qc mods inv dec s0 sc gc fN k
)
else
(
let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in
(s2, f2, g1)
)
let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k =
let ob = cmp_to_ocmp b in
let (s1, f1) = va_lemma_while_total ob c s0 in
update_state_mods_refl mods s0;
qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k
let qAssertLemma p = fun () -> ()
let qAssumeLemma p = fun () -> assume p
let qAssertSquashLemma p = fun () -> ()
//let qAssertByLemma #a p qcs mods s0 =
// fun () -> let _ = wp_sound [] qcs mods (fun _ _ -> p) s0 in ()
let wp_sound_code #a c qc k s0 =
let QProc c _ wp proof = qc in
proof s0 k
let lemma_state_match s0 s1 =
()
let wp_sound_code_wrap (#a:Type0) (c:code) (qc:quickCode a c) (s0:state) (k:(s0':state{s0 == s0'}) -> state -> a -> Type0) :
Ghost (state & fuel & a)
(t_require s0 /\ wp_sound_code_pre qc s0 k)
(wp_sound_code_post qc s0 k) | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val wp_sound_code_wrap
(#a: Type0)
(c: code)
(qc: quickCode a c)
(s0: state)
(k: (s0': state{s0 == s0'} -> state -> a -> Type0))
: Ghost (state & fuel & a)
(t_require s0 /\ wp_sound_code_pre qc s0 k)
(wp_sound_code_post qc s0 k) | [] | Vale.PPC64LE.QuickCodes.wp_sound_code_wrap | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
c: Vale.PPC64LE.QuickCodes.code ->
qc: Vale.PPC64LE.QuickCode.quickCode a c ->
s0: Vale.PPC64LE.State.state ->
k: (s0': Vale.PPC64LE.State.state{s0 == s0'} -> _: Vale.PPC64LE.State.state -> _: a -> Type0)
-> Prims.Ghost ((Vale.PPC64LE.State.state * Vale.PPC64LE.QuickCodes.fuel) * a) | {
"end_col": 30,
"end_line": 339,
"start_col": 2,
"start_line": 339
} |
Prims.Ghost | 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
) | [
{
"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
}
] | false | let qblock_proof #a #cs qcs mods s0 k =
wp_sound 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
)
let qblock_proof #a #cs qcs mods s0 k = | false | null | false | wp_sound cs (qcs s0) mods k s0 | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [] | [
"Vale.PPC64LE.QuickCodes.codes",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.QuickCodes.wp_sound",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.Decls.va_fuel"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
()
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
=
update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0
let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
=
match mods with
| [] -> ()
| _::mods ->
if mods_contains mods' mods && mods_contains1 mods m0 then
update_state_mods_weaken1 mods mods' s' s m0
let update_state_mods_weaken (mods mods':mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s')
=
update_state_mods_from mods s' s;
let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') =
update_state_mods_weaken1 mods mods' s' s m0
in
FStar.Classical.forall_intro f1;
update_state_mods_to mods' s' s
let call_QPURE
(#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:state -> a -> Type0) (s0:state)
: Lemma
(requires
(forall (p:unit -> GTot Type0).{:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p)))
(ensures wp cs qcs mods k s0)
=
l ()
(*
let call_QBindPURE
(#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0))
(l:unit -> PURE b pre) (qcs:state -> b -> GTot (quickCodes a cs)) (mods:mods_t)
(k:state -> a -> Type0) (s0:state)
: Ghost b
(requires
(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)))
(ensures fun g -> (wp cs (qcs s0 g) mods k s0))
=
l ()
*)
let rec wp_sound #a cs qcs mods k s0 =
let qcs0 = qcs in
match qcs with
| QEmpty g ->
update_state_mods_refl mods s0;
let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g)
| QSeq _ _ qc qcs ->
let QProc _ _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Seq cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs qcs mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QBind _ _ qc qcs ->
let QProc c' _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Bind cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QGetState f ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QPURE r msg pre l qcs' ->
call_QPURE r msg pre l qcs' mods k s0;
wp_sound cs qcs' mods k s0
(*
| QBindPURE b r msg pre l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = call_QBindPURE r msg pre l qcs' mods k s0 in
let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
*)
| QLemma _ _ pre post l qcs' ->
l ();
wp_sound cs qcs' mods k s0
| QGhost b _ _ pre post l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = l () in
let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in
wp_sound cs qcs mods k s0 | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val 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
) | [] | Vale.PPC64LE.QuickCodes.qblock_proof | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
qcs: (_: Vale.PPC64LE.Decls.va_state -> Prims.GTot (Vale.PPC64LE.QuickCodes.quickCodes a cs)) ->
mods: Vale.PPC64LE.QuickCode.mods_t ->
s0: Vale.PPC64LE.Decls.va_state ->
k: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0)
-> Prims.Ghost ((Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) * a) | {
"end_col": 32,
"end_line": 234,
"start_col": 2,
"start_line": 234
} |
FStar.Pervasives.Lemma | val update_state_mods_weaken1 (mods mods': mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) | [
{
"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
}
] | false | let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
=
match mods with
| [] -> ()
| _::mods ->
if mods_contains mods' mods && mods_contains1 mods m0 then
update_state_mods_weaken1 mods mods' s' s m0 | val update_state_mods_weaken1 (mods mods': mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
let rec update_state_mods_weaken1 (mods mods': mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = | false | null | true | match mods with
| [] -> ()
| _ :: mods ->
if mods_contains mods' mods && mods_contains1 mods m0
then update_state_mods_weaken1 mods mods' s' s m0 | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.State.state",
"Vale.PPC64LE.QuickCode.mod_t",
"Prims.list",
"Prims.op_AmpAmp",
"Vale.PPC64LE.QuickCodes.mods_contains",
"Vale.PPC64LE.QuickCodes.mods_contains1",
"Vale.PPC64LE.QuickCodes.update_state_mods_weaken1",
"Prims.bool",
"Prims.unit",
"Prims.l_and",
"Prims.l_or",
"Prims.b2t",
"Vale.PPC64LE.QuickCodes.state_mod_eq",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
()
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
=
update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0
let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_state_mods_weaken1 (mods mods': mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) | [
"recursion"
] | Vale.PPC64LE.QuickCodes.update_state_mods_weaken1 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mods: Vale.PPC64LE.QuickCode.mods_t ->
mods': Vale.PPC64LE.QuickCode.mods_t ->
s': Vale.PPC64LE.State.state ->
s: Vale.PPC64LE.State.state ->
m0: Vale.PPC64LE.QuickCode.mod_t
-> FStar.Pervasives.Lemma
(requires
(Vale.PPC64LE.QuickCodes.mods_contains1 mods m0 \/
Vale.PPC64LE.QuickCodes.state_mod_eq m0 s s') /\
Vale.PPC64LE.QuickCodes.mods_contains mods' mods)
(ensures
Vale.PPC64LE.QuickCodes.mods_contains1 mods' m0 \/
Vale.PPC64LE.QuickCodes.state_mod_eq m0 s s') | {
"end_col": 52,
"end_line": 135,
"start_col": 2,
"start_line": 131
} |
Prims.Ghost | 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
) | [
{
"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
}
] | false | let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k =
let ob = cmp_to_ocmp b in
let (s1, f1) = va_lemma_while_total ob c s0 in
update_state_mods_refl mods s0;
qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 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
)
let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = | false | null | false | let ob = cmp_to_ocmp b in
let s1, f1 = va_lemma_while_total ob c s0 in
update_state_mods_refl mods s0;
qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCodes.cmp",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.Decls.va_fuel",
"Vale.PPC64LE.QuickCodes.qWhile_proof_rec",
"Prims.unit",
"Vale.PPC64LE.QuickCodes.update_state_mods_refl",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Decls.va_lemma_while_total",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.QuickCodes.cmp_to_ocmp"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
()
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
=
update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0
let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
=
match mods with
| [] -> ()
| _::mods ->
if mods_contains mods' mods && mods_contains1 mods m0 then
update_state_mods_weaken1 mods mods' s' s m0
let update_state_mods_weaken (mods mods':mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s')
=
update_state_mods_from mods s' s;
let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') =
update_state_mods_weaken1 mods mods' s' s m0
in
FStar.Classical.forall_intro f1;
update_state_mods_to mods' s' s
let call_QPURE
(#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:state -> a -> Type0) (s0:state)
: Lemma
(requires
(forall (p:unit -> GTot Type0).{:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p)))
(ensures wp cs qcs mods k s0)
=
l ()
(*
let call_QBindPURE
(#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0))
(l:unit -> PURE b pre) (qcs:state -> b -> GTot (quickCodes a cs)) (mods:mods_t)
(k:state -> a -> Type0) (s0:state)
: Ghost b
(requires
(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)))
(ensures fun g -> (wp cs (qcs s0 g) mods k s0))
=
l ()
*)
let rec wp_sound #a cs qcs mods k s0 =
let qcs0 = qcs in
match qcs with
| QEmpty g ->
update_state_mods_refl mods s0;
let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g)
| QSeq _ _ qc qcs ->
let QProc _ _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Seq cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs qcs mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QBind _ _ qc qcs ->
let QProc c' _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Bind cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QGetState f ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QPURE r msg pre l qcs' ->
call_QPURE r msg pre l qcs' mods k s0;
wp_sound cs qcs' mods k s0
(*
| QBindPURE b r msg pre l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = call_QBindPURE r msg pre l qcs' mods k s0 in
let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
*)
| QLemma _ _ pre post l qcs' ->
l ();
wp_sound cs qcs' mods k s0
| QGhost b _ _ pre post l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = l () in
let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in
wp_sound cs qcs mods k s0
let qblock_proof #a #cs qcs mods s0 k =
wp_sound cs (qcs s0) mods k s0
let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
if b then
(
let (sM, f0, g) = QProc?.proof qc1 s0 k in
update_state_mods_weaken qc1.mods mods sM s0;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s0 k in
update_state_mods_weaken qc2.mods mods sM s0;
(sM, f0, g)
)
let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
( match b with
| Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2
| Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2
| Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2
| Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2
| Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2
| Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2
);
let s1 = {s0 with cr0 = eval_cmp_cr0 s0 (cmp_to_ocmp b)} in
update_state_mods_to mods s1 s0;
if eval_cmp s0 b then
(
let (sM, f0, g) = QProc?.proof qc1 s1 k in
va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc1.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s1 k in
va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc2.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
)
let rec qWhile_proof_rec
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:state -> a -> Type0)
(dec:state -> a -> d) (s0 s1:state) (g1:a) (f1:fuel) (k:state -> a -> Type0)
: Ghost (state & va_fuel & a)
(requires
state_inv s1 /\
wp_While b qc mods inv dec g1 s1 k /\
eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\
update_state_mods mods s1 s0 == s1)
(ensures fun (s2, f2, g2) ->
eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\
update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2
)
(decreases (dec s1 g1))
=
let ob = cmp_to_ocmp b in
let s1' = {s1 with cr0 = eval_cmp_cr0 s1 (cmp_to_ocmp b)} in
update_state_mods_to mods s1' s1;
update_state_mods_trans mods s0 s1 s1';
if eval_cmp s1 b then
(
let inv2 = wp_While_inv qc mods inv dec s1 g1 in
let wp = QProc?.wp (qc g1) in
let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in
let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in
let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in
update_state_mods_weaken (qc g1).mods mods sc s2;
update_state_mods_trans mods s0 s2 sc;
qWhile_proof_rec b qc mods inv dec s0 sc gc fN k
)
else
(
let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in
(s2, f2, g1)
) | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val 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
) | [] | Vale.PPC64LE.QuickCodes.qWhile_proof | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.PPC64LE.QuickCodes.cmp ->
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) ->
g0: a ->
s0: Vale.PPC64LE.Decls.va_state ->
k: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0)
-> Prims.Ghost ((Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) * a) | {
"end_col": 50,
"end_line": 318,
"start_col": 53,
"start_line": 314
} |
FStar.Pervasives.Lemma | val update_state_mods_weaken (mods mods': mods_t) (s' s: state)
: Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s') | [
{
"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
}
] | false | let update_state_mods_weaken (mods mods':mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s')
=
update_state_mods_from mods s' s;
let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') =
update_state_mods_weaken1 mods mods' s' s m0
in
FStar.Classical.forall_intro f1;
update_state_mods_to mods' s' s | val update_state_mods_weaken (mods mods': mods_t) (s' s: state)
: Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s')
let update_state_mods_weaken (mods mods': mods_t) (s' s: state)
: Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s') = | false | null | true | update_state_mods_from mods s' s;
let f1 (m0: mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') =
update_state_mods_weaken1 mods mods' s' s m0
in
FStar.Classical.forall_intro f1;
update_state_mods_to mods' s' s | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.State.state",
"Vale.PPC64LE.QuickCodes.update_state_mods_to",
"Prims.unit",
"FStar.Classical.forall_intro",
"Vale.PPC64LE.QuickCode.mod_t",
"Prims.l_or",
"Prims.b2t",
"Vale.PPC64LE.QuickCodes.mods_contains1",
"Vale.PPC64LE.QuickCodes.state_mod_eq",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.PPC64LE.QuickCodes.update_state_mods_weaken1",
"Vale.PPC64LE.QuickCodes.update_state_mods_from",
"Prims.l_and",
"Prims.eq2",
"Vale.PPC64LE.QuickCode.update_state_mods",
"Vale.PPC64LE.QuickCodes.mods_contains"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
()
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
=
update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0
let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
=
match mods with
| [] -> ()
| _::mods ->
if mods_contains mods' mods && mods_contains1 mods m0 then
update_state_mods_weaken1 mods mods' s' s m0
let update_state_mods_weaken (mods mods':mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s') | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_state_mods_weaken (mods mods': mods_t) (s' s: state)
: Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s') | [] | Vale.PPC64LE.QuickCodes.update_state_mods_weaken | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mods: Vale.PPC64LE.QuickCode.mods_t ->
mods': Vale.PPC64LE.QuickCode.mods_t ->
s': Vale.PPC64LE.State.state ->
s: Vale.PPC64LE.State.state
-> FStar.Pervasives.Lemma
(requires
Vale.PPC64LE.QuickCode.update_state_mods mods s' s == s' /\
Vale.PPC64LE.QuickCodes.mods_contains mods' mods)
(ensures Vale.PPC64LE.QuickCode.update_state_mods mods' s' s == s') | {
"end_col": 33,
"end_line": 146,
"start_col": 2,
"start_line": 141
} |
FStar.Pervasives.Lemma | val update_state_mods_from1 (mods: mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') | [
{
"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
}
] | false | let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 | val update_state_mods_from1 (mods: mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
let update_state_mods_from1 (mods: mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = | false | null | true | if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.State.state",
"Vale.PPC64LE.QuickCode.mod_t",
"Prims.op_Negation",
"Vale.PPC64LE.QuickCodes.mods_contains1",
"Vale.PPC64LE.QuickCodes.update_state_mods_not1",
"Prims.bool",
"Prims.unit",
"Vale.PPC64LE.QuickCodes.state_mod_eq",
"Vale.PPC64LE.QuickCode.update_state_mods",
"Prims.squash",
"Prims.l_or",
"Prims.b2t",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_state_mods_from1 (mods: mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') | [] | Vale.PPC64LE.QuickCodes.update_state_mods_from1 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mods: Vale.PPC64LE.QuickCode.mods_t ->
s': Vale.PPC64LE.State.state ->
s: Vale.PPC64LE.State.state ->
m0: Vale.PPC64LE.QuickCode.mod_t
-> FStar.Pervasives.Lemma
(requires
Vale.PPC64LE.QuickCodes.state_mod_eq m0
s'
(Vale.PPC64LE.QuickCode.update_state_mods mods s' s))
(ensures
Vale.PPC64LE.QuickCodes.mods_contains1 mods m0 \/
Vale.PPC64LE.QuickCodes.state_mod_eq m0 s s') | {
"end_col": 74,
"end_line": 54,
"start_col": 2,
"start_line": 54
} |
FStar.Pervasives.Lemma | val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x) | [
{
"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
}
] | false | let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t | val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
let rec empty_list_is_small #a x = | false | null | true | match x with
| [] -> ()
| h :: t -> empty_list_is_small t | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
"lemma"
] | [
"Prims.list",
"Vale.PPC64LE.QuickCodes.empty_list_is_small",
"Prims.unit"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x) | [
"recursion"
] | Vale.PPC64LE.QuickCodes.empty_list_is_small | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Prims.list a -> FStar.Pervasives.Lemma (ensures [] == x \/ [] << x) | {
"end_col": 33,
"end_line": 19,
"start_col": 2,
"start_line": 17
} |
Prims.Ghost | 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
) | [
{
"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
}
] | false | let rec wp_sound #a cs qcs mods k s0 =
let qcs0 = qcs in
match qcs with
| QEmpty g ->
update_state_mods_refl mods s0;
let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g)
| QSeq _ _ qc qcs ->
let QProc _ _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Seq cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs qcs mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QBind _ _ qc qcs ->
let QProc c' _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Bind cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QGetState f ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QPURE r msg pre l qcs' ->
call_QPURE r msg pre l qcs' mods k s0;
wp_sound cs qcs' mods k s0
(*
| QBindPURE b r msg pre l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = call_QBindPURE r msg pre l qcs' mods k s0 in
let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
*)
| QLemma _ _ pre post l qcs' ->
l ();
wp_sound cs qcs' mods k s0
| QGhost b _ _ pre post l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = l () in
let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in
wp_sound cs qcs mods k s0 | 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
)
let rec wp_sound #a cs qcs mods k s0 = | false | null | false | let qcs0 = qcs in
match qcs with
| QEmpty g ->
update_state_mods_refl mods s0;
let sN, fN = va_lemma_empty_total s0 [] in
(sN, fN, g)
| QSeq _ _ qc qcs ->
let QProc _ _ wp1' proof = qc in
let c :: cs = cs in
let k' = wp_Seq cs qcs mods k in
let sM, fM, gM = proof s0 k' in
let sN, fN, gN = wp_sound cs qcs mods k sM in
let fN' = va_lemma_merge_total (c :: cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QBind _ _ qc qcs ->
let QProc c' _ wp1' proof = qc in
let c :: cs = cs in
let k' = wp_Bind cs qcs mods k in
let sM, fM, gM = proof s0 k' in
let sN, fN, gN = wp_sound cs (qcs sM gM) mods k sM in
let fN' = va_lemma_merge_total (c :: cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QGetState f ->
let c :: cs = cs in
let sM, fM = va_lemma_empty_total s0 [] in
let sN, fN, gN = wp_sound cs (f sM) mods k sM in
let fN' = va_lemma_merge_total (c :: cs) s0 fM sM fN sN in
(sN, fN', gN)
| QPURE r msg pre l qcs' ->
call_QPURE r msg pre l qcs' mods k s0;
wp_sound cs qcs' mods k s0
| QLemma _ _ pre post l qcs' ->
l ();
wp_sound cs qcs' mods k s0
| QGhost b _ _ pre post l qcs' ->
let c :: cs = cs in
let sM, fM = va_lemma_empty_total s0 [] in
let g = l () in
let sN, fN, gN = wp_sound cs (qcs' g) mods k s0 in
let fN' = va_lemma_merge_total (c :: cs) s0 fM sM fN sN in
(sN, fN', gN)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in
wp_sound cs qcs mods k s0 | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [] | [
"Vale.PPC64LE.QuickCodes.codes",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Decls.va_lemma_empty_total",
"Prims.Nil",
"Vale.PPC64LE.Decls.va_code",
"Prims.unit",
"Vale.PPC64LE.QuickCodes.update_state_mods_refl",
"Vale.PPC64LE.QuickCodes.code",
"FStar.Range.range",
"Prims.string",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.QuickCode.quickProc_wp",
"Vale.PPC64LE.QuickCode.t_proof",
"Prims.list",
"Vale.PPC64LE.State.state",
"Vale.PPC64LE.QuickCodes.update_state_mods_trans",
"Vale.PPC64LE.QuickCodes.update_state_mods_weaken",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.PPC64LE.Decls.va_lemma_merge_total",
"Prims.Cons",
"Vale.PPC64LE.QuickCodes.wp_sound",
"Vale.PPC64LE.QuickCodes.wp_Seq_t",
"Vale.PPC64LE.QuickCodes.wp_Seq",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.QuickCodes.wp_Bind_t",
"Vale.PPC64LE.QuickCodes.wp_Bind",
"FStar.Monotonic.Pure.is_monotonic",
"FStar.Monotonic.Pure.as_pure_wp",
"Vale.PPC64LE.QuickCodes.call_QPURE",
"Prims.squash",
"FStar.Pervasives.pattern",
"Vale.PPC64LE.QuickCodes.k_AssertBy",
"Vale.PPC64LE.QuickCodes.empty_list_is_small"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
()
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
=
update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0
let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
=
match mods with
| [] -> ()
| _::mods ->
if mods_contains mods' mods && mods_contains1 mods m0 then
update_state_mods_weaken1 mods mods' s' s m0
let update_state_mods_weaken (mods mods':mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s')
=
update_state_mods_from mods s' s;
let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') =
update_state_mods_weaken1 mods mods' s' s m0
in
FStar.Classical.forall_intro f1;
update_state_mods_to mods' s' s
let call_QPURE
(#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:state -> a -> Type0) (s0:state)
: Lemma
(requires
(forall (p:unit -> GTot Type0).{:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p)))
(ensures wp cs qcs mods k s0)
=
l ()
(*
let call_QBindPURE
(#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0))
(l:unit -> PURE b pre) (qcs:state -> b -> GTot (quickCodes a cs)) (mods:mods_t)
(k:state -> a -> Type0) (s0:state)
: Ghost b
(requires
(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)))
(ensures fun g -> (wp cs (qcs s0 g) mods k s0))
=
l ()
*) | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val 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
) | [
"recursion"
] | Vale.PPC64LE.QuickCodes.wp_sound | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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.Ghost ((Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) * a) | {
"end_col": 31,
"end_line": 231,
"start_col": 38,
"start_line": 174
} |
FStar.Pervasives.Lemma | val update_state_mods_refl (mods: mods_t) (s: state)
: Lemma (ensures state_eq (update_state_mods mods s s) s) | [
{
"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
}
] | false | let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s | val update_state_mods_refl (mods: mods_t) (s: state)
: Lemma (ensures state_eq (update_state_mods mods s s) s)
let rec update_state_mods_refl (mods: mods_t) (s: state)
: Lemma (ensures state_eq (update_state_mods mods s s) s) = | false | null | true | match mods with
| [] -> ()
| _ :: mods -> update_state_mods_refl mods s | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.State.state",
"Vale.PPC64LE.QuickCode.mod_t",
"Prims.list",
"Vale.PPC64LE.QuickCodes.update_state_mods_refl",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Vale.PPC64LE.State.state_eq",
"Vale.PPC64LE.QuickCode.update_state_mods",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s) | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_state_mods_refl (mods: mods_t) (s: state)
: Lemma (ensures state_eq (update_state_mods mods s s) s) | [
"recursion"
] | Vale.PPC64LE.QuickCodes.update_state_mods_refl | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | mods: Vale.PPC64LE.QuickCode.mods_t -> s: Vale.PPC64LE.State.state
-> FStar.Pervasives.Lemma
(ensures Vale.PPC64LE.State.state_eq (Vale.PPC64LE.QuickCode.update_state_mods mods s s) s) | {
"end_col": 44,
"end_line": 40,
"start_col": 2,
"start_line": 38
} |
Prims.Tot | val qAssertSquashLemma (p:Type0) : tAssertSquashLemma p | [
{
"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
}
] | false | let qAssertSquashLemma p = fun () -> () | val qAssertSquashLemma (p:Type0) : tAssertSquashLemma p
let qAssertSquashLemma p = | false | null | false | fun () -> () | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
"total"
] | [
"Prims.unit",
"Prims.squash"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
()
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
=
update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0
let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
=
match mods with
| [] -> ()
| _::mods ->
if mods_contains mods' mods && mods_contains1 mods m0 then
update_state_mods_weaken1 mods mods' s' s m0
let update_state_mods_weaken (mods mods':mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s')
=
update_state_mods_from mods s' s;
let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') =
update_state_mods_weaken1 mods mods' s' s m0
in
FStar.Classical.forall_intro f1;
update_state_mods_to mods' s' s
let call_QPURE
(#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:state -> a -> Type0) (s0:state)
: Lemma
(requires
(forall (p:unit -> GTot Type0).{:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p)))
(ensures wp cs qcs mods k s0)
=
l ()
(*
let call_QBindPURE
(#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0))
(l:unit -> PURE b pre) (qcs:state -> b -> GTot (quickCodes a cs)) (mods:mods_t)
(k:state -> a -> Type0) (s0:state)
: Ghost b
(requires
(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)))
(ensures fun g -> (wp cs (qcs s0 g) mods k s0))
=
l ()
*)
let rec wp_sound #a cs qcs mods k s0 =
let qcs0 = qcs in
match qcs with
| QEmpty g ->
update_state_mods_refl mods s0;
let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g)
| QSeq _ _ qc qcs ->
let QProc _ _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Seq cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs qcs mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QBind _ _ qc qcs ->
let QProc c' _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Bind cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QGetState f ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QPURE r msg pre l qcs' ->
call_QPURE r msg pre l qcs' mods k s0;
wp_sound cs qcs' mods k s0
(*
| QBindPURE b r msg pre l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = call_QBindPURE r msg pre l qcs' mods k s0 in
let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
*)
| QLemma _ _ pre post l qcs' ->
l ();
wp_sound cs qcs' mods k s0
| QGhost b _ _ pre post l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = l () in
let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in
wp_sound cs qcs mods k s0
let qblock_proof #a #cs qcs mods s0 k =
wp_sound cs (qcs s0) mods k s0
let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
if b then
(
let (sM, f0, g) = QProc?.proof qc1 s0 k in
update_state_mods_weaken qc1.mods mods sM s0;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s0 k in
update_state_mods_weaken qc2.mods mods sM s0;
(sM, f0, g)
)
let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
( match b with
| Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2
| Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2
| Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2
| Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2
| Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2
| Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2
);
let s1 = {s0 with cr0 = eval_cmp_cr0 s0 (cmp_to_ocmp b)} in
update_state_mods_to mods s1 s0;
if eval_cmp s0 b then
(
let (sM, f0, g) = QProc?.proof qc1 s1 k in
va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc1.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s1 k in
va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc2.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
)
let rec qWhile_proof_rec
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:state -> a -> Type0)
(dec:state -> a -> d) (s0 s1:state) (g1:a) (f1:fuel) (k:state -> a -> Type0)
: Ghost (state & va_fuel & a)
(requires
state_inv s1 /\
wp_While b qc mods inv dec g1 s1 k /\
eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\
update_state_mods mods s1 s0 == s1)
(ensures fun (s2, f2, g2) ->
eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\
update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2
)
(decreases (dec s1 g1))
=
let ob = cmp_to_ocmp b in
let s1' = {s1 with cr0 = eval_cmp_cr0 s1 (cmp_to_ocmp b)} in
update_state_mods_to mods s1' s1;
update_state_mods_trans mods s0 s1 s1';
if eval_cmp s1 b then
(
let inv2 = wp_While_inv qc mods inv dec s1 g1 in
let wp = QProc?.wp (qc g1) in
let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in
let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in
let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in
update_state_mods_weaken (qc g1).mods mods sc s2;
update_state_mods_trans mods s0 s2 sc;
qWhile_proof_rec b qc mods inv dec s0 sc gc fN k
)
else
(
let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in
(s2, f2, g1)
)
let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k =
let ob = cmp_to_ocmp b in
let (s1, f1) = va_lemma_while_total ob c s0 in
update_state_mods_refl mods s0;
qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k
let qAssertLemma p = fun () -> () | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qAssertSquashLemma (p:Type0) : tAssertSquashLemma p | [] | Vale.PPC64LE.QuickCodes.qAssertSquashLemma | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Type0 -> Vale.PPC64LE.QuickCodes.tAssertSquashLemma p | {
"end_col": 39,
"end_line": 322,
"start_col": 27,
"start_line": 322
} |
FStar.Pervasives.Lemma | val update_state_mods_from (mods: mods_t) (s' s: state)
: Lemma (requires update_state_mods mods s' s == s')
(ensures
(forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s')) | [
{
"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
}
] | false | let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1 | val update_state_mods_from (mods: mods_t) (s' s: state)
: Lemma (requires update_state_mods mods s' s == s')
(ensures
(forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'))
let update_state_mods_from (mods: mods_t) (s' s: state)
: Lemma (requires update_state_mods mods s' s == s')
(ensures
(forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s')) = | false | null | true | let f1 (m0: mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1 | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.State.state",
"FStar.Classical.forall_intro",
"Vale.PPC64LE.QuickCode.mod_t",
"Prims.l_or",
"Prims.b2t",
"Vale.PPC64LE.QuickCodes.mods_contains1",
"Vale.PPC64LE.QuickCodes.state_mod_eq",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.PPC64LE.QuickCodes.update_state_mods_from1",
"Prims.eq2",
"Vale.PPC64LE.QuickCode.update_state_mods",
"Prims.l_Forall"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s' | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_state_mods_from (mods: mods_t) (s' s: state)
: Lemma (requires update_state_mods mods s' s == s')
(ensures
(forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s')) | [] | Vale.PPC64LE.QuickCodes.update_state_mods_from | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | mods: Vale.PPC64LE.QuickCode.mods_t -> s': Vale.PPC64LE.State.state -> s: Vale.PPC64LE.State.state
-> FStar.Pervasives.Lemma (requires Vale.PPC64LE.QuickCode.update_state_mods mods s' s == s')
(ensures
forall (m0: Vale.PPC64LE.QuickCode.mod_t).
{:pattern
Vale.PPC64LE.QuickCodes.mods_contains1 mods m0\/Vale.PPC64LE.QuickCodes.state_mod_eq m0
s
s'}
Vale.PPC64LE.QuickCodes.mods_contains1 mods m0 \/
Vale.PPC64LE.QuickCodes.state_mod_eq m0 s s') | {
"end_col": 33,
"end_line": 79,
"start_col": 3,
"start_line": 75
} |
FStar.Pervasives.Lemma | val update_state_mods_not1 (mods: mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s)) | [
{
"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
}
] | false | let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0 | val update_state_mods_not1 (mods: mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
let rec update_state_mods_not1 (mods: mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s)) = | false | null | true | match mods with
| [] -> ()
| _ :: mods -> update_state_mods_not1 mods s' s m0 | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.State.state",
"Vale.PPC64LE.QuickCode.mod_t",
"Prims.list",
"Vale.PPC64LE.QuickCodes.update_state_mods_not1",
"Prims.unit",
"Prims.b2t",
"Prims.op_Negation",
"Vale.PPC64LE.QuickCodes.mods_contains1",
"Prims.squash",
"Vale.PPC64LE.QuickCodes.state_mod_eq",
"Vale.PPC64LE.QuickCode.update_state_mods",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s)) | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_state_mods_not1 (mods: mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s)) | [
"recursion"
] | Vale.PPC64LE.QuickCodes.update_state_mods_not1 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mods: Vale.PPC64LE.QuickCode.mods_t ->
s': Vale.PPC64LE.State.state ->
s: Vale.PPC64LE.State.state ->
m0: Vale.PPC64LE.QuickCode.mod_t
-> FStar.Pervasives.Lemma
(requires Prims.op_Negation (Vale.PPC64LE.QuickCodes.mods_contains1 mods m0))
(ensures
Vale.PPC64LE.QuickCodes.state_mod_eq m0
s
(Vale.PPC64LE.QuickCode.update_state_mods mods s' s)) | {
"end_col": 50,
"end_line": 48,
"start_col": 2,
"start_line": 46
} |
Prims.Tot | val qAssertLemma (p:Type0) : tAssertLemma p | [
{
"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
}
] | false | let qAssertLemma p = fun () -> () | val qAssertLemma (p:Type0) : tAssertLemma p
let qAssertLemma p = | false | null | false | fun () -> () | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
"total"
] | [
"Prims.unit"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
()
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
=
update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0
let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
=
match mods with
| [] -> ()
| _::mods ->
if mods_contains mods' mods && mods_contains1 mods m0 then
update_state_mods_weaken1 mods mods' s' s m0
let update_state_mods_weaken (mods mods':mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s')
=
update_state_mods_from mods s' s;
let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') =
update_state_mods_weaken1 mods mods' s' s m0
in
FStar.Classical.forall_intro f1;
update_state_mods_to mods' s' s
let call_QPURE
(#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:state -> a -> Type0) (s0:state)
: Lemma
(requires
(forall (p:unit -> GTot Type0).{:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p)))
(ensures wp cs qcs mods k s0)
=
l ()
(*
let call_QBindPURE
(#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0))
(l:unit -> PURE b pre) (qcs:state -> b -> GTot (quickCodes a cs)) (mods:mods_t)
(k:state -> a -> Type0) (s0:state)
: Ghost b
(requires
(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)))
(ensures fun g -> (wp cs (qcs s0 g) mods k s0))
=
l ()
*)
let rec wp_sound #a cs qcs mods k s0 =
let qcs0 = qcs in
match qcs with
| QEmpty g ->
update_state_mods_refl mods s0;
let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g)
| QSeq _ _ qc qcs ->
let QProc _ _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Seq cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs qcs mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QBind _ _ qc qcs ->
let QProc c' _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Bind cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QGetState f ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QPURE r msg pre l qcs' ->
call_QPURE r msg pre l qcs' mods k s0;
wp_sound cs qcs' mods k s0
(*
| QBindPURE b r msg pre l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = call_QBindPURE r msg pre l qcs' mods k s0 in
let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
*)
| QLemma _ _ pre post l qcs' ->
l ();
wp_sound cs qcs' mods k s0
| QGhost b _ _ pre post l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = l () in
let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in
wp_sound cs qcs mods k s0
let qblock_proof #a #cs qcs mods s0 k =
wp_sound cs (qcs s0) mods k s0
let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
if b then
(
let (sM, f0, g) = QProc?.proof qc1 s0 k in
update_state_mods_weaken qc1.mods mods sM s0;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s0 k in
update_state_mods_weaken qc2.mods mods sM s0;
(sM, f0, g)
)
let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
( match b with
| Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2
| Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2
| Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2
| Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2
| Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2
| Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2
);
let s1 = {s0 with cr0 = eval_cmp_cr0 s0 (cmp_to_ocmp b)} in
update_state_mods_to mods s1 s0;
if eval_cmp s0 b then
(
let (sM, f0, g) = QProc?.proof qc1 s1 k in
va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc1.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s1 k in
va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc2.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
)
let rec qWhile_proof_rec
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:state -> a -> Type0)
(dec:state -> a -> d) (s0 s1:state) (g1:a) (f1:fuel) (k:state -> a -> Type0)
: Ghost (state & va_fuel & a)
(requires
state_inv s1 /\
wp_While b qc mods inv dec g1 s1 k /\
eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\
update_state_mods mods s1 s0 == s1)
(ensures fun (s2, f2, g2) ->
eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\
update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2
)
(decreases (dec s1 g1))
=
let ob = cmp_to_ocmp b in
let s1' = {s1 with cr0 = eval_cmp_cr0 s1 (cmp_to_ocmp b)} in
update_state_mods_to mods s1' s1;
update_state_mods_trans mods s0 s1 s1';
if eval_cmp s1 b then
(
let inv2 = wp_While_inv qc mods inv dec s1 g1 in
let wp = QProc?.wp (qc g1) in
let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in
let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in
let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in
update_state_mods_weaken (qc g1).mods mods sc s2;
update_state_mods_trans mods s0 s2 sc;
qWhile_proof_rec b qc mods inv dec s0 sc gc fN k
)
else
(
let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in
(s2, f2, g1)
)
let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k =
let ob = cmp_to_ocmp b in
let (s1, f1) = va_lemma_while_total ob c s0 in
update_state_mods_refl mods s0;
qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qAssertLemma (p:Type0) : tAssertLemma p | [] | Vale.PPC64LE.QuickCodes.qAssertLemma | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Type0 -> Vale.PPC64LE.QuickCodes.tAssertLemma p | {
"end_col": 33,
"end_line": 320,
"start_col": 21,
"start_line": 320
} |
Prims.Tot | [
{
"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
}
] | false | let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint | let state_mod_eq (m: mod_t) (s1 s2: state) = | false | null | false | match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n ->
Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
"total"
] | [
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.State.state",
"Prims.l_True",
"Prims.eq2",
"Prims.bool",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ok",
"Vale.PPC64LE.Machine_s.reg",
"Vale.PPC64LE.Machine_s.nat64",
"Vale.PPC64LE.State.eval_reg",
"Vale.PPC64LE.Machine_s.vec",
"Vale.PPC64LE.Machine_s.quad32",
"Vale.PPC64LE.State.eval_vec",
"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.HeapImpl.vale_heap",
"Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap",
"Vale.PPC64LE.Decls.coerce",
"Vale.Arch.HeapImpl.vale_full_heap",
"Vale.Arch.Heap.heap_impl",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_heap",
"Vale.Arch.HeapImpl.vale_heap_layout",
"Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_layout",
"Vale.PPC64LE.Decls.heaplet_id",
"Vale.Lib.Map16.sel",
"Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets",
"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",
"Prims.logical"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t | false | true | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val state_mod_eq : m: Vale.PPC64LE.QuickCode.mod_t -> s1: Vale.PPC64LE.State.state -> s2: Vale.PPC64LE.State.state
-> Prims.logical | [] | Vale.PPC64LE.QuickCodes.state_mod_eq | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | m: Vale.PPC64LE.QuickCode.mod_t -> s1: Vale.PPC64LE.State.state -> s2: Vale.PPC64LE.State.state
-> Prims.logical | {
"end_col": 58,
"end_line": 33,
"start_col": 2,
"start_line": 22
} |
|
FStar.Pervasives.Lemma | val call_QPURE
(#a: Type0)
(#cs: codes)
(r: range)
(msg: string)
(pre: ((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l: (unit -> PURE unit (as_pure_wp pre)))
(qcs: quickCodes a cs)
(mods: mods_t)
(k: (state -> a -> Type0))
(s0: state)
: Lemma
(requires
(forall (p: (unit -> GTot Type0)). {:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) | [
{
"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
}
] | false | let call_QPURE
(#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:state -> a -> Type0) (s0:state)
: Lemma
(requires
(forall (p:unit -> GTot Type0).{:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p)))
(ensures wp cs qcs mods k s0)
=
l () | val call_QPURE
(#a: Type0)
(#cs: codes)
(r: range)
(msg: string)
(pre: ((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l: (unit -> PURE unit (as_pure_wp pre)))
(qcs: quickCodes a cs)
(mods: mods_t)
(k: (state -> a -> Type0))
(s0: state)
: Lemma
(requires
(forall (p: (unit -> GTot Type0)). {:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0)
let call_QPURE
(#a: Type0)
(#cs: codes)
(r: range)
(msg: string)
(pre: ((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l: (unit -> PURE unit (as_pure_wp pre)))
(qcs: quickCodes a cs)
(mods: mods_t)
(k: (state -> a -> Type0))
(s0: state)
: Lemma
(requires
(forall (p: (unit -> GTot Type0)). {:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = | false | null | true | l () | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.QuickCodes.codes",
"FStar.Range.range",
"Prims.string",
"Prims.unit",
"FStar.Monotonic.Pure.is_monotonic",
"FStar.Monotonic.Pure.as_pure_wp",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.State.state",
"Prims.l_Forall",
"Prims.l_imp",
"Vale.PPC64LE.QuickCodes.wp",
"Vale.PPC64LE.QuickCodes.label",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
()
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
=
update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0
let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
=
match mods with
| [] -> ()
| _::mods ->
if mods_contains mods' mods && mods_contains1 mods m0 then
update_state_mods_weaken1 mods mods' s' s m0
let update_state_mods_weaken (mods mods':mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s')
=
update_state_mods_from mods s' s;
let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') =
update_state_mods_weaken1 mods mods' s' s m0
in
FStar.Classical.forall_intro f1;
update_state_mods_to mods' s' s
let call_QPURE
(#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:state -> a -> Type0) (s0:state)
: Lemma
(requires
(forall (p:unit -> GTot Type0).{:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p)))
(ensures wp cs qcs mods k s0) | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val call_QPURE
(#a: Type0)
(#cs: codes)
(r: range)
(msg: string)
(pre: ((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l: (unit -> PURE unit (as_pure_wp pre)))
(qcs: quickCodes a cs)
(mods: mods_t)
(k: (state -> a -> Type0))
(s0: state)
: Lemma
(requires
(forall (p: (unit -> GTot Type0)). {:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) | [] | Vale.PPC64LE.QuickCodes.call_QPURE | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
r: FStar.Range.range ->
msg: Prims.string ->
pre:
(_: (_: Prims.unit -> Prims.GTot Type0) -> Prims.GTot Type0)
{FStar.Monotonic.Pure.is_monotonic pre} ->
l: (_: Prims.unit -> Prims.PURE Prims.unit) ->
qcs: Vale.PPC64LE.QuickCodes.quickCodes a cs ->
mods: Vale.PPC64LE.QuickCode.mods_t ->
k: (_: Vale.PPC64LE.State.state -> _: a -> Type0) ->
s0: Vale.PPC64LE.State.state
-> FStar.Pervasives.Lemma
(requires
forall (p: (_: Prims.unit -> Prims.GTot Type0)). {:pattern pre p}
(Vale.PPC64LE.QuickCodes.wp cs qcs mods k s0 ==> p ()) ==>
Vale.PPC64LE.QuickCodes.label r msg (pre p))
(ensures Vale.PPC64LE.QuickCodes.wp cs qcs mods k s0) | {
"end_col": 6,
"end_line": 157,
"start_col": 2,
"start_line": 157
} |
FStar.Pervasives.Lemma | val update_state_mods_trans (mods: mods_t) (s0 s1 s2: state)
: Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2) | [
{
"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
}
] | false | let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
=
update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0 | val update_state_mods_trans (mods: mods_t) (s0 s1 s2: state)
: Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
let update_state_mods_trans (mods: mods_t) (s0 s1 s2: state)
: Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2) = | false | null | true | update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0 | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.State.state",
"Vale.PPC64LE.QuickCodes.update_state_mods_to",
"Prims.unit",
"Vale.PPC64LE.QuickCodes.update_state_mods_from",
"Prims.l_and",
"Prims.eq2",
"Vale.PPC64LE.QuickCode.update_state_mods",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
()
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2) | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_state_mods_trans (mods: mods_t) (s0 s1 s2: state)
: Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2) | [] | Vale.PPC64LE.QuickCodes.update_state_mods_trans | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mods: Vale.PPC64LE.QuickCode.mods_t ->
s0: Vale.PPC64LE.State.state ->
s1: Vale.PPC64LE.State.state ->
s2: Vale.PPC64LE.State.state
-> FStar.Pervasives.Lemma
(requires
Vale.PPC64LE.QuickCode.update_state_mods mods s1 s0 == s1 /\
Vale.PPC64LE.QuickCode.update_state_mods mods s2 s1 == s2)
(ensures Vale.PPC64LE.QuickCode.update_state_mods mods s2 s0 == s2) | {
"end_col": 33,
"end_line": 125,
"start_col": 2,
"start_line": 123
} |
Prims.Ghost | 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) | [
{
"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
}
] | false | let wp_sound_code #a c qc k s0 =
let QProc c _ wp proof = qc in
proof s0 k | 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)
let wp_sound_code #a c qc k s0 = | false | null | false | let QProc c _ wp proof = qc in
proof s0 k | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.QuickCode.quickProc_wp",
"Vale.PPC64LE.QuickCode.t_proof",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.QuickCodes.fuel"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
()
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
=
update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0
let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
=
match mods with
| [] -> ()
| _::mods ->
if mods_contains mods' mods && mods_contains1 mods m0 then
update_state_mods_weaken1 mods mods' s' s m0
let update_state_mods_weaken (mods mods':mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s')
=
update_state_mods_from mods s' s;
let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') =
update_state_mods_weaken1 mods mods' s' s m0
in
FStar.Classical.forall_intro f1;
update_state_mods_to mods' s' s
let call_QPURE
(#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:state -> a -> Type0) (s0:state)
: Lemma
(requires
(forall (p:unit -> GTot Type0).{:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p)))
(ensures wp cs qcs mods k s0)
=
l ()
(*
let call_QBindPURE
(#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0))
(l:unit -> PURE b pre) (qcs:state -> b -> GTot (quickCodes a cs)) (mods:mods_t)
(k:state -> a -> Type0) (s0:state)
: Ghost b
(requires
(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)))
(ensures fun g -> (wp cs (qcs s0 g) mods k s0))
=
l ()
*)
let rec wp_sound #a cs qcs mods k s0 =
let qcs0 = qcs in
match qcs with
| QEmpty g ->
update_state_mods_refl mods s0;
let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g)
| QSeq _ _ qc qcs ->
let QProc _ _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Seq cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs qcs mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QBind _ _ qc qcs ->
let QProc c' _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Bind cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QGetState f ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QPURE r msg pre l qcs' ->
call_QPURE r msg pre l qcs' mods k s0;
wp_sound cs qcs' mods k s0
(*
| QBindPURE b r msg pre l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = call_QBindPURE r msg pre l qcs' mods k s0 in
let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
*)
| QLemma _ _ pre post l qcs' ->
l ();
wp_sound cs qcs' mods k s0
| QGhost b _ _ pre post l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = l () in
let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in
wp_sound cs qcs mods k s0
let qblock_proof #a #cs qcs mods s0 k =
wp_sound cs (qcs s0) mods k s0
let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
if b then
(
let (sM, f0, g) = QProc?.proof qc1 s0 k in
update_state_mods_weaken qc1.mods mods sM s0;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s0 k in
update_state_mods_weaken qc2.mods mods sM s0;
(sM, f0, g)
)
let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
( match b with
| Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2
| Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2
| Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2
| Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2
| Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2
| Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2
);
let s1 = {s0 with cr0 = eval_cmp_cr0 s0 (cmp_to_ocmp b)} in
update_state_mods_to mods s1 s0;
if eval_cmp s0 b then
(
let (sM, f0, g) = QProc?.proof qc1 s1 k in
va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc1.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s1 k in
va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc2.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
)
let rec qWhile_proof_rec
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:state -> a -> Type0)
(dec:state -> a -> d) (s0 s1:state) (g1:a) (f1:fuel) (k:state -> a -> Type0)
: Ghost (state & va_fuel & a)
(requires
state_inv s1 /\
wp_While b qc mods inv dec g1 s1 k /\
eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\
update_state_mods mods s1 s0 == s1)
(ensures fun (s2, f2, g2) ->
eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\
update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2
)
(decreases (dec s1 g1))
=
let ob = cmp_to_ocmp b in
let s1' = {s1 with cr0 = eval_cmp_cr0 s1 (cmp_to_ocmp b)} in
update_state_mods_to mods s1' s1;
update_state_mods_trans mods s0 s1 s1';
if eval_cmp s1 b then
(
let inv2 = wp_While_inv qc mods inv dec s1 g1 in
let wp = QProc?.wp (qc g1) in
let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in
let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in
let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in
update_state_mods_weaken (qc g1).mods mods sc s2;
update_state_mods_trans mods s0 s2 sc;
qWhile_proof_rec b qc mods inv dec s0 sc gc fN k
)
else
(
let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in
(s2, f2, g1)
)
let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k =
let ob = cmp_to_ocmp b in
let (s1, f1) = va_lemma_while_total ob c s0 in
update_state_mods_refl mods s0;
qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k
let qAssertLemma p = fun () -> ()
let qAssumeLemma p = fun () -> assume p
let qAssertSquashLemma p = fun () -> ()
//let qAssertByLemma #a p qcs mods s0 =
// fun () -> let _ = wp_sound [] qcs mods (fun _ _ -> p) s0 in () | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val 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) | [] | Vale.PPC64LE.QuickCodes.wp_sound_code | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
c: Vale.PPC64LE.QuickCodes.code ->
qc: Vale.PPC64LE.QuickCode.quickCode a c ->
k: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0) ->
s0: Vale.PPC64LE.Decls.va_state
-> Prims.Ghost ((Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.QuickCodes.fuel) * a) | {
"end_col": 12,
"end_line": 329,
"start_col": 32,
"start_line": 327
} |
Prims.Ghost | val va_wp_sound_code_norm (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:(s0':va_state{s0 == s0'}) -> va_state -> a -> Type0) :
Ghost (va_state & fuel & a)
(t_require s0 /\ normal (wp_sound_code_pre qc s0 k))
(wp_sound_code_post qc s0 k) | [
{
"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
}
] | false | let va_wp_sound_code_norm #a c qc s0 k =
assert_normal (wp_sound_code_pre qc s0 k);
wp_sound_code_wrap c qc s0 k | val va_wp_sound_code_norm (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:(s0':va_state{s0 == s0'}) -> va_state -> a -> Type0) :
Ghost (va_state & fuel & a)
(t_require s0 /\ normal (wp_sound_code_pre qc s0 k))
(wp_sound_code_post qc s0 k)
let va_wp_sound_code_norm #a c qc s0 k = | false | null | false | assert_normal (wp_sound_code_pre qc s0 k);
wp_sound_code_wrap c qc s0 k | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.Decls.va_state",
"Prims.eq2",
"Vale.PPC64LE.QuickCodes.wp_sound_code_wrap",
"Prims.unit",
"Vale.PPC64LE.QuickCodes.assert_normal",
"Vale.PPC64LE.QuickCodes.wp_sound_code_pre",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.QuickCodes.fuel"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
()
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
=
update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0
let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
=
match mods with
| [] -> ()
| _::mods ->
if mods_contains mods' mods && mods_contains1 mods m0 then
update_state_mods_weaken1 mods mods' s' s m0
let update_state_mods_weaken (mods mods':mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s')
=
update_state_mods_from mods s' s;
let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') =
update_state_mods_weaken1 mods mods' s' s m0
in
FStar.Classical.forall_intro f1;
update_state_mods_to mods' s' s
let call_QPURE
(#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:state -> a -> Type0) (s0:state)
: Lemma
(requires
(forall (p:unit -> GTot Type0).{:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p)))
(ensures wp cs qcs mods k s0)
=
l ()
(*
let call_QBindPURE
(#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0))
(l:unit -> PURE b pre) (qcs:state -> b -> GTot (quickCodes a cs)) (mods:mods_t)
(k:state -> a -> Type0) (s0:state)
: Ghost b
(requires
(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)))
(ensures fun g -> (wp cs (qcs s0 g) mods k s0))
=
l ()
*)
let rec wp_sound #a cs qcs mods k s0 =
let qcs0 = qcs in
match qcs with
| QEmpty g ->
update_state_mods_refl mods s0;
let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g)
| QSeq _ _ qc qcs ->
let QProc _ _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Seq cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs qcs mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QBind _ _ qc qcs ->
let QProc c' _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Bind cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QGetState f ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QPURE r msg pre l qcs' ->
call_QPURE r msg pre l qcs' mods k s0;
wp_sound cs qcs' mods k s0
(*
| QBindPURE b r msg pre l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = call_QBindPURE r msg pre l qcs' mods k s0 in
let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
*)
| QLemma _ _ pre post l qcs' ->
l ();
wp_sound cs qcs' mods k s0
| QGhost b _ _ pre post l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = l () in
let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in
wp_sound cs qcs mods k s0
let qblock_proof #a #cs qcs mods s0 k =
wp_sound cs (qcs s0) mods k s0
let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
if b then
(
let (sM, f0, g) = QProc?.proof qc1 s0 k in
update_state_mods_weaken qc1.mods mods sM s0;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s0 k in
update_state_mods_weaken qc2.mods mods sM s0;
(sM, f0, g)
)
let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
( match b with
| Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2
| Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2
| Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2
| Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2
| Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2
| Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2
);
let s1 = {s0 with cr0 = eval_cmp_cr0 s0 (cmp_to_ocmp b)} in
update_state_mods_to mods s1 s0;
if eval_cmp s0 b then
(
let (sM, f0, g) = QProc?.proof qc1 s1 k in
va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc1.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s1 k in
va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc2.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
)
let rec qWhile_proof_rec
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:state -> a -> Type0)
(dec:state -> a -> d) (s0 s1:state) (g1:a) (f1:fuel) (k:state -> a -> Type0)
: Ghost (state & va_fuel & a)
(requires
state_inv s1 /\
wp_While b qc mods inv dec g1 s1 k /\
eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\
update_state_mods mods s1 s0 == s1)
(ensures fun (s2, f2, g2) ->
eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\
update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2
)
(decreases (dec s1 g1))
=
let ob = cmp_to_ocmp b in
let s1' = {s1 with cr0 = eval_cmp_cr0 s1 (cmp_to_ocmp b)} in
update_state_mods_to mods s1' s1;
update_state_mods_trans mods s0 s1 s1';
if eval_cmp s1 b then
(
let inv2 = wp_While_inv qc mods inv dec s1 g1 in
let wp = QProc?.wp (qc g1) in
let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in
let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in
let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in
update_state_mods_weaken (qc g1).mods mods sc s2;
update_state_mods_trans mods s0 s2 sc;
qWhile_proof_rec b qc mods inv dec s0 sc gc fN k
)
else
(
let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in
(s2, f2, g1)
)
let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k =
let ob = cmp_to_ocmp b in
let (s1, f1) = va_lemma_while_total ob c s0 in
update_state_mods_refl mods s0;
qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k
let qAssertLemma p = fun () -> ()
let qAssumeLemma p = fun () -> assume p
let qAssertSquashLemma p = fun () -> ()
//let qAssertByLemma #a p qcs mods s0 =
// fun () -> let _ = wp_sound [] qcs mods (fun _ _ -> p) s0 in ()
let wp_sound_code #a c qc k s0 =
let QProc c _ wp proof = qc in
proof s0 k
let lemma_state_match s0 s1 =
()
let wp_sound_code_wrap (#a:Type0) (c:code) (qc:quickCode a c) (s0:state) (k:(s0':state{s0 == s0'}) -> state -> a -> Type0) :
Ghost (state & fuel & a)
(t_require s0 /\ wp_sound_code_pre qc s0 k)
(wp_sound_code_post qc s0 k)
=
wp_sound_code c qc (k s0) s0
let assert_normal (p:Type) : Lemma
(requires normal p)
(ensures p)
=
() | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wp_sound_code_norm (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:(s0':va_state{s0 == s0'}) -> va_state -> a -> Type0) :
Ghost (va_state & fuel & a)
(t_require s0 /\ normal (wp_sound_code_pre qc s0 k))
(wp_sound_code_post qc s0 k) | [] | Vale.PPC64LE.QuickCodes.va_wp_sound_code_norm | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
c: Vale.PPC64LE.QuickCodes.code ->
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)
-> Prims.Ghost ((Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.QuickCodes.fuel) * a) | {
"end_col": 30,
"end_line": 349,
"start_col": 2,
"start_line": 348
} |
Prims.Ghost | val qWhile_proof_rec
(#a #d: Type)
(#c: code)
(b: cmp)
(qc: (a -> quickCode a c))
(mods: mods_t)
(inv: (state -> a -> Type0))
(dec: (state -> a -> d))
(s0 s1: state)
(g1: a)
(f1: fuel)
(k: (state -> a -> Type0))
: Ghost (state & va_fuel & a)
(requires
state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\
eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1)
(ensures
fun (s2, f2, g2) ->
eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\
state_inv s2 /\ k s2 g2)
(decreases (dec s1 g1)) | [
{
"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
}
] | false | let rec qWhile_proof_rec
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:state -> a -> Type0)
(dec:state -> a -> d) (s0 s1:state) (g1:a) (f1:fuel) (k:state -> a -> Type0)
: Ghost (state & va_fuel & a)
(requires
state_inv s1 /\
wp_While b qc mods inv dec g1 s1 k /\
eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\
update_state_mods mods s1 s0 == s1)
(ensures fun (s2, f2, g2) ->
eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\
update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2
)
(decreases (dec s1 g1))
=
let ob = cmp_to_ocmp b in
let s1' = {s1 with cr0 = eval_cmp_cr0 s1 (cmp_to_ocmp b)} in
update_state_mods_to mods s1' s1;
update_state_mods_trans mods s0 s1 s1';
if eval_cmp s1 b then
(
let inv2 = wp_While_inv qc mods inv dec s1 g1 in
let wp = QProc?.wp (qc g1) in
let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in
let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in
let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in
update_state_mods_weaken (qc g1).mods mods sc s2;
update_state_mods_trans mods s0 s2 sc;
qWhile_proof_rec b qc mods inv dec s0 sc gc fN k
)
else
(
let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in
(s2, f2, g1)
) | val qWhile_proof_rec
(#a #d: Type)
(#c: code)
(b: cmp)
(qc: (a -> quickCode a c))
(mods: mods_t)
(inv: (state -> a -> Type0))
(dec: (state -> a -> d))
(s0 s1: state)
(g1: a)
(f1: fuel)
(k: (state -> a -> Type0))
: Ghost (state & va_fuel & a)
(requires
state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\
eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1)
(ensures
fun (s2, f2, g2) ->
eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\
state_inv s2 /\ k s2 g2)
(decreases (dec s1 g1))
let rec qWhile_proof_rec
(#a #d: Type)
(#c: code)
(b: cmp)
(qc: (a -> quickCode a c))
(mods: mods_t)
(inv: (state -> a -> Type0))
(dec: (state -> a -> d))
(s0 s1: state)
(g1: a)
(f1: fuel)
(k: (state -> a -> Type0))
: Ghost (state & va_fuel & a)
(requires
state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\
eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1)
(ensures
fun (s2, f2, g2) ->
eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\
state_inv s2 /\ k s2 g2)
(decreases (dec s1 g1)) = | false | null | false | let ob = cmp_to_ocmp b in
let s1' = { s1 with cr0 = eval_cmp_cr0 s1 (cmp_to_ocmp b) } in
update_state_mods_to mods s1' s1;
update_state_mods_trans mods s0 s1 s1';
if eval_cmp s1 b
then
(let inv2 = wp_While_inv qc mods inv dec s1 g1 in
let wp = QProc?.wp (qc g1) in
let s2, f2 = va_lemma_whileTrue_total ob c s0 s1 f1 in
let sc, fc, gc = QProc?.proof (qc g1) s2 inv2 in
let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in
update_state_mods_weaken (qc g1).mods mods sc s2;
update_state_mods_trans mods s0 s2 sc;
qWhile_proof_rec b qc mods inv dec s0 sc gc fN k)
else
(let s2, f2 = va_lemma_whileFalse_total ob c s0 s1 f1 in
(s2, f2, g1)) | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
""
] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCodes.cmp",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.State.state",
"Vale.PPC64LE.QuickCodes.fuel",
"Vale.PPC64LE.QuickCodes.eval_cmp",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.Decls.va_fuel",
"Vale.PPC64LE.QuickCodes.qWhile_proof_rec",
"Prims.unit",
"Vale.PPC64LE.QuickCodes.update_state_mods_trans",
"Vale.PPC64LE.QuickCodes.update_state_mods_weaken",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.PPC64LE.Decls.va_lemma_whileMerge_total",
"Vale.PPC64LE.Machine_s.While",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__proof",
"FStar.Pervasives.Native.tuple2",
"Vale.PPC64LE.Decls.va_lemma_whileTrue_total",
"Vale.PPC64LE.QuickCode.quickProc_wp",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__wp",
"Vale.PPC64LE.QuickCodes.wp_While_inv",
"Prims.bool",
"FStar.Pervasives.Native.Mktuple3",
"Vale.PPC64LE.Decls.va_lemma_whileFalse_total",
"Vale.PPC64LE.QuickCodes.update_state_mods_to",
"Vale.PPC64LE.Machine_s.Mkstate",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ok",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__regs",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__vecs",
"Vale.PPC64LE.Decls.eval_cmp_cr0",
"Vale.PPC64LE.QuickCodes.cmp_to_ocmp",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__xer",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_heap",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_stack",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_stackTaint",
"Prims.l_and",
"Vale.PPC64LE.Decls.state_inv",
"Vale.PPC64LE.QuickCodes.wp_While",
"Vale.PPC64LE.Decls.eval_while_inv",
"Prims.eq2",
"Vale.PPC64LE.QuickCode.update_state_mods",
"Vale.PPC64LE.Decls.eval_code"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
()
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
=
update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0
let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
=
match mods with
| [] -> ()
| _::mods ->
if mods_contains mods' mods && mods_contains1 mods m0 then
update_state_mods_weaken1 mods mods' s' s m0
let update_state_mods_weaken (mods mods':mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s')
=
update_state_mods_from mods s' s;
let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') =
update_state_mods_weaken1 mods mods' s' s m0
in
FStar.Classical.forall_intro f1;
update_state_mods_to mods' s' s
let call_QPURE
(#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:state -> a -> Type0) (s0:state)
: Lemma
(requires
(forall (p:unit -> GTot Type0).{:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p)))
(ensures wp cs qcs mods k s0)
=
l ()
(*
let call_QBindPURE
(#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0))
(l:unit -> PURE b pre) (qcs:state -> b -> GTot (quickCodes a cs)) (mods:mods_t)
(k:state -> a -> Type0) (s0:state)
: Ghost b
(requires
(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)))
(ensures fun g -> (wp cs (qcs s0 g) mods k s0))
=
l ()
*)
let rec wp_sound #a cs qcs mods k s0 =
let qcs0 = qcs in
match qcs with
| QEmpty g ->
update_state_mods_refl mods s0;
let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g)
| QSeq _ _ qc qcs ->
let QProc _ _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Seq cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs qcs mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QBind _ _ qc qcs ->
let QProc c' _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Bind cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QGetState f ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QPURE r msg pre l qcs' ->
call_QPURE r msg pre l qcs' mods k s0;
wp_sound cs qcs' mods k s0
(*
| QBindPURE b r msg pre l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = call_QBindPURE r msg pre l qcs' mods k s0 in
let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
*)
| QLemma _ _ pre post l qcs' ->
l ();
wp_sound cs qcs' mods k s0
| QGhost b _ _ pre post l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = l () in
let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in
wp_sound cs qcs mods k s0
let qblock_proof #a #cs qcs mods s0 k =
wp_sound cs (qcs s0) mods k s0
let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
if b then
(
let (sM, f0, g) = QProc?.proof qc1 s0 k in
update_state_mods_weaken qc1.mods mods sM s0;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s0 k in
update_state_mods_weaken qc2.mods mods sM s0;
(sM, f0, g)
)
let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
( match b with
| Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2
| Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2
| Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2
| Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2
| Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2
| Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2
);
let s1 = {s0 with cr0 = eval_cmp_cr0 s0 (cmp_to_ocmp b)} in
update_state_mods_to mods s1 s0;
if eval_cmp s0 b then
(
let (sM, f0, g) = QProc?.proof qc1 s1 k in
va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc1.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s1 k in
va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc2.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
)
let rec qWhile_proof_rec
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:state -> a -> Type0)
(dec:state -> a -> d) (s0 s1:state) (g1:a) (f1:fuel) (k:state -> a -> Type0)
: Ghost (state & va_fuel & a)
(requires
state_inv s1 /\
wp_While b qc mods inv dec g1 s1 k /\
eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\
update_state_mods mods s1 s0 == s1)
(ensures fun (s2, f2, g2) ->
eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\
update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2
) | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qWhile_proof_rec
(#a #d: Type)
(#c: code)
(b: cmp)
(qc: (a -> quickCode a c))
(mods: mods_t)
(inv: (state -> a -> Type0))
(dec: (state -> a -> d))
(s0 s1: state)
(g1: a)
(f1: fuel)
(k: (state -> a -> Type0))
: Ghost (state & va_fuel & a)
(requires
state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\
eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1)
(ensures
fun (s2, f2, g2) ->
eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\
state_inv s2 /\ k s2 g2)
(decreases (dec s1 g1)) | [
"recursion"
] | Vale.PPC64LE.QuickCodes.qWhile_proof_rec | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.PPC64LE.QuickCodes.cmp ->
qc: (_: a -> Vale.PPC64LE.QuickCode.quickCode a c) ->
mods: Vale.PPC64LE.QuickCode.mods_t ->
inv: (_: Vale.PPC64LE.State.state -> _: a -> Type0) ->
dec: (_: Vale.PPC64LE.State.state -> _: a -> d) ->
s0: Vale.PPC64LE.State.state ->
s1: Vale.PPC64LE.State.state ->
g1: a ->
f1: Vale.PPC64LE.QuickCodes.fuel ->
k: (_: Vale.PPC64LE.State.state -> _: a -> Type0)
-> Prims.Ghost ((Vale.PPC64LE.State.state * Vale.PPC64LE.Decls.va_fuel) * a) | {
"end_col": 3,
"end_line": 312,
"start_col": 3,
"start_line": 292
} |
FStar.Pervasives.Lemma | val update_state_mods_to (mods: mods_t) (s' s: state)
: Lemma
(requires
(forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'))
(ensures state_eq s' (update_state_mods mods s' s)) | [
{
"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
}
] | false | let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
() | val update_state_mods_to (mods: mods_t) (s' s: state)
: Lemma
(requires
(forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'))
(ensures state_eq s' (update_state_mods mods s' s))
let update_state_mods_to (mods: mods_t) (s' s: state)
: Lemma
(requires
(forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'))
(ensures state_eq s' (update_state_mods mods s' s)) = | false | null | true | let s'' = update_state_mods mods s' s in
let f1 (m0: mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r: reg) : Lemma (ensures s'.regs r == s''.regs r) [SMTPat (s'.regs r)] =
f1 (Mod_reg r)
in
let f1_vec (v: vec) : Lemma (ensures s'.vecs v == s''.vecs v) [SMTPat (s'.vecs v)] =
f1 (Mod_vec v)
in
let f1_heaplet (n: heaplet_id)
: Lemma
(ensures
Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)] =
f1 (Mod_mem_heaplet n)
in
() | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.State.state",
"Vale.Arch.HeapImpl.heaplet_id",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.Lib.Map16.sel",
"Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_heap",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil",
"Vale.PPC64LE.QuickCode.Mod_mem_heaplet",
"Vale.PPC64LE.Decls.coerce",
"Vale.Arch.HeapImpl.vale_full_heap",
"Vale.Arch.Heap.heap_impl",
"Vale.PPC64LE.Machine_s.vec",
"Vale.Def.Types_s.quad32",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__vecs",
"Vale.PPC64LE.QuickCode.Mod_vec",
"Vale.PPC64LE.Machine_s.quad32",
"Vale.PPC64LE.Machine_s.reg",
"Vale.Def.Words_s.nat64",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__regs",
"Vale.PPC64LE.QuickCode.Mod_reg",
"Vale.PPC64LE.Machine_s.nat64",
"Vale.PPC64LE.QuickCode.Mod_stackTaint",
"Vale.PPC64LE.QuickCode.Mod_stack",
"Vale.PPC64LE.QuickCode.Mod_mem_layout",
"Vale.PPC64LE.QuickCode.Mod_mem",
"Vale.PPC64LE.QuickCode.Mod_xer",
"Vale.PPC64LE.QuickCode.Mod_cr0",
"Vale.PPC64LE.QuickCode.Mod_ok",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCodes.state_mod_eq",
"Vale.PPC64LE.QuickCodes.update_state_mods_to1",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCode.update_state_mods",
"Prims.l_Forall",
"Prims.l_or",
"Prims.b2t",
"Vale.PPC64LE.QuickCodes.mods_contains1",
"Vale.PPC64LE.State.state_eq"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
)) | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_state_mods_to (mods: mods_t) (s' s: state)
: Lemma
(requires
(forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'))
(ensures state_eq s' (update_state_mods mods s' s)) | [] | Vale.PPC64LE.QuickCodes.update_state_mods_to | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | mods: Vale.PPC64LE.QuickCode.mods_t -> s': Vale.PPC64LE.State.state -> s: Vale.PPC64LE.State.state
-> FStar.Pervasives.Lemma
(requires
forall (m0: Vale.PPC64LE.QuickCode.mod_t).
{:pattern
Vale.PPC64LE.QuickCodes.mods_contains1 mods m0\/Vale.PPC64LE.QuickCodes.state_mod_eq m0
s
s'}
Vale.PPC64LE.QuickCodes.mods_contains1 mods m0 \/
Vale.PPC64LE.QuickCodes.state_mod_eq m0 s s')
(ensures Vale.PPC64LE.State.state_eq s' (Vale.PPC64LE.QuickCode.update_state_mods mods s' s)) | {
"end_col": 4,
"end_line": 117,
"start_col": 3,
"start_line": 87
} |
Prims.Ghost | 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
) | [
{
"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
}
] | false | let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
( match b with
| Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2
| Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2
| Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2
| Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2
| Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2
| Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2
);
let s1 = {s0 with cr0 = eval_cmp_cr0 s0 (cmp_to_ocmp b)} in
update_state_mods_to mods s1 s0;
if eval_cmp s0 b then
(
let (sM, f0, g) = QProc?.proof qc1 s1 k in
va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc1.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s1 k in
va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc2.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)
) | 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
)
let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = | false | null | false | (match b with
| Cmp_eq o1 o2 ->
lemma_valid_cmp_eq s0 o1 o2;
lemma_cmp_eq s0 o1 o2
| Cmp_ne o1 o2 ->
lemma_valid_cmp_ne s0 o1 o2;
lemma_cmp_ne s0 o1 o2
| Cmp_le o1 o2 ->
lemma_valid_cmp_le s0 o1 o2;
lemma_cmp_le s0 o1 o2
| Cmp_ge o1 o2 ->
lemma_valid_cmp_ge s0 o1 o2;
lemma_cmp_ge s0 o1 o2
| Cmp_lt o1 o2 ->
lemma_valid_cmp_lt s0 o1 o2;
lemma_cmp_lt s0 o1 o2
| Cmp_gt o1 o2 ->
lemma_valid_cmp_gt s0 o1 o2;
lemma_cmp_gt s0 o1 o2);
let s1 = { s0 with cr0 = eval_cmp_cr0 s0 (cmp_to_ocmp b) } in
update_state_mods_to mods s1 s0;
if eval_cmp s0 b
then
(let sM, f0, g = QProc?.proof qc1 s1 k in
va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc1.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g))
else
(let sM, f0, g = QProc?.proof qc2 s1 k in
va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM;
update_state_mods_weaken qc2.mods mods sM s1;
update_state_mods_trans mods s0 s1 sM;
(sM, f0, g)) | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCodes.cmp",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.eval_cmp",
"Vale.PPC64LE.State.state",
"Vale.PPC64LE.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Prims.unit",
"Vale.PPC64LE.QuickCodes.update_state_mods_trans",
"Vale.PPC64LE.QuickCodes.update_state_mods_weaken",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.PPC64LE.Decls.va_lemma_ifElseTrue_total",
"Vale.PPC64LE.QuickCodes.cmp_to_ocmp",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__proof",
"Prims.bool",
"Vale.PPC64LE.Decls.va_lemma_ifElseFalse_total",
"Vale.PPC64LE.QuickCodes.update_state_mods_to",
"Vale.PPC64LE.Machine_s.Mkstate",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ok",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__regs",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__vecs",
"Vale.PPC64LE.Decls.eval_cmp_cr0",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__xer",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_heap",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_stack",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_stackTaint",
"Vale.PPC64LE.Machine_s.cmp_opr",
"Vale.PPC64LE.Decls.lemma_cmp_eq",
"Vale.PPC64LE.Decls.lemma_valid_cmp_eq",
"Vale.PPC64LE.Decls.lemma_cmp_ne",
"Vale.PPC64LE.Decls.lemma_valid_cmp_ne",
"Vale.PPC64LE.Decls.lemma_cmp_le",
"Vale.PPC64LE.Decls.lemma_valid_cmp_le",
"Vale.PPC64LE.Decls.lemma_cmp_ge",
"Vale.PPC64LE.Decls.lemma_valid_cmp_ge",
"Vale.PPC64LE.Decls.lemma_cmp_lt",
"Vale.PPC64LE.Decls.lemma_valid_cmp_lt",
"Vale.PPC64LE.Decls.lemma_cmp_gt",
"Vale.PPC64LE.Decls.lemma_valid_cmp_gt"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2
let update_state_mods_from (mods:mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s')
(ensures (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
=
let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
update_state_mods_from1 mods s' s m0
in
FStar.Classical.forall_intro f1
let update_state_mods_to (mods:mods_t) (s' s:state) : Lemma
(requires (
forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'}
mods_contains1 mods m0 \/ state_mod_eq m0 s s'
))
(ensures state_eq s' (update_state_mods mods s' s))
=
let s'' = update_state_mods mods s' s in
let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') =
update_state_mods_to1 mods s' s m0
in
f1 Mod_ok;
f1 Mod_cr0;
f1 Mod_xer;
f1 Mod_mem;
f1 Mod_mem_layout;
f1 Mod_stack;
f1 Mod_stackTaint;
let f1_reg (r:reg) : Lemma
(ensures s'.regs r == s''.regs r)
[SMTPat (s'.regs r)]
=
f1 (Mod_reg r)
in
let f1_vec (v:vec) : Lemma
(ensures s'.vecs v == s''.vecs v)
[SMTPat (s'.vecs v)]
=
f1 (Mod_vec v)
in
let f1_heaplet (n:heaplet_id) : Lemma
(ensures Map16.sel (coerce s'.ms_heap).vf_heaplets n == Map16.sel (coerce s''.ms_heap).vf_heaplets n)
[SMTPat (Map16.sel (coerce s'.ms_heap).vf_heaplets n)]
=
f1 (Mod_mem_heaplet n)
in
()
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:state) : Lemma
(requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2)
(ensures update_state_mods mods s2 s0 == s2)
=
update_state_mods_from mods s1 s0;
update_state_mods_from mods s2 s1;
update_state_mods_to mods s2 s0
let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods)
(ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
=
match mods with
| [] -> ()
| _::mods ->
if mods_contains mods' mods && mods_contains1 mods m0 then
update_state_mods_weaken1 mods mods' s' s m0
let update_state_mods_weaken (mods mods':mods_t) (s' s:state) : Lemma
(requires update_state_mods mods s' s == s' /\ mods_contains mods' mods)
(ensures update_state_mods mods' s' s == s')
=
update_state_mods_from mods s' s;
let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') =
update_state_mods_weaken1 mods mods' s' s m0
in
FStar.Classical.forall_intro f1;
update_state_mods_to mods' s' s
let call_QPURE
(#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre})
(l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:state -> a -> Type0) (s0:state)
: Lemma
(requires
(forall (p:unit -> GTot Type0).{:pattern pre p}
(wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p)))
(ensures wp cs qcs mods k s0)
=
l ()
(*
let call_QBindPURE
(#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0))
(l:unit -> PURE b pre) (qcs:state -> b -> GTot (quickCodes a cs)) (mods:mods_t)
(k:state -> a -> Type0) (s0:state)
: Ghost b
(requires
(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)))
(ensures fun g -> (wp cs (qcs s0 g) mods k s0))
=
l ()
*)
let rec wp_sound #a cs qcs mods k s0 =
let qcs0 = qcs in
match qcs with
| QEmpty g ->
update_state_mods_refl mods s0;
let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g)
| QSeq _ _ qc qcs ->
let QProc _ _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Seq cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs qcs mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QBind _ _ qc qcs ->
let QProc c' _ wp1' proof = qc in
let c::cs = cs in
let k' = wp_Bind cs qcs mods k in
let (sM, fM, gM) = proof s0 k' in
let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
update_state_mods_weaken qc.mods mods sM s0;
update_state_mods_trans mods s0 sM sN;
(sN, fN', gN)
| QGetState f ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QPURE r msg pre l qcs' ->
call_QPURE r msg pre l qcs' mods k s0;
wp_sound cs qcs' mods k s0
(*
| QBindPURE b r msg pre l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = call_QBindPURE r msg pre l qcs' mods k s0 in
let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
*)
| QLemma _ _ pre post l qcs' ->
l ();
wp_sound cs qcs' mods k s0
| QGhost b _ _ pre post l qcs' ->
let c::cs = cs in
let (sM, fM) = va_lemma_empty_total s0 [] in
let g = l () in
let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in
let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in
(sN, fN', gN)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in
wp_sound cs qcs mods k s0
let qblock_proof #a #cs qcs mods s0 k =
wp_sound cs (qcs s0) mods k s0
let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
if b then
(
let (sM, f0, g) = QProc?.proof qc1 s0 k in
update_state_mods_weaken qc1.mods mods sM s0;
(sM, f0, g)
)
else
(
let (sM, f0, g) = QProc?.proof qc2 s0 k in
update_state_mods_weaken qc2.mods mods sM s0;
(sM, f0, g)
) | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val 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
) | [] | Vale.PPC64LE.QuickCodes.qIf_proof | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.PPC64LE.QuickCodes.cmp ->
qc1: Vale.PPC64LE.QuickCode.quickCode a c1 ->
qc2: Vale.PPC64LE.QuickCode.quickCode a c2 ->
mods: Vale.PPC64LE.QuickCode.mods_t ->
s0: Vale.PPC64LE.Decls.va_state ->
k: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0)
-> Prims.Ghost ((Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) * a) | {
"end_col": 3,
"end_line": 276,
"start_col": 2,
"start_line": 251
} |
FStar.Pervasives.Lemma | val update_state_mods_to1 (mods: mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s)) | [
{
"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
}
] | false | let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| r::mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_:squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2 | val update_state_mods_to1 (mods: mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s))
let rec update_state_mods_to1 (mods: mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = | false | null | true | match mods with
| [] -> ()
| r :: mods' ->
let b = r =!= m0 \/ state_mod_eq m0 s s' in
let goal (_: squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in
let l1 (_: squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in
let l2 (_: squash (~b)) : Lemma (goal ()) = () in
FStar.Classical.or_elim #b #(~b) #goal l1 l2 | {
"checked_file": "Vale.PPC64LE.QuickCodes.fst.checked",
"dependencies": [
"Vale.PPC64LE.Stack_Sems.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.QuickCodes.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.State.state",
"Vale.PPC64LE.QuickCode.mod_t",
"Prims.list",
"FStar.Classical.or_elim",
"Prims.l_not",
"Prims.squash",
"Prims.unit",
"Prims.l_True",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.PPC64LE.QuickCodes.update_state_mods_to1",
"Prims.l_or",
"Vale.PPC64LE.QuickCodes.state_mod_eq",
"Vale.PPC64LE.QuickCode.update_state_mods",
"Prims.logical",
"Prims.eq2",
"Prims.b2t",
"Vale.PPC64LE.QuickCodes.mods_contains1"
] | [] | module Vale.PPC64LE.QuickCodes
open FStar.Mul
open FStar.Range
open Vale.Arch.HeapImpl
module Map16 = Vale.Lib.Map16
friend Vale.PPC64LE.Stack_Sems
#reset-options "--initial_ifuel 1 --z3rlimit 30"
let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma
(requires True) (ensures label r msg p ==> p)
= ()
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
let rec empty_list_is_small #a x =
match x with
| [] -> ()
| h::t -> empty_list_is_small t
let state_mod_eq (m:mod_t) (s1 s2:state) =
match m with
| Mod_None -> True
| Mod_ok -> s1.ok == s2.ok
| Mod_reg r -> eval_reg r s1 == eval_reg r s2
| Mod_vec v -> eval_vec v s1 == eval_vec v s2
| Mod_cr0 -> s1.cr0 == s2.cr0
| Mod_xer -> s1.xer == s2.xer
| Mod_mem -> (coerce s1.ms_heap).vf_heap == (coerce s2.ms_heap).vf_heap
| Mod_mem_layout -> (coerce s1.ms_heap).vf_layout == (coerce s2.ms_heap).vf_layout
| Mod_mem_heaplet n -> Map16.sel (coerce s1.ms_heap).vf_heaplets n == Map16.sel (coerce s2.ms_heap).vf_heaplets n
| Mod_stack -> s1.ms_stack == s2.ms_stack
| Mod_stackTaint -> s1.ms_stackTaint == s2.ms_stackTaint
let rec update_state_mods_refl (mods:mods_t) (s:state) : Lemma
(ensures state_eq (update_state_mods mods s s) s)
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_refl mods s
let rec update_state_mods_not1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires not (mods_contains1 mods m0))
(ensures state_mod_eq m0 s (update_state_mods mods s' s))
=
match mods with
| [] -> ()
| _::mods -> update_state_mods_not1 mods s' s m0
let update_state_mods_from1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires state_mod_eq m0 s' (update_state_mods mods s' s))
(ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
=
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
let rec update_state_mods_to1 (mods:mods_t) (s' s:state) (m0:mod_t) : Lemma
(requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s)) | false | false | Vale.PPC64LE.QuickCodes.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_state_mods_to1 (mods: mods_t) (s' s: state) (m0: mod_t)
: Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s')
(ensures state_mod_eq m0 s' (update_state_mods mods s' s)) | [
"recursion"
] | Vale.PPC64LE.QuickCodes.update_state_mods_to1 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mods: Vale.PPC64LE.QuickCode.mods_t ->
s': Vale.PPC64LE.State.state ->
s: Vale.PPC64LE.State.state ->
m0: Vale.PPC64LE.QuickCode.mod_t
-> FStar.Pervasives.Lemma
(requires
Vale.PPC64LE.QuickCodes.mods_contains1 mods m0 \/
Vale.PPC64LE.QuickCodes.state_mod_eq m0 s s')
(ensures
Vale.PPC64LE.QuickCodes.state_mod_eq m0
s'
(Vale.PPC64LE.QuickCode.update_state_mods mods s' s)) | {
"end_col": 50,
"end_line": 67,
"start_col": 2,
"start_line": 60
} |
FStar.Pervasives.Lemma | val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end | val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f = | false | null | true | let f0, f1, f2, f3 = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0
then ()
else
(Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f)) | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Hacl.Spec.K256.Scalar.qelem4",
"Lib.IntTypes.uint64",
"Prims.op_AmpAmp",
"Prims.op_Equality",
"Prims.int",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.bool",
"Prims._assert",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.pow2",
"Hacl.Spec.K256.Scalar.qas_nat4",
"Prims.unit",
"FStar.Math.Lemmas.pow2_lt_compat",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.eq2"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128)) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128)) | [] | Hacl.Spec.K256.Scalar.Lemmas.is_qelem_lt_pow2_128_vartime4_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Spec.K256.Scalar.qelem4
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.K256.Scalar.is_qelem_lt_pow2_128_vartime4 f ==
(Hacl.Spec.K256.Scalar.qas_nat4 f < Prims.pow2 128)) | {
"end_col": 39,
"end_line": 80,
"start_col": 43,
"start_line": 73
} |
FStar.Pervasives.Lemma | val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256) | val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c = | false | null | true | Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256) | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Math.Lemmas.small_div",
"Prims.unit",
"FStar.Math.Lemmas.lemma_div_plus"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c) | [] | Hacl.Spec.K256.Scalar.Lemmas.lemma_get_carry_from_bn_add | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | r: Prims.nat{r < Prims.pow2 256} -> c: Prims.nat
-> FStar.Pervasives.Lemma (ensures (r + c * Prims.pow2 256) / Prims.pow2 256 = c) | {
"end_col": 36,
"end_line": 113,
"start_col": 2,
"start_line": 112
} |
FStar.Pervasives.Lemma | val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2 | val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 = | false | null | true | let a0, a1, a2, a3 = f1 in
let b0, b1, b2, b3 = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2 | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Hacl.Spec.K256.Scalar.qelem4",
"Lib.IntTypes.uint64",
"Hacl.Spec.Bignum.Definitions.bn_eval_inj",
"Lib.IntTypes.U64",
"Prims.unit",
"Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_is_qas_nat",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.Sequence.create4"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3)) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3)) | [] | Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_inj | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f1: Hacl.Spec.K256.Scalar.qelem4 -> f2: Hacl.Spec.K256.Scalar.qelem4
-> FStar.Pervasives.Lemma
(requires Hacl.Spec.K256.Scalar.qas_nat4 f1 = Hacl.Spec.K256.Scalar.qas_nat4 f2)
(ensures
(let _ = f1 in
(let FStar.Pervasives.Native.Mktuple4 #_ #_ #_ #_ a0 a1 a2 a3 = _ in
let _ = f2 in
(let FStar.Pervasives.Native.Mktuple4 #_ #_ #_ #_ b0 b1 b2 b3 = _ in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3)
<:
Type0)
<:
Type0)) | {
"end_col": 26,
"end_line": 43,
"start_col": 24,
"start_line": 36
} |
FStar.Pervasives.Lemma | val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_pow2_256_minus_q_lt_lemma p a =
Math.Lemmas.lemma_mult_lt_right (pow2 256 - S.q) a (pow2 p);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.lemma_mult_lt_left (pow2 p) (pow2 256 - S.q) (pow2 129);
Math.Lemmas.pow2_plus p 129 | val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129))
let mul_pow2_256_minus_q_lt_lemma p a = | false | null | true | Math.Lemmas.lemma_mult_lt_right (pow2 256 - S.q) a (pow2 p);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.lemma_mult_lt_left (pow2 p) (pow2 256 - S.q) (pow2 129);
Math.Lemmas.pow2_plus p 129 | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Math.Lemmas.pow2_plus",
"Prims.unit",
"FStar.Math.Lemmas.lemma_mult_lt_left",
"Prims.op_Subtraction",
"Spec.K256.PointOps.q",
"FStar.Pervasives.assert_norm",
"FStar.Math.Lemmas.lemma_mult_lt_right"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end
val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c
val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q))
let mul_pow2_256_minus_q_lemma len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
assert_norm (v t0 + v t1 * pow2 64 = pow2 256 - S.q - pow2 128);
let t01 = create2 t0 t1 in
SD.bn_eval_unfold_i t01 2;
SD.bn_eval_unfold_i t01 1;
SD.bn_eval0 t01;
assert (SD.bn_v t01 = pow2 256 - S.q - pow2 128);
let m0 = SB.bn_mul a t01 in // a * t01
SB.bn_mul_lemma a t01;
assert (SD.bn_v m0 == SD.bn_v a * SD.bn_v t01);
let m10 = create resLen (u64 0) in
let m1 = update_sub m10 2 len a in // a * t2 * pow2 128
SD.bn_update_sub_eval m10 a 2;
assert (SD.bn_v m1 = SD.bn_v m10 - SD.bn_v (sub m10 2 len) * pow2 128 + SD.bn_v a * pow2 128);
SD.bn_eval_zeroes #U64 resLen resLen;
eq_intro (sub m10 2 len) (create len (u64 0));
SD.bn_eval_zeroes #U64 len len;
assert (SD.bn_v m1 = SD.bn_v a * pow2 128);
let c, m2 = SB.bn_add m1 m0 in // a * SECP256K1_N_C
SB.bn_add_lemma m1 m0;
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v m1 + SD.bn_v m0);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * pow2 128 + SD.bn_v a * SD.bn_v t01);
Math.Lemmas.distributivity_add_right (SD.bn_v a) (pow2 128) (SD.bn_v t01);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * (pow2 256 - S.q))
val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129)) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129)) | [] | Hacl.Spec.K256.Scalar.Lemmas.mul_pow2_256_minus_q_lt_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Prims.nat -> a: Prims.nat{a < Prims.pow2 p}
-> FStar.Pervasives.Lemma
(ensures a * (Prims.pow2 256 - Spec.K256.PointOps.q) < Prims.pow2 (p + 129)) | {
"end_col": 29,
"end_line": 203,
"start_col": 2,
"start_line": 200
} |
FStar.Pervasives.Lemma | val lemma_b_pow2_256_plus_a_modq_lseq: len:size_nat{4 <= len} -> a:lseq uint64 len ->
Lemma (SD.bn_v a % S.q == (SD.bn_v (sub a 4 (len - 4)) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4)) % S.q) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_b_pow2_256_plus_a_modq_lseq len a =
lemma_b_pow2_256_plus_a_modq (SD.bn_v (sub a 0 4)) (SD.bn_v (sub a 4 (len - 4)));
SD.bn_eval_split_i a 4 | val lemma_b_pow2_256_plus_a_modq_lseq: len:size_nat{4 <= len} -> a:lseq uint64 len ->
Lemma (SD.bn_v a % S.q == (SD.bn_v (sub a 4 (len - 4)) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4)) % S.q)
let lemma_b_pow2_256_plus_a_modq_lseq len a = | false | null | true | lemma_b_pow2_256_plus_a_modq (SD.bn_v (sub a 0 4)) (SD.bn_v (sub a 4 (len - 4)));
SD.bn_eval_split_i a 4 | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Hacl.Spec.Bignum.Definitions.bn_eval_split_i",
"Lib.IntTypes.U64",
"Prims.unit",
"Hacl.Spec.K256.Scalar.Lemmas.lemma_b_pow2_256_plus_a_modq",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Lib.Sequence.sub",
"Prims.op_Subtraction"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end
val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c
val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q))
let mul_pow2_256_minus_q_lemma len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
assert_norm (v t0 + v t1 * pow2 64 = pow2 256 - S.q - pow2 128);
let t01 = create2 t0 t1 in
SD.bn_eval_unfold_i t01 2;
SD.bn_eval_unfold_i t01 1;
SD.bn_eval0 t01;
assert (SD.bn_v t01 = pow2 256 - S.q - pow2 128);
let m0 = SB.bn_mul a t01 in // a * t01
SB.bn_mul_lemma a t01;
assert (SD.bn_v m0 == SD.bn_v a * SD.bn_v t01);
let m10 = create resLen (u64 0) in
let m1 = update_sub m10 2 len a in // a * t2 * pow2 128
SD.bn_update_sub_eval m10 a 2;
assert (SD.bn_v m1 = SD.bn_v m10 - SD.bn_v (sub m10 2 len) * pow2 128 + SD.bn_v a * pow2 128);
SD.bn_eval_zeroes #U64 resLen resLen;
eq_intro (sub m10 2 len) (create len (u64 0));
SD.bn_eval_zeroes #U64 len len;
assert (SD.bn_v m1 = SD.bn_v a * pow2 128);
let c, m2 = SB.bn_add m1 m0 in // a * SECP256K1_N_C
SB.bn_add_lemma m1 m0;
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v m1 + SD.bn_v m0);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * pow2 128 + SD.bn_v a * SD.bn_v t01);
Math.Lemmas.distributivity_add_right (SD.bn_v a) (pow2 128) (SD.bn_v t01);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * (pow2 256 - S.q))
val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129))
let mul_pow2_256_minus_q_lt_lemma p a =
Math.Lemmas.lemma_mult_lt_right (pow2 256 - S.q) a (pow2 p);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.lemma_mult_lt_left (pow2 p) (pow2 256 - S.q) (pow2 129);
Math.Lemmas.pow2_plus p 129
val carry_is_zero (c d e a:nat) : Lemma
(requires
a < pow2 d /\ e < pow2 d /\
c * pow2 d + e = a)
(ensures c = 0)
let carry_is_zero c d e a = ()
val mul_pow2_256_minus_q_add_lemma:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> Lemma
(requires SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma len resLen d a e =
let c0, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
mul_pow2_256_minus_q_lemma len resLen a;
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
mul_pow2_256_minus_q_lt_lemma d (SD.bn_v a);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (d + 129));
Math.Lemmas.pow2_lt_compat (64 * resLen) (d + 129);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (64 * resLen));
SD.bn_eval_bound m resLen;
assert (SD.bn_v m < pow2 (64 * resLen));
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) (SD.bn_v a * (pow2 256 - S.q));
assert (v c0 = 0 /\ SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
let c1, res = SB.bn_add m e in // e + a * SECP256K1_N_C
SB.bn_add_lemma m e;
assert (v c1 * pow2 (64 * resLen) + SD.bn_v res == SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e);
SD.bn_eval_bound e 4;
assert (SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)
val mul_pow2_256_minus_q_add_lemma_carry_is_zero:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> f:nat -> Lemma
(requires
SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen /\
256 <= f /\ d + 129 <= f /\ f + 1 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
v c = 0 /\ SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma_carry_is_zero len resLen d a e f =
let c0, m = mul_pow2_256_minus_q_lseq_add len resLen a e in
mul_pow2_256_minus_q_add_lemma len resLen d a e;
let rhs_m = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e in
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = rhs_m);
assert (rhs_m < pow2 (d + 129) + pow2 256);
Math.Lemmas.pow2_le_compat f 256;
Math.Lemmas.pow2_le_compat f (d + 129);
Math.Lemmas.pow2_double_sum f;
assert (rhs_m < pow2 (f + 1));
Math.Lemmas.pow2_lt_compat (64 * resLen) (f + 1);
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) rhs_m;
assert (v c0 = 0 /\ SD.bn_v m = rhs_m)
val lemma_m_bound: m:lseq uint64 7 -> Lemma
(requires SD.bn_v m < pow2 385 + pow2 256)
(ensures SD.bn_v (sub m 4 3) < pow2 130)
let lemma_m_bound m =
Math.Lemmas.pow2_lt_compat 385 256;
Math.Lemmas.pow2_double_sum 385;
SD.bn_eval_split_i m 4;
assert (SD.bn_v m - SD.bn_v (sub m 0 4) = pow2 256 * SD.bn_v (sub m 4 3));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub m 4 3)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v m - SD.bn_v (sub m 0 4)) 386 256;
assert (SD.bn_v (sub m 4 3) < pow2 130)
val lemma_p_bound: p:lseq uint64 5 -> Lemma
(requires SD.bn_v p < pow2 259 + pow2 256)
(ensures SD.bn_v (sub p 4 1) < pow2 4)
let lemma_p_bound p =
Math.Lemmas.pow2_lt_compat 259 256;
Math.Lemmas.pow2_double_sum 259;
SD.bn_eval_split_i p 4;
assert (SD.bn_v p - SD.bn_v (sub p 0 4) = pow2 256 * SD.bn_v (sub p 4 1));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub p 4 1)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v p - SD.bn_v (sub p 0 4)) 260 256;
assert (SD.bn_v (sub p 4 1) < pow2 4)
val mod_lseq_before_final_lemma_aux: a:lseq uint64 8 -> Lemma
(let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
v c0 = 0 /\ SD.bn_v m = rhs_a /\
v c1 = 0 /\ SD.bn_v p = rhs_m /\
v c2 * pow2 256 + SD.bn_v r = rhs_p /\ rhs_p < pow2 133 + pow2 256)
let mod_lseq_before_final_lemma_aux a =
let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
SD.bn_eval_bound (sub a 4 4) 4;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 4 7 256 (sub a 4 4) (sub a 0 4) 385;
assert (v c0 = 0 /\ SD.bn_v m = rhs_a /\ rhs_a < pow2 385 + pow2 256);
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
lemma_m_bound m;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 3 5 130 (sub m 4 3) (sub m 0 4) 259;
assert (v c1 = 0 /\ SD.bn_v p = rhs_m); ///\ rhs_m < pow2 259 + pow2 256);
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
lemma_p_bound p;
mul_pow2_256_minus_q_add_lemma 1 4 4 (sub p 4 1) (sub p 0 4);
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
assert (v c2 * pow2 256 + SD.bn_v r = rhs_p);
assert (rhs_p < pow2 133 + pow2 256)
val lemma_b_pow2_256_plus_a_modq (a b: nat) :
Lemma ((b * pow2 256 + a) % S.q = (b * (pow2 256 - S.q) + a) % S.q)
let lemma_b_pow2_256_plus_a_modq a b =
calc (==) {
(b * (pow2 256 - S.q) + a) % S.q;
(==) { Math.Lemmas.distributivity_sub_right b (pow2 256) S.q }
(b * pow2 256 - b * S.q + a) % S.q;
(==) { Math.Lemmas.lemma_mod_sub (b * pow2 256 + a) S.q b }
(b * pow2 256 + a) % S.q;
}
val lemma_b_pow2_256_plus_a_modq_lseq: len:size_nat{4 <= len} -> a:lseq uint64 len ->
Lemma (SD.bn_v a % S.q == (SD.bn_v (sub a 4 (len - 4)) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4)) % S.q) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_b_pow2_256_plus_a_modq_lseq: len:size_nat{4 <= len} -> a:lseq uint64 len ->
Lemma (SD.bn_v a % S.q == (SD.bn_v (sub a 4 (len - 4)) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4)) % S.q) | [] | Hacl.Spec.K256.Scalar.Lemmas.lemma_b_pow2_256_plus_a_modq_lseq | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Lib.IntTypes.size_nat{4 <= len} -> a: Lib.Sequence.lseq Lib.IntTypes.uint64 len
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Bignum.Definitions.bn_v a % Spec.K256.PointOps.q ==
(Hacl.Spec.Bignum.Definitions.bn_v (Lib.Sequence.sub a 4 (len - 4)) *
(Prims.pow2 256 - Spec.K256.PointOps.q) +
Hacl.Spec.Bignum.Definitions.bn_v (Lib.Sequence.sub a 0 4)) %
Spec.K256.PointOps.q) | {
"end_col": 24,
"end_line": 348,
"start_col": 2,
"start_line": 347
} |
FStar.Pervasives.Lemma | val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q) | val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f = | false | null | true | assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 + 0xfffffffffffffffe * pow2 128 +
0xffffffffffffffff * pow2 192 =
S.q) | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Hacl.Spec.K256.Scalar.qelem4",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.pow2",
"Spec.K256.PointOps.q",
"Prims.unit"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q)) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q)) | [] | Hacl.Spec.K256.Scalar.Lemmas.is_qelem_lt_q_vartime4_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Spec.K256.Scalar.qelem4
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.K256.Scalar.is_qelem_lt_q_vartime4 f ==
(Hacl.Spec.K256.Scalar.qas_nat4 f < Spec.K256.PointOps.q)) | {
"end_col": 72,
"end_line": 55,
"start_col": 2,
"start_line": 54
} |
FStar.Pervasives.Lemma | val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2) | val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f = | false | null | true | assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 + 0xffffffffffffffff * pow2 128 +
0x7fffffffffffffff * pow2 192 =
S.q / 2) | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Hacl.Spec.K256.Scalar.qelem4",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.pow2",
"Prims.op_Division",
"Spec.K256.PointOps.q",
"Prims.unit"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2)) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2)) | [] | Hacl.Spec.K256.Scalar.Lemmas.is_qelem_le_q_halved_vartime4_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Spec.K256.Scalar.qelem4
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.K256.Scalar.is_qelem_le_q_halved_vartime4 f ==
(Hacl.Spec.K256.Scalar.qas_nat4 f <= Spec.K256.PointOps.q / 2)) | {
"end_col": 76,
"end_line": 61,
"start_col": 2,
"start_line": 60
} |
FStar.Pervasives.Lemma | val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2 | val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 = | false | null | true | if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2 | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Hacl.Spec.K256.Scalar.qelem4",
"Prims.op_Equality",
"Prims.int",
"Hacl.Spec.K256.Scalar.qas_nat4",
"Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_inj",
"Prims.bool",
"Prims.unit"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2)) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2)) | [] | Hacl.Spec.K256.Scalar.Lemmas.is_qelem_eq_vartime4_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f1: Hacl.Spec.K256.Scalar.qelem4 -> f2: Hacl.Spec.K256.Scalar.qelem4
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.K256.Scalar.is_qelem_eq_vartime4 f1 f2 ==
(Hacl.Spec.K256.Scalar.qas_nat4 f1 = Hacl.Spec.K256.Scalar.qas_nat4 f2)) | {
"end_col": 54,
"end_line": 66,
"start_col": 2,
"start_line": 66
} |
FStar.Pervasives.Lemma | val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3])) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f | val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f = | false | null | true | SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Hacl.Spec.K256.Scalar.qelem_lseq",
"Hacl.Spec.Bignum.Definitions.bn_eval0",
"Lib.IntTypes.U64",
"Prims.unit",
"Hacl.Spec.Bignum.Definitions.bn_eval_unfold_i"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3])) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3])) | [] | Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_is_qas_nat | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Spec.K256.Scalar.qelem_lseq
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Bignum.Definitions.bn_v f ==
Hacl.Spec.K256.Scalar.qas_nat4 (f.[ 0 ], f.[ 1 ], f.[ 2 ], f.[ 3 ])) | {
"end_col": 15,
"end_line": 26,
"start_col": 2,
"start_line": 22
} |
FStar.Pervasives.Lemma | val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end | val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b = | false | null | true | let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q
then
(assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0))
else
(assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1)) | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"Spec.K256.PointOps.q",
"Prims._assert",
"Prims.op_Equality",
"Prims.int",
"Prims.unit",
"FStar.Math.Lemmas.small_div",
"Prims.op_Subtraction",
"Prims.op_Addition",
"FStar.Pervasives.assert_norm",
"Prims.op_LessThanOrEqual",
"Prims.bool",
"Prims.op_Division",
"FStar.Math.Lemmas.lemma_div_le",
"FStar.Math.Lemmas.cancel_mul_div"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1)) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1)) | [] | Hacl.Spec.K256.Scalar.Lemmas.lemma_check_overflow | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Prims.nat{b < Prims.pow2 256}
-> FStar.Pervasives.Lemma
(ensures
(let overflow = (b + (Prims.pow2 256 - Spec.K256.PointOps.q)) / Prims.pow2 256 in
overflow =
(match b < Spec.K256.PointOps.q with
| true -> 0
| _ -> 1))) | {
"end_col": 30,
"end_line": 105,
"start_col": 28,
"start_line": 87
} |
FStar.Pervasives.Lemma | val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_short_lseq_lemma a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c | val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma a = | false | null | true | let t0, t1, t2, t3 = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Hacl.Spec.K256.Scalar.qelem_lseq",
"Lib.IntTypes.uint64",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.K256.Scalar.Lemmas.mod_short_lseq_lemma_aux",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.K256.PointOps.q",
"Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_is_qas_nat",
"Prims.b2t",
"Prims.op_Equality",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Hacl.Spec.Bignum.bn_add_lemma",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.bn_add",
"Lib.Sequence.lseq",
"Hacl.Spec.Bignum.Definitions.limb",
"Lib.Sequence.create4",
"Hacl.Spec.K256.Scalar.qelem4",
"Hacl.Spec.K256.Scalar.make_pow2_256_minus_order_k256"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end
val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q) | [] | Hacl.Spec.K256.Scalar.Lemmas.mod_short_lseq_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.Spec.K256.Scalar.qelem_lseq
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.K256.Scalar.mod_short_lseq a) ==
Hacl.Spec.Bignum.Definitions.bn_v a % Spec.K256.PointOps.q) | {
"end_col": 34,
"end_line": 157,
"start_col": 28,
"start_line": 148
} |
FStar.Pervasives.Lemma | val mul_pow2_256_minus_q_add_lemma_carry_is_zero:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> f:nat -> Lemma
(requires
SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen /\
256 <= f /\ d + 129 <= f /\ f + 1 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
v c = 0 /\ SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_pow2_256_minus_q_add_lemma_carry_is_zero len resLen d a e f =
let c0, m = mul_pow2_256_minus_q_lseq_add len resLen a e in
mul_pow2_256_minus_q_add_lemma len resLen d a e;
let rhs_m = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e in
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = rhs_m);
assert (rhs_m < pow2 (d + 129) + pow2 256);
Math.Lemmas.pow2_le_compat f 256;
Math.Lemmas.pow2_le_compat f (d + 129);
Math.Lemmas.pow2_double_sum f;
assert (rhs_m < pow2 (f + 1));
Math.Lemmas.pow2_lt_compat (64 * resLen) (f + 1);
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) rhs_m;
assert (v c0 = 0 /\ SD.bn_v m = rhs_m) | val mul_pow2_256_minus_q_add_lemma_carry_is_zero:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> f:nat -> Lemma
(requires
SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen /\
256 <= f /\ d + 129 <= f /\ f + 1 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
v c = 0 /\ SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma_carry_is_zero len resLen d a e f = | false | null | true | let c0, m = mul_pow2_256_minus_q_lseq_add len resLen a e in
mul_pow2_256_minus_q_add_lemma len resLen d a e;
let rhs_m = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e in
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = rhs_m);
assert (rhs_m < pow2 (d + 129) + pow2 256);
Math.Lemmas.pow2_le_compat f 256;
Math.Lemmas.pow2_le_compat f (d + 129);
Math.Lemmas.pow2_double_sum f;
assert (rhs_m < pow2 (f + 1));
Math.Lemmas.pow2_lt_compat (64 * resLen) (f + 1);
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) rhs_m;
assert (v c0 = 0 /\ SD.bn_v m = rhs_m) | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Prims.nat",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"Prims._assert",
"Prims.op_Equality",
"Prims.int",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.unit",
"Hacl.Spec.K256.Scalar.Lemmas.carry_is_zero",
"FStar.Mul.op_Star",
"FStar.Math.Lemmas.pow2_lt_compat",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Math.Lemmas.pow2_double_sum",
"FStar.Math.Lemmas.pow2_le_compat",
"Prims.op_Subtraction",
"Spec.K256.PointOps.q",
"Hacl.Spec.K256.Scalar.Lemmas.mul_pow2_256_minus_q_add_lemma",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Hacl.Spec.K256.Scalar.mul_pow2_256_minus_q_lseq_add"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end
val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c
val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q))
let mul_pow2_256_minus_q_lemma len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
assert_norm (v t0 + v t1 * pow2 64 = pow2 256 - S.q - pow2 128);
let t01 = create2 t0 t1 in
SD.bn_eval_unfold_i t01 2;
SD.bn_eval_unfold_i t01 1;
SD.bn_eval0 t01;
assert (SD.bn_v t01 = pow2 256 - S.q - pow2 128);
let m0 = SB.bn_mul a t01 in // a * t01
SB.bn_mul_lemma a t01;
assert (SD.bn_v m0 == SD.bn_v a * SD.bn_v t01);
let m10 = create resLen (u64 0) in
let m1 = update_sub m10 2 len a in // a * t2 * pow2 128
SD.bn_update_sub_eval m10 a 2;
assert (SD.bn_v m1 = SD.bn_v m10 - SD.bn_v (sub m10 2 len) * pow2 128 + SD.bn_v a * pow2 128);
SD.bn_eval_zeroes #U64 resLen resLen;
eq_intro (sub m10 2 len) (create len (u64 0));
SD.bn_eval_zeroes #U64 len len;
assert (SD.bn_v m1 = SD.bn_v a * pow2 128);
let c, m2 = SB.bn_add m1 m0 in // a * SECP256K1_N_C
SB.bn_add_lemma m1 m0;
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v m1 + SD.bn_v m0);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * pow2 128 + SD.bn_v a * SD.bn_v t01);
Math.Lemmas.distributivity_add_right (SD.bn_v a) (pow2 128) (SD.bn_v t01);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * (pow2 256 - S.q))
val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129))
let mul_pow2_256_minus_q_lt_lemma p a =
Math.Lemmas.lemma_mult_lt_right (pow2 256 - S.q) a (pow2 p);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.lemma_mult_lt_left (pow2 p) (pow2 256 - S.q) (pow2 129);
Math.Lemmas.pow2_plus p 129
val carry_is_zero (c d e a:nat) : Lemma
(requires
a < pow2 d /\ e < pow2 d /\
c * pow2 d + e = a)
(ensures c = 0)
let carry_is_zero c d e a = ()
val mul_pow2_256_minus_q_add_lemma:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> Lemma
(requires SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma len resLen d a e =
let c0, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
mul_pow2_256_minus_q_lemma len resLen a;
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
mul_pow2_256_minus_q_lt_lemma d (SD.bn_v a);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (d + 129));
Math.Lemmas.pow2_lt_compat (64 * resLen) (d + 129);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (64 * resLen));
SD.bn_eval_bound m resLen;
assert (SD.bn_v m < pow2 (64 * resLen));
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) (SD.bn_v a * (pow2 256 - S.q));
assert (v c0 = 0 /\ SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
let c1, res = SB.bn_add m e in // e + a * SECP256K1_N_C
SB.bn_add_lemma m e;
assert (v c1 * pow2 (64 * resLen) + SD.bn_v res == SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e);
SD.bn_eval_bound e 4;
assert (SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)
val mul_pow2_256_minus_q_add_lemma_carry_is_zero:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> f:nat -> Lemma
(requires
SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen /\
256 <= f /\ d + 129 <= f /\ f + 1 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
v c = 0 /\ SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_pow2_256_minus_q_add_lemma_carry_is_zero:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> f:nat -> Lemma
(requires
SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen /\
256 <= f /\ d + 129 <= f /\ f + 1 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
v c = 0 /\ SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)) | [] | Hacl.Spec.K256.Scalar.Lemmas.mul_pow2_256_minus_q_add_lemma_carry_is_zero | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_nat ->
resLen: Lib.IntTypes.size_nat{2 + len <= resLen /\ 4 <= resLen} ->
d: Prims.nat ->
a: Lib.Sequence.lseq Lib.IntTypes.uint64 len ->
e: Lib.Sequence.lseq Lib.IntTypes.uint64 4 ->
f: Prims.nat
-> FStar.Pervasives.Lemma
(requires
Hacl.Spec.Bignum.Definitions.bn_v a < Prims.pow2 d /\ d + 129 < 64 * resLen /\ 256 <= f /\
d + 129 <= f /\ f + 1 < 64 * resLen)
(ensures
(let _ = Hacl.Spec.K256.Scalar.mul_pow2_256_minus_q_lseq_add len resLen a e in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ c res = _ in
Lib.IntTypes.v c * Prims.pow2 (64 * resLen) + Hacl.Spec.Bignum.Definitions.bn_v res =
Hacl.Spec.Bignum.Definitions.bn_v a * (Prims.pow2 256 - Spec.K256.PointOps.q) +
Hacl.Spec.Bignum.Definitions.bn_v e /\ Lib.IntTypes.v c = 0 /\
Hacl.Spec.Bignum.Definitions.bn_v a * (Prims.pow2 256 - Spec.K256.PointOps.q) +
Hacl.Spec.Bignum.Definitions.bn_v e <
Prims.pow2 (d + 129) + Prims.pow2 256)
<:
Type0)) | {
"end_col": 40,
"end_line": 266,
"start_col": 69,
"start_line": 254
} |
FStar.Pervasives.Lemma | val mul_pow2_256_minus_q_add_lemma:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> Lemma
(requires SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_pow2_256_minus_q_add_lemma len resLen d a e =
let c0, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
mul_pow2_256_minus_q_lemma len resLen a;
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
mul_pow2_256_minus_q_lt_lemma d (SD.bn_v a);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (d + 129));
Math.Lemmas.pow2_lt_compat (64 * resLen) (d + 129);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (64 * resLen));
SD.bn_eval_bound m resLen;
assert (SD.bn_v m < pow2 (64 * resLen));
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) (SD.bn_v a * (pow2 256 - S.q));
assert (v c0 = 0 /\ SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
let c1, res = SB.bn_add m e in // e + a * SECP256K1_N_C
SB.bn_add_lemma m e;
assert (v c1 * pow2 (64 * resLen) + SD.bn_v res == SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e);
SD.bn_eval_bound e 4;
assert (SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256) | val mul_pow2_256_minus_q_add_lemma:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> Lemma
(requires SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma len resLen d a e = | false | null | true | let c0, m = mul_pow2_256_minus_q_lseq len resLen a in
mul_pow2_256_minus_q_lemma len resLen a;
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
mul_pow2_256_minus_q_lt_lemma d (SD.bn_v a);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (d + 129));
Math.Lemmas.pow2_lt_compat (64 * resLen) (d + 129);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (64 * resLen));
SD.bn_eval_bound m resLen;
assert (SD.bn_v m < pow2 (64 * resLen));
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) (SD.bn_v a * (pow2 256 - S.q));
assert (v c0 = 0 /\ SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
let c1, res = SB.bn_add m e in
SB.bn_add_lemma m e;
assert (v c1 * pow2 (64 * resLen) + SD.bn_v res == SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e);
SD.bn_eval_bound e 4;
assert (SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256) | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Prims.nat",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims._assert",
"Prims.op_LessThan",
"FStar.Mul.op_Star",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.K256.PointOps.q",
"Prims.unit",
"Hacl.Spec.Bignum.Definitions.bn_eval_bound",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Hacl.Spec.Bignum.bn_add_lemma",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.bn_add",
"Prims.op_Equality",
"Hacl.Spec.K256.Scalar.Lemmas.carry_is_zero",
"FStar.Math.Lemmas.pow2_lt_compat",
"Hacl.Spec.K256.Scalar.Lemmas.mul_pow2_256_minus_q_lt_lemma",
"Hacl.Spec.K256.Scalar.Lemmas.mul_pow2_256_minus_q_lemma",
"Lib.IntTypes.int_t",
"Hacl.Spec.K256.Scalar.mul_pow2_256_minus_q_lseq"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end
val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c
val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q))
let mul_pow2_256_minus_q_lemma len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
assert_norm (v t0 + v t1 * pow2 64 = pow2 256 - S.q - pow2 128);
let t01 = create2 t0 t1 in
SD.bn_eval_unfold_i t01 2;
SD.bn_eval_unfold_i t01 1;
SD.bn_eval0 t01;
assert (SD.bn_v t01 = pow2 256 - S.q - pow2 128);
let m0 = SB.bn_mul a t01 in // a * t01
SB.bn_mul_lemma a t01;
assert (SD.bn_v m0 == SD.bn_v a * SD.bn_v t01);
let m10 = create resLen (u64 0) in
let m1 = update_sub m10 2 len a in // a * t2 * pow2 128
SD.bn_update_sub_eval m10 a 2;
assert (SD.bn_v m1 = SD.bn_v m10 - SD.bn_v (sub m10 2 len) * pow2 128 + SD.bn_v a * pow2 128);
SD.bn_eval_zeroes #U64 resLen resLen;
eq_intro (sub m10 2 len) (create len (u64 0));
SD.bn_eval_zeroes #U64 len len;
assert (SD.bn_v m1 = SD.bn_v a * pow2 128);
let c, m2 = SB.bn_add m1 m0 in // a * SECP256K1_N_C
SB.bn_add_lemma m1 m0;
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v m1 + SD.bn_v m0);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * pow2 128 + SD.bn_v a * SD.bn_v t01);
Math.Lemmas.distributivity_add_right (SD.bn_v a) (pow2 128) (SD.bn_v t01);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * (pow2 256 - S.q))
val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129))
let mul_pow2_256_minus_q_lt_lemma p a =
Math.Lemmas.lemma_mult_lt_right (pow2 256 - S.q) a (pow2 p);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.lemma_mult_lt_left (pow2 p) (pow2 256 - S.q) (pow2 129);
Math.Lemmas.pow2_plus p 129
val carry_is_zero (c d e a:nat) : Lemma
(requires
a < pow2 d /\ e < pow2 d /\
c * pow2 d + e = a)
(ensures c = 0)
let carry_is_zero c d e a = ()
val mul_pow2_256_minus_q_add_lemma:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> Lemma
(requires SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_pow2_256_minus_q_add_lemma:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> Lemma
(requires SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)) | [] | Hacl.Spec.K256.Scalar.Lemmas.mul_pow2_256_minus_q_add_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_nat ->
resLen: Lib.IntTypes.size_nat{2 + len <= resLen /\ 4 <= resLen} ->
d: Prims.nat ->
a: Lib.Sequence.lseq Lib.IntTypes.uint64 len ->
e: Lib.Sequence.lseq Lib.IntTypes.uint64 4
-> FStar.Pervasives.Lemma
(requires Hacl.Spec.Bignum.Definitions.bn_v a < Prims.pow2 d /\ d + 129 < 64 * resLen)
(ensures
(let _ = Hacl.Spec.K256.Scalar.mul_pow2_256_minus_q_lseq_add len resLen a e in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ c res = _ in
Lib.IntTypes.v c * Prims.pow2 (64 * resLen) + Hacl.Spec.Bignum.Definitions.bn_v res =
Hacl.Spec.Bignum.Definitions.bn_v a * (Prims.pow2 256 - Spec.K256.PointOps.q) +
Hacl.Spec.Bignum.Definitions.bn_v e /\
Hacl.Spec.Bignum.Definitions.bn_v a * (Prims.pow2 256 - Spec.K256.PointOps.q) +
Hacl.Spec.Bignum.Definitions.bn_v e <
Prims.pow2 (d + 129) + Prims.pow2 256)
<:
Type0)) | {
"end_col": 79,
"end_line": 241,
"start_col": 53,
"start_line": 223
} |
FStar.Pervasives.Lemma | val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_pow2_256_minus_q_lemma len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
assert_norm (v t0 + v t1 * pow2 64 = pow2 256 - S.q - pow2 128);
let t01 = create2 t0 t1 in
SD.bn_eval_unfold_i t01 2;
SD.bn_eval_unfold_i t01 1;
SD.bn_eval0 t01;
assert (SD.bn_v t01 = pow2 256 - S.q - pow2 128);
let m0 = SB.bn_mul a t01 in // a * t01
SB.bn_mul_lemma a t01;
assert (SD.bn_v m0 == SD.bn_v a * SD.bn_v t01);
let m10 = create resLen (u64 0) in
let m1 = update_sub m10 2 len a in // a * t2 * pow2 128
SD.bn_update_sub_eval m10 a 2;
assert (SD.bn_v m1 = SD.bn_v m10 - SD.bn_v (sub m10 2 len) * pow2 128 + SD.bn_v a * pow2 128);
SD.bn_eval_zeroes #U64 resLen resLen;
eq_intro (sub m10 2 len) (create len (u64 0));
SD.bn_eval_zeroes #U64 len len;
assert (SD.bn_v m1 = SD.bn_v a * pow2 128);
let c, m2 = SB.bn_add m1 m0 in // a * SECP256K1_N_C
SB.bn_add_lemma m1 m0;
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v m1 + SD.bn_v m0);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * pow2 128 + SD.bn_v a * SD.bn_v t01);
Math.Lemmas.distributivity_add_right (SD.bn_v a) (pow2 128) (SD.bn_v t01);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * (pow2 256 - S.q)) | val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q))
let mul_pow2_256_minus_q_lemma len resLen a = | false | null | true | let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
assert_norm (v t0 + v t1 * pow2 64 = pow2 256 - S.q - pow2 128);
let t01 = create2 t0 t1 in
SD.bn_eval_unfold_i t01 2;
SD.bn_eval_unfold_i t01 1;
SD.bn_eval0 t01;
assert (SD.bn_v t01 = pow2 256 - S.q - pow2 128);
let m0 = SB.bn_mul a t01 in
SB.bn_mul_lemma a t01;
assert (SD.bn_v m0 == SD.bn_v a * SD.bn_v t01);
let m10 = create resLen (u64 0) in
let m1 = update_sub m10 2 len a in
SD.bn_update_sub_eval m10 a 2;
assert (SD.bn_v m1 = SD.bn_v m10 - SD.bn_v (sub m10 2 len) * pow2 128 + SD.bn_v a * pow2 128);
SD.bn_eval_zeroes #U64 resLen resLen;
eq_intro (sub m10 2 len) (create len (u64 0));
SD.bn_eval_zeroes #U64 len len;
assert (SD.bn_v m1 = SD.bn_v a * pow2 128);
let c, m2 = SB.bn_add m1 m0 in
SB.bn_add_lemma m1 m0;
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v m1 + SD.bn_v m0);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * pow2 128 + SD.bn_v a * SD.bn_v t01);
Math.Lemmas.distributivity_add_right (SD.bn_v a) (pow2 128) (SD.bn_v t01);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * (pow2 256 - S.q)) | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims._assert",
"Prims.op_Equality",
"Prims.int",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Prims.pow2",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.op_Subtraction",
"Spec.K256.PointOps.q",
"Prims.unit",
"FStar.Math.Lemmas.distributivity_add_right",
"Hacl.Spec.Bignum.bn_add_lemma",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.bn_add",
"Hacl.Spec.Bignum.Definitions.bn_eval_zeroes",
"Lib.Sequence.eq_intro",
"Lib.Sequence.sub",
"Lib.Sequence.create",
"Lib.IntTypes.u64",
"Hacl.Spec.Bignum.Definitions.bn_update_sub_eval",
"Lib.IntTypes.int_t",
"Prims.l_and",
"Prims.eq2",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_or",
"Prims.op_LessThan",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.index",
"Lib.Sequence.update_sub",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Prims.l_imp",
"Hacl.Spec.Bignum.bn_mul_lemma",
"Hacl.Spec.Bignum.bn_mul",
"Hacl.Spec.Bignum.Definitions.bn_eval0",
"Hacl.Spec.Bignum.Definitions.bn_eval_unfold_i",
"Hacl.Spec.Bignum.Definitions.limb",
"Lib.Sequence.create2",
"FStar.Pervasives.assert_norm",
"Lib.IntTypes.range"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end
val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c
val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q)) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q)) | [] | Hacl.Spec.K256.Scalar.Lemmas.mul_pow2_256_minus_q_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_nat ->
resLen: Lib.IntTypes.size_nat{2 + len <= resLen} ->
a: Lib.Sequence.lseq Lib.IntTypes.uint64 len
-> FStar.Pervasives.Lemma
(ensures
(let _ = Hacl.Spec.K256.Scalar.mul_pow2_256_minus_q_lseq len resLen a in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ c res = _ in
Lib.IntTypes.v c * Prims.pow2 (64 * resLen) + Hacl.Spec.Bignum.Definitions.bn_v res =
Hacl.Spec.Bignum.Definitions.bn_v a * (Prims.pow2 256 - Spec.K256.PointOps.q))
<:
Type0)) | {
"end_col": 79,
"end_line": 193,
"start_col": 45,
"start_line": 164
} |
FStar.Pervasives.Lemma | val lemma_p_bound: p:lseq uint64 5 -> Lemma
(requires SD.bn_v p < pow2 259 + pow2 256)
(ensures SD.bn_v (sub p 4 1) < pow2 4) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_p_bound p =
Math.Lemmas.pow2_lt_compat 259 256;
Math.Lemmas.pow2_double_sum 259;
SD.bn_eval_split_i p 4;
assert (SD.bn_v p - SD.bn_v (sub p 0 4) = pow2 256 * SD.bn_v (sub p 4 1));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub p 4 1)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v p - SD.bn_v (sub p 0 4)) 260 256;
assert (SD.bn_v (sub p 4 1) < pow2 4) | val lemma_p_bound: p:lseq uint64 5 -> Lemma
(requires SD.bn_v p < pow2 259 + pow2 256)
(ensures SD.bn_v (sub p 4 1) < pow2 4)
let lemma_p_bound p = | false | null | true | Math.Lemmas.pow2_lt_compat 259 256;
Math.Lemmas.pow2_double_sum 259;
SD.bn_eval_split_i p 4;
assert (SD.bn_v p - SD.bn_v (sub p 0 4) = pow2 256 * SD.bn_v (sub p 4 1));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub p 4 1)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v p - SD.bn_v (sub p 0 4)) 260 256;
assert (SD.bn_v (sub p 4 1) < pow2 4) | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Prims._assert",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Lib.IntTypes.U64",
"Lib.Sequence.sub",
"Prims.pow2",
"Prims.unit",
"FStar.Math.Lemmas.lemma_div_lt",
"Prims.op_Subtraction",
"FStar.Math.Lemmas.cancel_mul_div",
"Prims.op_Equality",
"Prims.int",
"FStar.Mul.op_Star",
"Hacl.Spec.Bignum.Definitions.bn_eval_split_i",
"FStar.Math.Lemmas.pow2_double_sum",
"FStar.Math.Lemmas.pow2_lt_compat"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end
val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c
val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q))
let mul_pow2_256_minus_q_lemma len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
assert_norm (v t0 + v t1 * pow2 64 = pow2 256 - S.q - pow2 128);
let t01 = create2 t0 t1 in
SD.bn_eval_unfold_i t01 2;
SD.bn_eval_unfold_i t01 1;
SD.bn_eval0 t01;
assert (SD.bn_v t01 = pow2 256 - S.q - pow2 128);
let m0 = SB.bn_mul a t01 in // a * t01
SB.bn_mul_lemma a t01;
assert (SD.bn_v m0 == SD.bn_v a * SD.bn_v t01);
let m10 = create resLen (u64 0) in
let m1 = update_sub m10 2 len a in // a * t2 * pow2 128
SD.bn_update_sub_eval m10 a 2;
assert (SD.bn_v m1 = SD.bn_v m10 - SD.bn_v (sub m10 2 len) * pow2 128 + SD.bn_v a * pow2 128);
SD.bn_eval_zeroes #U64 resLen resLen;
eq_intro (sub m10 2 len) (create len (u64 0));
SD.bn_eval_zeroes #U64 len len;
assert (SD.bn_v m1 = SD.bn_v a * pow2 128);
let c, m2 = SB.bn_add m1 m0 in // a * SECP256K1_N_C
SB.bn_add_lemma m1 m0;
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v m1 + SD.bn_v m0);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * pow2 128 + SD.bn_v a * SD.bn_v t01);
Math.Lemmas.distributivity_add_right (SD.bn_v a) (pow2 128) (SD.bn_v t01);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * (pow2 256 - S.q))
val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129))
let mul_pow2_256_minus_q_lt_lemma p a =
Math.Lemmas.lemma_mult_lt_right (pow2 256 - S.q) a (pow2 p);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.lemma_mult_lt_left (pow2 p) (pow2 256 - S.q) (pow2 129);
Math.Lemmas.pow2_plus p 129
val carry_is_zero (c d e a:nat) : Lemma
(requires
a < pow2 d /\ e < pow2 d /\
c * pow2 d + e = a)
(ensures c = 0)
let carry_is_zero c d e a = ()
val mul_pow2_256_minus_q_add_lemma:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> Lemma
(requires SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma len resLen d a e =
let c0, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
mul_pow2_256_minus_q_lemma len resLen a;
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
mul_pow2_256_minus_q_lt_lemma d (SD.bn_v a);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (d + 129));
Math.Lemmas.pow2_lt_compat (64 * resLen) (d + 129);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (64 * resLen));
SD.bn_eval_bound m resLen;
assert (SD.bn_v m < pow2 (64 * resLen));
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) (SD.bn_v a * (pow2 256 - S.q));
assert (v c0 = 0 /\ SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
let c1, res = SB.bn_add m e in // e + a * SECP256K1_N_C
SB.bn_add_lemma m e;
assert (v c1 * pow2 (64 * resLen) + SD.bn_v res == SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e);
SD.bn_eval_bound e 4;
assert (SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)
val mul_pow2_256_minus_q_add_lemma_carry_is_zero:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> f:nat -> Lemma
(requires
SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen /\
256 <= f /\ d + 129 <= f /\ f + 1 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
v c = 0 /\ SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma_carry_is_zero len resLen d a e f =
let c0, m = mul_pow2_256_minus_q_lseq_add len resLen a e in
mul_pow2_256_minus_q_add_lemma len resLen d a e;
let rhs_m = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e in
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = rhs_m);
assert (rhs_m < pow2 (d + 129) + pow2 256);
Math.Lemmas.pow2_le_compat f 256;
Math.Lemmas.pow2_le_compat f (d + 129);
Math.Lemmas.pow2_double_sum f;
assert (rhs_m < pow2 (f + 1));
Math.Lemmas.pow2_lt_compat (64 * resLen) (f + 1);
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) rhs_m;
assert (v c0 = 0 /\ SD.bn_v m = rhs_m)
val lemma_m_bound: m:lseq uint64 7 -> Lemma
(requires SD.bn_v m < pow2 385 + pow2 256)
(ensures SD.bn_v (sub m 4 3) < pow2 130)
let lemma_m_bound m =
Math.Lemmas.pow2_lt_compat 385 256;
Math.Lemmas.pow2_double_sum 385;
SD.bn_eval_split_i m 4;
assert (SD.bn_v m - SD.bn_v (sub m 0 4) = pow2 256 * SD.bn_v (sub m 4 3));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub m 4 3)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v m - SD.bn_v (sub m 0 4)) 386 256;
assert (SD.bn_v (sub m 4 3) < pow2 130)
val lemma_p_bound: p:lseq uint64 5 -> Lemma
(requires SD.bn_v p < pow2 259 + pow2 256)
(ensures SD.bn_v (sub p 4 1) < pow2 4) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_p_bound: p:lseq uint64 5 -> Lemma
(requires SD.bn_v p < pow2 259 + pow2 256)
(ensures SD.bn_v (sub p 4 1) < pow2 4) | [] | Hacl.Spec.K256.Scalar.Lemmas.lemma_p_bound | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Lib.Sequence.lseq Lib.IntTypes.uint64 5
-> FStar.Pervasives.Lemma
(requires Hacl.Spec.Bignum.Definitions.bn_v p < Prims.pow2 259 + Prims.pow2 256)
(ensures Hacl.Spec.Bignum.Definitions.bn_v (Lib.Sequence.sub p 4 1) < Prims.pow2 4) | {
"end_col": 39,
"end_line": 294,
"start_col": 2,
"start_line": 288
} |
FStar.Pervasives.Lemma | val qmul_shift_384_lemma_eval_fits : l:lseq uint64 8 ->
Lemma (let res_b = SB.bn_rshift l 6 in
let res_b_padded = create 4 (u64 0) in
let res_b_padded = update_sub res_b_padded 0 2 res_b in
SD.bn_v res_b_padded < pow2 128 /\
SD.bn_v res_b_padded = SD.bn_v l / pow2 384) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qmul_shift_384_lemma_eval_fits l =
let res_b = SB.bn_rshift l 6 in
let res_b_padded = create 4 (u64 0) in
let res_b_padded = update_sub res_b_padded 0 2 res_b in
SD.bn_eval_update_sub 2 res_b 4;
assert (SD.bn_v res_b = SD.bn_v res_b_padded);
SB.bn_rshift_lemma l 6;
SD.bn_eval_bound res_b 2;
assert (SD.bn_v res_b_padded < pow2 128) | val qmul_shift_384_lemma_eval_fits : l:lseq uint64 8 ->
Lemma (let res_b = SB.bn_rshift l 6 in
let res_b_padded = create 4 (u64 0) in
let res_b_padded = update_sub res_b_padded 0 2 res_b in
SD.bn_v res_b_padded < pow2 128 /\
SD.bn_v res_b_padded = SD.bn_v l / pow2 384)
let qmul_shift_384_lemma_eval_fits l = | false | null | true | let res_b = SB.bn_rshift l 6 in
let res_b_padded = create 4 (u64 0) in
let res_b_padded = update_sub res_b_padded 0 2 res_b in
SD.bn_eval_update_sub 2 res_b 4;
assert (SD.bn_v res_b = SD.bn_v res_b_padded);
SB.bn_rshift_lemma l 6;
SD.bn_eval_bound res_b 2;
assert (SD.bn_v res_b_padded < pow2 128) | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Prims._assert",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Lib.IntTypes.U64",
"Prims.pow2",
"Prims.unit",
"Hacl.Spec.Bignum.Definitions.bn_eval_bound",
"Prims.op_Subtraction",
"Hacl.Spec.Bignum.bn_rshift_lemma",
"Prims.op_Equality",
"Prims.nat",
"Hacl.Spec.Bignum.Definitions.bn_eval_update_sub",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.l_and",
"Prims.eq2",
"Lib.Sequence.sub",
"Prims.l_Forall",
"Prims.l_or",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.index",
"Lib.Sequence.update_sub",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Lib.IntTypes.SEC",
"Prims.l_imp",
"Lib.Sequence.create",
"Lib.IntTypes.u64",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.bn_rshift"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end
val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c
val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q))
let mul_pow2_256_minus_q_lemma len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
assert_norm (v t0 + v t1 * pow2 64 = pow2 256 - S.q - pow2 128);
let t01 = create2 t0 t1 in
SD.bn_eval_unfold_i t01 2;
SD.bn_eval_unfold_i t01 1;
SD.bn_eval0 t01;
assert (SD.bn_v t01 = pow2 256 - S.q - pow2 128);
let m0 = SB.bn_mul a t01 in // a * t01
SB.bn_mul_lemma a t01;
assert (SD.bn_v m0 == SD.bn_v a * SD.bn_v t01);
let m10 = create resLen (u64 0) in
let m1 = update_sub m10 2 len a in // a * t2 * pow2 128
SD.bn_update_sub_eval m10 a 2;
assert (SD.bn_v m1 = SD.bn_v m10 - SD.bn_v (sub m10 2 len) * pow2 128 + SD.bn_v a * pow2 128);
SD.bn_eval_zeroes #U64 resLen resLen;
eq_intro (sub m10 2 len) (create len (u64 0));
SD.bn_eval_zeroes #U64 len len;
assert (SD.bn_v m1 = SD.bn_v a * pow2 128);
let c, m2 = SB.bn_add m1 m0 in // a * SECP256K1_N_C
SB.bn_add_lemma m1 m0;
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v m1 + SD.bn_v m0);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * pow2 128 + SD.bn_v a * SD.bn_v t01);
Math.Lemmas.distributivity_add_right (SD.bn_v a) (pow2 128) (SD.bn_v t01);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * (pow2 256 - S.q))
val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129))
let mul_pow2_256_minus_q_lt_lemma p a =
Math.Lemmas.lemma_mult_lt_right (pow2 256 - S.q) a (pow2 p);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.lemma_mult_lt_left (pow2 p) (pow2 256 - S.q) (pow2 129);
Math.Lemmas.pow2_plus p 129
val carry_is_zero (c d e a:nat) : Lemma
(requires
a < pow2 d /\ e < pow2 d /\
c * pow2 d + e = a)
(ensures c = 0)
let carry_is_zero c d e a = ()
val mul_pow2_256_minus_q_add_lemma:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> Lemma
(requires SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma len resLen d a e =
let c0, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
mul_pow2_256_minus_q_lemma len resLen a;
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
mul_pow2_256_minus_q_lt_lemma d (SD.bn_v a);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (d + 129));
Math.Lemmas.pow2_lt_compat (64 * resLen) (d + 129);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (64 * resLen));
SD.bn_eval_bound m resLen;
assert (SD.bn_v m < pow2 (64 * resLen));
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) (SD.bn_v a * (pow2 256 - S.q));
assert (v c0 = 0 /\ SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
let c1, res = SB.bn_add m e in // e + a * SECP256K1_N_C
SB.bn_add_lemma m e;
assert (v c1 * pow2 (64 * resLen) + SD.bn_v res == SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e);
SD.bn_eval_bound e 4;
assert (SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)
val mul_pow2_256_minus_q_add_lemma_carry_is_zero:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> f:nat -> Lemma
(requires
SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen /\
256 <= f /\ d + 129 <= f /\ f + 1 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
v c = 0 /\ SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma_carry_is_zero len resLen d a e f =
let c0, m = mul_pow2_256_minus_q_lseq_add len resLen a e in
mul_pow2_256_minus_q_add_lemma len resLen d a e;
let rhs_m = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e in
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = rhs_m);
assert (rhs_m < pow2 (d + 129) + pow2 256);
Math.Lemmas.pow2_le_compat f 256;
Math.Lemmas.pow2_le_compat f (d + 129);
Math.Lemmas.pow2_double_sum f;
assert (rhs_m < pow2 (f + 1));
Math.Lemmas.pow2_lt_compat (64 * resLen) (f + 1);
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) rhs_m;
assert (v c0 = 0 /\ SD.bn_v m = rhs_m)
val lemma_m_bound: m:lseq uint64 7 -> Lemma
(requires SD.bn_v m < pow2 385 + pow2 256)
(ensures SD.bn_v (sub m 4 3) < pow2 130)
let lemma_m_bound m =
Math.Lemmas.pow2_lt_compat 385 256;
Math.Lemmas.pow2_double_sum 385;
SD.bn_eval_split_i m 4;
assert (SD.bn_v m - SD.bn_v (sub m 0 4) = pow2 256 * SD.bn_v (sub m 4 3));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub m 4 3)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v m - SD.bn_v (sub m 0 4)) 386 256;
assert (SD.bn_v (sub m 4 3) < pow2 130)
val lemma_p_bound: p:lseq uint64 5 -> Lemma
(requires SD.bn_v p < pow2 259 + pow2 256)
(ensures SD.bn_v (sub p 4 1) < pow2 4)
let lemma_p_bound p =
Math.Lemmas.pow2_lt_compat 259 256;
Math.Lemmas.pow2_double_sum 259;
SD.bn_eval_split_i p 4;
assert (SD.bn_v p - SD.bn_v (sub p 0 4) = pow2 256 * SD.bn_v (sub p 4 1));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub p 4 1)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v p - SD.bn_v (sub p 0 4)) 260 256;
assert (SD.bn_v (sub p 4 1) < pow2 4)
val mod_lseq_before_final_lemma_aux: a:lseq uint64 8 -> Lemma
(let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
v c0 = 0 /\ SD.bn_v m = rhs_a /\
v c1 = 0 /\ SD.bn_v p = rhs_m /\
v c2 * pow2 256 + SD.bn_v r = rhs_p /\ rhs_p < pow2 133 + pow2 256)
let mod_lseq_before_final_lemma_aux a =
let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
SD.bn_eval_bound (sub a 4 4) 4;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 4 7 256 (sub a 4 4) (sub a 0 4) 385;
assert (v c0 = 0 /\ SD.bn_v m = rhs_a /\ rhs_a < pow2 385 + pow2 256);
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
lemma_m_bound m;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 3 5 130 (sub m 4 3) (sub m 0 4) 259;
assert (v c1 = 0 /\ SD.bn_v p = rhs_m); ///\ rhs_m < pow2 259 + pow2 256);
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
lemma_p_bound p;
mul_pow2_256_minus_q_add_lemma 1 4 4 (sub p 4 1) (sub p 0 4);
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
assert (v c2 * pow2 256 + SD.bn_v r = rhs_p);
assert (rhs_p < pow2 133 + pow2 256)
val lemma_b_pow2_256_plus_a_modq (a b: nat) :
Lemma ((b * pow2 256 + a) % S.q = (b * (pow2 256 - S.q) + a) % S.q)
let lemma_b_pow2_256_plus_a_modq a b =
calc (==) {
(b * (pow2 256 - S.q) + a) % S.q;
(==) { Math.Lemmas.distributivity_sub_right b (pow2 256) S.q }
(b * pow2 256 - b * S.q + a) % S.q;
(==) { Math.Lemmas.lemma_mod_sub (b * pow2 256 + a) S.q b }
(b * pow2 256 + a) % S.q;
}
val lemma_b_pow2_256_plus_a_modq_lseq: len:size_nat{4 <= len} -> a:lseq uint64 len ->
Lemma (SD.bn_v a % S.q == (SD.bn_v (sub a 4 (len - 4)) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4)) % S.q)
let lemma_b_pow2_256_plus_a_modq_lseq len a =
lemma_b_pow2_256_plus_a_modq (SD.bn_v (sub a 0 4)) (SD.bn_v (sub a 4 (len - 4)));
SD.bn_eval_split_i a 4
val mod_lseq_before_final_lemma: a:lseq uint64 8 ->
Lemma (let (c, res) = mod_lseq_before_final a in
v c * pow2 256 + SD.bn_v res < pow2 133 + pow2 256 /\
(v c * pow2 256 + SD.bn_v res) % S.q == SD.bn_v a % S.q)
let mod_lseq_before_final_lemma a =
let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
mod_lseq_before_final_lemma_aux a;
assert (v c0 = 0 /\ SD.bn_v m = rhs_a);
assert (v c1 = 0 /\ SD.bn_v p = rhs_m);
assert (v c2 * pow2 256 + SD.bn_v r = rhs_p);
assert (rhs_p < pow2 133 + pow2 256);
calc (==) { //(v c2 * pow2 256 + SD.bn_v r) % S.q;
rhs_p % S.q;
(==) { lemma_b_pow2_256_plus_a_modq_lseq 5 p }
SD.bn_v p % S.q;
(==) { }
rhs_m % S.q;
(==) { lemma_b_pow2_256_plus_a_modq_lseq 7 m }
SD.bn_v m % S.q;
(==) { }
rhs_a % S.q;
(==) { lemma_b_pow2_256_plus_a_modq_lseq 8 a }
SD.bn_v a % S.q;
}
val mod_lseq_lemma: a:lseq uint64 8 -> Lemma (SD.bn_v (mod_lseq a) == SD.bn_v a % S.q)
let mod_lseq_lemma a =
let c0, r = mod_lseq_before_final a in
mod_lseq_before_final_lemma a;
assert ((v c0 * pow2 256 + SD.bn_v r) % S.q == SD.bn_v a % S.q);
assert (v c0 * pow2 256 + SD.bn_v r < pow2 256 + pow2 133);
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp = pow2 256 - S.q);
let c1, out = SB.bn_add r tmp in
SB.bn_add_lemma r tmp;
assert (v c1 * pow2 256 + SD.bn_v out = SD.bn_v r + pow2 256 - S.q);
Math.Lemmas.small_mod (v c0 + v c1) (pow2 64);
assert (v (c0 +. c1) == v c0 + v c1);
let mask = u64 0 -. (c0 +. c1) in
//let mask = u64 0 -. c1 in
let res = map2 (BB.mask_select mask) out r in
SD.bn_eval_bound r 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v r);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c1);
assert (v c1 = (if SD.bn_v r < S.q then 0 else 1));
if v c0 = 0 then begin
assert (SD.bn_v r % S.q == SD.bn_v a % S.q);
assert (res == mod_short_lseq r);
mod_short_lseq_lemma r;
assert (SD.bn_v res == SD.bn_v a % S.q) end
else begin // v c0 = 1 ==> v c1 = 0
assert ((pow2 256 + SD.bn_v r) % S.q == SD.bn_v a % S.q);
assert (v c1 * pow2 256 + SD.bn_v out = SD.bn_v r + pow2 256 - S.q);
assert (SD.bn_v r < pow2 133);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.pow2_lt_compat 133 129;
Math.Lemmas.pow2_double_sum 133;
assert (SD.bn_v r + pow2 256 - S.q < pow2 134);
Math.Lemmas.pow2_lt_compat 256 134;
carry_is_zero (v c1) 256 (SD.bn_v out) (SD.bn_v r + pow2 256 - S.q);
assert (v c1 = 0);
assert_norm (pow2 134 < S.q);
assert (SD.bn_v r + pow2 256 - S.q < S.q);
BB.lseq_mask_select_lemma out r mask;
assert (SD.bn_v res == SD.bn_v r + pow2 256 - S.q);
Math.Lemmas.lemma_mod_sub (pow2 256 + SD.bn_v r) S.q 1;
assert (SD.bn_v res % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v res) S.q end
val qmul_shift_383_mod_2_lemma : l:lseq uint64 8 ->
Lemma (v l.[5] / pow2 63 = SD.bn_v l / pow2 383 % 2)
let qmul_shift_383_mod_2_lemma l =
calc (==) {
v l.[5] / pow2 63;
(==) { SD.bn_eval_index l 5 }
SD.bn_v l / pow2 320 % pow2 64 / pow2 63;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (SD.bn_v l) 320 384 }
SD.bn_v l % pow2 384 / pow2 320 / pow2 63;
(==) { Math.Lemmas.division_multiplication_lemma (SD.bn_v l % pow2 384) (pow2 320) (pow2 63) }
SD.bn_v l % pow2 384 / (pow2 320 * pow2 63);
(==) { Math.Lemmas.pow2_plus 320 63 }
SD.bn_v l % pow2 384 / pow2 383;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (SD.bn_v l) 383 384 }
SD.bn_v l / pow2 383 % pow2 1;
(==) { assert_norm (pow2 1 = 2) }
SD.bn_v l / pow2 383 % 2;
}
val qmul_shift_384_lemma_eval_fits : l:lseq uint64 8 ->
Lemma (let res_b = SB.bn_rshift l 6 in
let res_b_padded = create 4 (u64 0) in
let res_b_padded = update_sub res_b_padded 0 2 res_b in
SD.bn_v res_b_padded < pow2 128 /\
SD.bn_v res_b_padded = SD.bn_v l / pow2 384) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qmul_shift_384_lemma_eval_fits : l:lseq uint64 8 ->
Lemma (let res_b = SB.bn_rshift l 6 in
let res_b_padded = create 4 (u64 0) in
let res_b_padded = update_sub res_b_padded 0 2 res_b in
SD.bn_v res_b_padded < pow2 128 /\
SD.bn_v res_b_padded = SD.bn_v l / pow2 384) | [] | Hacl.Spec.K256.Scalar.Lemmas.qmul_shift_384_lemma_eval_fits | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | l: Lib.Sequence.lseq Lib.IntTypes.uint64 8
-> FStar.Pervasives.Lemma
(ensures
(let res_b = Hacl.Spec.Bignum.bn_rshift l 6 in
let res_b_padded = Lib.Sequence.create 4 (Lib.IntTypes.u64 0) in
let res_b_padded = Lib.Sequence.update_sub res_b_padded 0 2 res_b in
Hacl.Spec.Bignum.Definitions.bn_v res_b_padded < Prims.pow2 128 /\
Hacl.Spec.Bignum.Definitions.bn_v res_b_padded =
Hacl.Spec.Bignum.Definitions.bn_v l / Prims.pow2 384)) | {
"end_col": 42,
"end_line": 476,
"start_col": 38,
"start_line": 467
} |
FStar.Pervasives.Lemma | val lemma_m_bound: m:lseq uint64 7 -> Lemma
(requires SD.bn_v m < pow2 385 + pow2 256)
(ensures SD.bn_v (sub m 4 3) < pow2 130) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_m_bound m =
Math.Lemmas.pow2_lt_compat 385 256;
Math.Lemmas.pow2_double_sum 385;
SD.bn_eval_split_i m 4;
assert (SD.bn_v m - SD.bn_v (sub m 0 4) = pow2 256 * SD.bn_v (sub m 4 3));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub m 4 3)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v m - SD.bn_v (sub m 0 4)) 386 256;
assert (SD.bn_v (sub m 4 3) < pow2 130) | val lemma_m_bound: m:lseq uint64 7 -> Lemma
(requires SD.bn_v m < pow2 385 + pow2 256)
(ensures SD.bn_v (sub m 4 3) < pow2 130)
let lemma_m_bound m = | false | null | true | Math.Lemmas.pow2_lt_compat 385 256;
Math.Lemmas.pow2_double_sum 385;
SD.bn_eval_split_i m 4;
assert (SD.bn_v m - SD.bn_v (sub m 0 4) = pow2 256 * SD.bn_v (sub m 4 3));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub m 4 3)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v m - SD.bn_v (sub m 0 4)) 386 256;
assert (SD.bn_v (sub m 4 3) < pow2 130) | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Prims._assert",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Lib.IntTypes.U64",
"Lib.Sequence.sub",
"Prims.pow2",
"Prims.unit",
"FStar.Math.Lemmas.lemma_div_lt",
"Prims.op_Subtraction",
"FStar.Math.Lemmas.cancel_mul_div",
"Prims.op_Equality",
"Prims.int",
"FStar.Mul.op_Star",
"Hacl.Spec.Bignum.Definitions.bn_eval_split_i",
"FStar.Math.Lemmas.pow2_double_sum",
"FStar.Math.Lemmas.pow2_lt_compat"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end
val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c
val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q))
let mul_pow2_256_minus_q_lemma len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
assert_norm (v t0 + v t1 * pow2 64 = pow2 256 - S.q - pow2 128);
let t01 = create2 t0 t1 in
SD.bn_eval_unfold_i t01 2;
SD.bn_eval_unfold_i t01 1;
SD.bn_eval0 t01;
assert (SD.bn_v t01 = pow2 256 - S.q - pow2 128);
let m0 = SB.bn_mul a t01 in // a * t01
SB.bn_mul_lemma a t01;
assert (SD.bn_v m0 == SD.bn_v a * SD.bn_v t01);
let m10 = create resLen (u64 0) in
let m1 = update_sub m10 2 len a in // a * t2 * pow2 128
SD.bn_update_sub_eval m10 a 2;
assert (SD.bn_v m1 = SD.bn_v m10 - SD.bn_v (sub m10 2 len) * pow2 128 + SD.bn_v a * pow2 128);
SD.bn_eval_zeroes #U64 resLen resLen;
eq_intro (sub m10 2 len) (create len (u64 0));
SD.bn_eval_zeroes #U64 len len;
assert (SD.bn_v m1 = SD.bn_v a * pow2 128);
let c, m2 = SB.bn_add m1 m0 in // a * SECP256K1_N_C
SB.bn_add_lemma m1 m0;
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v m1 + SD.bn_v m0);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * pow2 128 + SD.bn_v a * SD.bn_v t01);
Math.Lemmas.distributivity_add_right (SD.bn_v a) (pow2 128) (SD.bn_v t01);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * (pow2 256 - S.q))
val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129))
let mul_pow2_256_minus_q_lt_lemma p a =
Math.Lemmas.lemma_mult_lt_right (pow2 256 - S.q) a (pow2 p);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.lemma_mult_lt_left (pow2 p) (pow2 256 - S.q) (pow2 129);
Math.Lemmas.pow2_plus p 129
val carry_is_zero (c d e a:nat) : Lemma
(requires
a < pow2 d /\ e < pow2 d /\
c * pow2 d + e = a)
(ensures c = 0)
let carry_is_zero c d e a = ()
val mul_pow2_256_minus_q_add_lemma:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> Lemma
(requires SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma len resLen d a e =
let c0, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
mul_pow2_256_minus_q_lemma len resLen a;
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
mul_pow2_256_minus_q_lt_lemma d (SD.bn_v a);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (d + 129));
Math.Lemmas.pow2_lt_compat (64 * resLen) (d + 129);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (64 * resLen));
SD.bn_eval_bound m resLen;
assert (SD.bn_v m < pow2 (64 * resLen));
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) (SD.bn_v a * (pow2 256 - S.q));
assert (v c0 = 0 /\ SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
let c1, res = SB.bn_add m e in // e + a * SECP256K1_N_C
SB.bn_add_lemma m e;
assert (v c1 * pow2 (64 * resLen) + SD.bn_v res == SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e);
SD.bn_eval_bound e 4;
assert (SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)
val mul_pow2_256_minus_q_add_lemma_carry_is_zero:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> f:nat -> Lemma
(requires
SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen /\
256 <= f /\ d + 129 <= f /\ f + 1 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
v c = 0 /\ SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma_carry_is_zero len resLen d a e f =
let c0, m = mul_pow2_256_minus_q_lseq_add len resLen a e in
mul_pow2_256_minus_q_add_lemma len resLen d a e;
let rhs_m = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e in
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = rhs_m);
assert (rhs_m < pow2 (d + 129) + pow2 256);
Math.Lemmas.pow2_le_compat f 256;
Math.Lemmas.pow2_le_compat f (d + 129);
Math.Lemmas.pow2_double_sum f;
assert (rhs_m < pow2 (f + 1));
Math.Lemmas.pow2_lt_compat (64 * resLen) (f + 1);
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) rhs_m;
assert (v c0 = 0 /\ SD.bn_v m = rhs_m)
val lemma_m_bound: m:lseq uint64 7 -> Lemma
(requires SD.bn_v m < pow2 385 + pow2 256)
(ensures SD.bn_v (sub m 4 3) < pow2 130) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_m_bound: m:lseq uint64 7 -> Lemma
(requires SD.bn_v m < pow2 385 + pow2 256)
(ensures SD.bn_v (sub m 4 3) < pow2 130) | [] | Hacl.Spec.K256.Scalar.Lemmas.lemma_m_bound | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | m: Lib.Sequence.lseq Lib.IntTypes.uint64 7
-> FStar.Pervasives.Lemma
(requires Hacl.Spec.Bignum.Definitions.bn_v m < Prims.pow2 385 + Prims.pow2 256)
(ensures Hacl.Spec.Bignum.Definitions.bn_v (Lib.Sequence.sub m 4 3) < Prims.pow2 130) | {
"end_col": 41,
"end_line": 280,
"start_col": 2,
"start_line": 274
} |
FStar.Pervasives.Lemma | val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end | val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c = | false | null | true | assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q
then
(assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q)
else
(assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q) | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Hacl.Spec.K256.Scalar.qelem_lseq",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Spec.K256.PointOps.q",
"FStar.Math.Lemmas.small_mod",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.nat",
"Prims.bool",
"Prims.int",
"Prims.op_Modulus",
"FStar.Math.Lemmas.lemma_mod_sub",
"Prims.op_Subtraction",
"Prims.op_Addition",
"Prims.pow2",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Hacl.Spec.K256.Scalar.Lemmas.lemma_get_carry_from_bn_add",
"Hacl.Spec.K256.Scalar.Lemmas.lemma_check_overflow",
"Hacl.Spec.Bignum.Definitions.bn_eval_bound",
"Lib.Sequence.lseq",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Base.lseq_mask_select_lemma",
"Lib.IntTypes.ones_v",
"Prims.l_Forall",
"Prims.l_imp",
"Lib.Sequence.index",
"Hacl.Spec.Bignum.Base.mask_select",
"Lib.IntTypes.int_t",
"Lib.Sequence.map2",
"Lib.IntTypes.uint64",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.u64",
"FStar.Pervasives.assert_norm"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q) | [] | Hacl.Spec.K256.Scalar.Lemmas.mod_short_lseq_lemma_aux | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Hacl.Spec.K256.Scalar.qelem_lseq ->
out: Hacl.Spec.K256.Scalar.qelem_lseq ->
c: Hacl.Spec.Bignum.Base.carry Lib.IntTypes.U64
-> FStar.Pervasives.Lemma
(requires
Lib.IntTypes.v c * Prims.pow2 256 + Hacl.Spec.Bignum.Definitions.bn_v out =
Hacl.Spec.Bignum.Definitions.bn_v a + Prims.pow2 256 - Spec.K256.PointOps.q)
(ensures
Hacl.Spec.Bignum.Definitions.bn_v (Lib.Sequence.map2 (Hacl.Spec.Bignum.Base.mask_select (Lib.IntTypes.u64
0 -.
c))
out
a) ==
Hacl.Spec.Bignum.Definitions.bn_v a % Spec.K256.PointOps.q) | {
"end_col": 48,
"end_line": 142,
"start_col": 2,
"start_line": 121
} |
FStar.Pervasives.Lemma | val qmul_shift_384_lemma (a b:qelem_lseq) :
Lemma (let x = SD.bn_v a * SD.bn_v b / pow2 383 % 2 in
let res = SD.bn_v (qmul_shift_384 a b) in
res < S.q /\ res = SD.bn_v a * SD.bn_v b / pow2 384 + x) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qmul_shift_384_lemma a b =
let l = SB.bn_mul a b in
SB.bn_mul_lemma a b;
assert (SD.bn_v l = SD.bn_v a * SD.bn_v b);
let res_b = SB.bn_rshift l 6 in
let res_b_padded = create 4 (u64 0) in
let res_b_padded = update_sub res_b_padded 0 2 res_b in
qmul_shift_384_lemma_eval_fits l;
assert (SD.bn_v res_b_padded < pow2 128);
assert (SD.bn_v res_b_padded = SD.bn_v l / pow2 384);
let c, res1_b = SB.bn_add1 res_b_padded (u64 1) in
SB.bn_add1_lemma res_b_padded (u64 1);
assert (v c * pow2 256 + SD.bn_v res1_b = SD.bn_v res_b_padded + 1);
SD.bn_eval_bound res1_b 4;
Math.Lemmas.pow2_lt_compat 256 128;
carry_is_zero (v c) 256 (SD.bn_v res1_b) (SD.bn_v res_b_padded + 1);
assert (v c = 0 /\ SD.bn_v res1_b = SD.bn_v res_b_padded + 1);
let flag = l.[5] >>. 63ul in
assert (v flag = v l.[5] / pow2 63);
qmul_shift_383_mod_2_lemma l;
assert (v flag = SD.bn_v l / pow2 383 % 2);
let mask = u64 0 -. flag in
assert (v mask = (if v flag = 0 then 0 else ones_v U64));
let res = map2 (BB.mask_select mask) res1_b res_b_padded in
BB.lseq_mask_select_lemma res1_b res_b_padded mask;
assert (res == (if v flag = 0 then res_b_padded else res1_b)) | val qmul_shift_384_lemma (a b:qelem_lseq) :
Lemma (let x = SD.bn_v a * SD.bn_v b / pow2 383 % 2 in
let res = SD.bn_v (qmul_shift_384 a b) in
res < S.q /\ res = SD.bn_v a * SD.bn_v b / pow2 384 + x)
let qmul_shift_384_lemma a b = | false | null | true | let l = SB.bn_mul a b in
SB.bn_mul_lemma a b;
assert (SD.bn_v l = SD.bn_v a * SD.bn_v b);
let res_b = SB.bn_rshift l 6 in
let res_b_padded = create 4 (u64 0) in
let res_b_padded = update_sub res_b_padded 0 2 res_b in
qmul_shift_384_lemma_eval_fits l;
assert (SD.bn_v res_b_padded < pow2 128);
assert (SD.bn_v res_b_padded = SD.bn_v l / pow2 384);
let c, res1_b = SB.bn_add1 res_b_padded (u64 1) in
SB.bn_add1_lemma res_b_padded (u64 1);
assert (v c * pow2 256 + SD.bn_v res1_b = SD.bn_v res_b_padded + 1);
SD.bn_eval_bound res1_b 4;
Math.Lemmas.pow2_lt_compat 256 128;
carry_is_zero (v c) 256 (SD.bn_v res1_b) (SD.bn_v res_b_padded + 1);
assert (v c = 0 /\ SD.bn_v res1_b = SD.bn_v res_b_padded + 1);
let flag = l.[ 5 ] >>. 63ul in
assert (v flag = v l.[ 5 ] / pow2 63);
qmul_shift_383_mod_2_lemma l;
assert (v flag = SD.bn_v l / pow2 383 % 2);
let mask = u64 0 -. flag in
assert (v mask = (if v flag = 0 then 0 else ones_v U64));
let res = map2 (BB.mask_select mask) res1_b res_b_padded in
BB.lseq_mask_select_lemma res1_b res_b_padded mask;
assert (res == (if v flag = 0 then res_b_padded else res1_b)) | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Hacl.Spec.K256.Scalar.qelem_lseq",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.lseq",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.op_Equality",
"Prims.int",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Prims.bool",
"Prims.unit",
"Hacl.Spec.Bignum.Base.lseq_mask_select_lemma",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.Sequence.index",
"Hacl.Spec.Bignum.Base.mask_select",
"Lib.Sequence.map2",
"Lib.IntTypes.ones_v",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.u64",
"Prims.op_Modulus",
"Prims.op_Division",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.op_Addition",
"Prims.pow2",
"Hacl.Spec.K256.Scalar.Lemmas.qmul_shift_383_mod_2_lemma",
"Lib.Sequence.op_String_Access",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.UInt32.__uint_to_t",
"Prims.l_and",
"Hacl.Spec.K256.Scalar.Lemmas.carry_is_zero",
"FStar.Math.Lemmas.pow2_lt_compat",
"Hacl.Spec.Bignum.Definitions.bn_eval_bound",
"FStar.Mul.op_Star",
"Hacl.Spec.Bignum.bn_add1_lemma",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.bn_add1",
"Hacl.Spec.K256.Scalar.Lemmas.qmul_shift_384_lemma_eval_fits",
"Lib.Sequence.sub",
"Prims.l_or",
"Prims.op_LessThanOrEqual",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.update_sub",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Lib.Sequence.create",
"Prims.op_Subtraction",
"Hacl.Spec.Bignum.bn_rshift",
"Hacl.Spec.Bignum.bn_mul_lemma",
"Hacl.Spec.Bignum.bn_mul"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end
val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c
val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q))
let mul_pow2_256_minus_q_lemma len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
assert_norm (v t0 + v t1 * pow2 64 = pow2 256 - S.q - pow2 128);
let t01 = create2 t0 t1 in
SD.bn_eval_unfold_i t01 2;
SD.bn_eval_unfold_i t01 1;
SD.bn_eval0 t01;
assert (SD.bn_v t01 = pow2 256 - S.q - pow2 128);
let m0 = SB.bn_mul a t01 in // a * t01
SB.bn_mul_lemma a t01;
assert (SD.bn_v m0 == SD.bn_v a * SD.bn_v t01);
let m10 = create resLen (u64 0) in
let m1 = update_sub m10 2 len a in // a * t2 * pow2 128
SD.bn_update_sub_eval m10 a 2;
assert (SD.bn_v m1 = SD.bn_v m10 - SD.bn_v (sub m10 2 len) * pow2 128 + SD.bn_v a * pow2 128);
SD.bn_eval_zeroes #U64 resLen resLen;
eq_intro (sub m10 2 len) (create len (u64 0));
SD.bn_eval_zeroes #U64 len len;
assert (SD.bn_v m1 = SD.bn_v a * pow2 128);
let c, m2 = SB.bn_add m1 m0 in // a * SECP256K1_N_C
SB.bn_add_lemma m1 m0;
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v m1 + SD.bn_v m0);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * pow2 128 + SD.bn_v a * SD.bn_v t01);
Math.Lemmas.distributivity_add_right (SD.bn_v a) (pow2 128) (SD.bn_v t01);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * (pow2 256 - S.q))
val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129))
let mul_pow2_256_minus_q_lt_lemma p a =
Math.Lemmas.lemma_mult_lt_right (pow2 256 - S.q) a (pow2 p);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.lemma_mult_lt_left (pow2 p) (pow2 256 - S.q) (pow2 129);
Math.Lemmas.pow2_plus p 129
val carry_is_zero (c d e a:nat) : Lemma
(requires
a < pow2 d /\ e < pow2 d /\
c * pow2 d + e = a)
(ensures c = 0)
let carry_is_zero c d e a = ()
val mul_pow2_256_minus_q_add_lemma:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> Lemma
(requires SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma len resLen d a e =
let c0, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
mul_pow2_256_minus_q_lemma len resLen a;
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
mul_pow2_256_minus_q_lt_lemma d (SD.bn_v a);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (d + 129));
Math.Lemmas.pow2_lt_compat (64 * resLen) (d + 129);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (64 * resLen));
SD.bn_eval_bound m resLen;
assert (SD.bn_v m < pow2 (64 * resLen));
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) (SD.bn_v a * (pow2 256 - S.q));
assert (v c0 = 0 /\ SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
let c1, res = SB.bn_add m e in // e + a * SECP256K1_N_C
SB.bn_add_lemma m e;
assert (v c1 * pow2 (64 * resLen) + SD.bn_v res == SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e);
SD.bn_eval_bound e 4;
assert (SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)
val mul_pow2_256_minus_q_add_lemma_carry_is_zero:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> f:nat -> Lemma
(requires
SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen /\
256 <= f /\ d + 129 <= f /\ f + 1 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
v c = 0 /\ SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma_carry_is_zero len resLen d a e f =
let c0, m = mul_pow2_256_minus_q_lseq_add len resLen a e in
mul_pow2_256_minus_q_add_lemma len resLen d a e;
let rhs_m = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e in
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = rhs_m);
assert (rhs_m < pow2 (d + 129) + pow2 256);
Math.Lemmas.pow2_le_compat f 256;
Math.Lemmas.pow2_le_compat f (d + 129);
Math.Lemmas.pow2_double_sum f;
assert (rhs_m < pow2 (f + 1));
Math.Lemmas.pow2_lt_compat (64 * resLen) (f + 1);
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) rhs_m;
assert (v c0 = 0 /\ SD.bn_v m = rhs_m)
val lemma_m_bound: m:lseq uint64 7 -> Lemma
(requires SD.bn_v m < pow2 385 + pow2 256)
(ensures SD.bn_v (sub m 4 3) < pow2 130)
let lemma_m_bound m =
Math.Lemmas.pow2_lt_compat 385 256;
Math.Lemmas.pow2_double_sum 385;
SD.bn_eval_split_i m 4;
assert (SD.bn_v m - SD.bn_v (sub m 0 4) = pow2 256 * SD.bn_v (sub m 4 3));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub m 4 3)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v m - SD.bn_v (sub m 0 4)) 386 256;
assert (SD.bn_v (sub m 4 3) < pow2 130)
val lemma_p_bound: p:lseq uint64 5 -> Lemma
(requires SD.bn_v p < pow2 259 + pow2 256)
(ensures SD.bn_v (sub p 4 1) < pow2 4)
let lemma_p_bound p =
Math.Lemmas.pow2_lt_compat 259 256;
Math.Lemmas.pow2_double_sum 259;
SD.bn_eval_split_i p 4;
assert (SD.bn_v p - SD.bn_v (sub p 0 4) = pow2 256 * SD.bn_v (sub p 4 1));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub p 4 1)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v p - SD.bn_v (sub p 0 4)) 260 256;
assert (SD.bn_v (sub p 4 1) < pow2 4)
val mod_lseq_before_final_lemma_aux: a:lseq uint64 8 -> Lemma
(let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
v c0 = 0 /\ SD.bn_v m = rhs_a /\
v c1 = 0 /\ SD.bn_v p = rhs_m /\
v c2 * pow2 256 + SD.bn_v r = rhs_p /\ rhs_p < pow2 133 + pow2 256)
let mod_lseq_before_final_lemma_aux a =
let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
SD.bn_eval_bound (sub a 4 4) 4;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 4 7 256 (sub a 4 4) (sub a 0 4) 385;
assert (v c0 = 0 /\ SD.bn_v m = rhs_a /\ rhs_a < pow2 385 + pow2 256);
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
lemma_m_bound m;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 3 5 130 (sub m 4 3) (sub m 0 4) 259;
assert (v c1 = 0 /\ SD.bn_v p = rhs_m); ///\ rhs_m < pow2 259 + pow2 256);
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
lemma_p_bound p;
mul_pow2_256_minus_q_add_lemma 1 4 4 (sub p 4 1) (sub p 0 4);
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
assert (v c2 * pow2 256 + SD.bn_v r = rhs_p);
assert (rhs_p < pow2 133 + pow2 256)
val lemma_b_pow2_256_plus_a_modq (a b: nat) :
Lemma ((b * pow2 256 + a) % S.q = (b * (pow2 256 - S.q) + a) % S.q)
let lemma_b_pow2_256_plus_a_modq a b =
calc (==) {
(b * (pow2 256 - S.q) + a) % S.q;
(==) { Math.Lemmas.distributivity_sub_right b (pow2 256) S.q }
(b * pow2 256 - b * S.q + a) % S.q;
(==) { Math.Lemmas.lemma_mod_sub (b * pow2 256 + a) S.q b }
(b * pow2 256 + a) % S.q;
}
val lemma_b_pow2_256_plus_a_modq_lseq: len:size_nat{4 <= len} -> a:lseq uint64 len ->
Lemma (SD.bn_v a % S.q == (SD.bn_v (sub a 4 (len - 4)) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4)) % S.q)
let lemma_b_pow2_256_plus_a_modq_lseq len a =
lemma_b_pow2_256_plus_a_modq (SD.bn_v (sub a 0 4)) (SD.bn_v (sub a 4 (len - 4)));
SD.bn_eval_split_i a 4
val mod_lseq_before_final_lemma: a:lseq uint64 8 ->
Lemma (let (c, res) = mod_lseq_before_final a in
v c * pow2 256 + SD.bn_v res < pow2 133 + pow2 256 /\
(v c * pow2 256 + SD.bn_v res) % S.q == SD.bn_v a % S.q)
let mod_lseq_before_final_lemma a =
let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
mod_lseq_before_final_lemma_aux a;
assert (v c0 = 0 /\ SD.bn_v m = rhs_a);
assert (v c1 = 0 /\ SD.bn_v p = rhs_m);
assert (v c2 * pow2 256 + SD.bn_v r = rhs_p);
assert (rhs_p < pow2 133 + pow2 256);
calc (==) { //(v c2 * pow2 256 + SD.bn_v r) % S.q;
rhs_p % S.q;
(==) { lemma_b_pow2_256_plus_a_modq_lseq 5 p }
SD.bn_v p % S.q;
(==) { }
rhs_m % S.q;
(==) { lemma_b_pow2_256_plus_a_modq_lseq 7 m }
SD.bn_v m % S.q;
(==) { }
rhs_a % S.q;
(==) { lemma_b_pow2_256_plus_a_modq_lseq 8 a }
SD.bn_v a % S.q;
}
val mod_lseq_lemma: a:lseq uint64 8 -> Lemma (SD.bn_v (mod_lseq a) == SD.bn_v a % S.q)
let mod_lseq_lemma a =
let c0, r = mod_lseq_before_final a in
mod_lseq_before_final_lemma a;
assert ((v c0 * pow2 256 + SD.bn_v r) % S.q == SD.bn_v a % S.q);
assert (v c0 * pow2 256 + SD.bn_v r < pow2 256 + pow2 133);
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp = pow2 256 - S.q);
let c1, out = SB.bn_add r tmp in
SB.bn_add_lemma r tmp;
assert (v c1 * pow2 256 + SD.bn_v out = SD.bn_v r + pow2 256 - S.q);
Math.Lemmas.small_mod (v c0 + v c1) (pow2 64);
assert (v (c0 +. c1) == v c0 + v c1);
let mask = u64 0 -. (c0 +. c1) in
//let mask = u64 0 -. c1 in
let res = map2 (BB.mask_select mask) out r in
SD.bn_eval_bound r 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v r);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c1);
assert (v c1 = (if SD.bn_v r < S.q then 0 else 1));
if v c0 = 0 then begin
assert (SD.bn_v r % S.q == SD.bn_v a % S.q);
assert (res == mod_short_lseq r);
mod_short_lseq_lemma r;
assert (SD.bn_v res == SD.bn_v a % S.q) end
else begin // v c0 = 1 ==> v c1 = 0
assert ((pow2 256 + SD.bn_v r) % S.q == SD.bn_v a % S.q);
assert (v c1 * pow2 256 + SD.bn_v out = SD.bn_v r + pow2 256 - S.q);
assert (SD.bn_v r < pow2 133);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.pow2_lt_compat 133 129;
Math.Lemmas.pow2_double_sum 133;
assert (SD.bn_v r + pow2 256 - S.q < pow2 134);
Math.Lemmas.pow2_lt_compat 256 134;
carry_is_zero (v c1) 256 (SD.bn_v out) (SD.bn_v r + pow2 256 - S.q);
assert (v c1 = 0);
assert_norm (pow2 134 < S.q);
assert (SD.bn_v r + pow2 256 - S.q < S.q);
BB.lseq_mask_select_lemma out r mask;
assert (SD.bn_v res == SD.bn_v r + pow2 256 - S.q);
Math.Lemmas.lemma_mod_sub (pow2 256 + SD.bn_v r) S.q 1;
assert (SD.bn_v res % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v res) S.q end
val qmul_shift_383_mod_2_lemma : l:lseq uint64 8 ->
Lemma (v l.[5] / pow2 63 = SD.bn_v l / pow2 383 % 2)
let qmul_shift_383_mod_2_lemma l =
calc (==) {
v l.[5] / pow2 63;
(==) { SD.bn_eval_index l 5 }
SD.bn_v l / pow2 320 % pow2 64 / pow2 63;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (SD.bn_v l) 320 384 }
SD.bn_v l % pow2 384 / pow2 320 / pow2 63;
(==) { Math.Lemmas.division_multiplication_lemma (SD.bn_v l % pow2 384) (pow2 320) (pow2 63) }
SD.bn_v l % pow2 384 / (pow2 320 * pow2 63);
(==) { Math.Lemmas.pow2_plus 320 63 }
SD.bn_v l % pow2 384 / pow2 383;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (SD.bn_v l) 383 384 }
SD.bn_v l / pow2 383 % pow2 1;
(==) { assert_norm (pow2 1 = 2) }
SD.bn_v l / pow2 383 % 2;
}
val qmul_shift_384_lemma_eval_fits : l:lseq uint64 8 ->
Lemma (let res_b = SB.bn_rshift l 6 in
let res_b_padded = create 4 (u64 0) in
let res_b_padded = update_sub res_b_padded 0 2 res_b in
SD.bn_v res_b_padded < pow2 128 /\
SD.bn_v res_b_padded = SD.bn_v l / pow2 384)
let qmul_shift_384_lemma_eval_fits l =
let res_b = SB.bn_rshift l 6 in
let res_b_padded = create 4 (u64 0) in
let res_b_padded = update_sub res_b_padded 0 2 res_b in
SD.bn_eval_update_sub 2 res_b 4;
assert (SD.bn_v res_b = SD.bn_v res_b_padded);
SB.bn_rshift_lemma l 6;
SD.bn_eval_bound res_b 2;
assert (SD.bn_v res_b_padded < pow2 128)
val qmul_shift_384_lemma (a b:qelem_lseq) :
Lemma (let x = SD.bn_v a * SD.bn_v b / pow2 383 % 2 in
let res = SD.bn_v (qmul_shift_384 a b) in
res < S.q /\ res = SD.bn_v a * SD.bn_v b / pow2 384 + x) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qmul_shift_384_lemma (a b:qelem_lseq) :
Lemma (let x = SD.bn_v a * SD.bn_v b / pow2 383 % 2 in
let res = SD.bn_v (qmul_shift_384 a b) in
res < S.q /\ res = SD.bn_v a * SD.bn_v b / pow2 384 + x) | [] | Hacl.Spec.K256.Scalar.Lemmas.qmul_shift_384_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.Spec.K256.Scalar.qelem_lseq -> b: Hacl.Spec.K256.Scalar.qelem_lseq
-> FStar.Pervasives.Lemma
(ensures
(let x =
Hacl.Spec.Bignum.Definitions.bn_v a * Hacl.Spec.Bignum.Definitions.bn_v b / Prims.pow2 383 %
2
in
let res = Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.K256.Scalar.qmul_shift_384 a b) in
res < Spec.K256.PointOps.q /\
res =
Hacl.Spec.Bignum.Definitions.bn_v a * Hacl.Spec.Bignum.Definitions.bn_v b / Prims.pow2 384 +
x)) | {
"end_col": 63,
"end_line": 513,
"start_col": 30,
"start_line": 484
} |
FStar.Pervasives.Lemma | val mod_lseq_before_final_lemma: a:lseq uint64 8 ->
Lemma (let (c, res) = mod_lseq_before_final a in
v c * pow2 256 + SD.bn_v res < pow2 133 + pow2 256 /\
(v c * pow2 256 + SD.bn_v res) % S.q == SD.bn_v a % S.q) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_lseq_before_final_lemma a =
let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
mod_lseq_before_final_lemma_aux a;
assert (v c0 = 0 /\ SD.bn_v m = rhs_a);
assert (v c1 = 0 /\ SD.bn_v p = rhs_m);
assert (v c2 * pow2 256 + SD.bn_v r = rhs_p);
assert (rhs_p < pow2 133 + pow2 256);
calc (==) { //(v c2 * pow2 256 + SD.bn_v r) % S.q;
rhs_p % S.q;
(==) { lemma_b_pow2_256_plus_a_modq_lseq 5 p }
SD.bn_v p % S.q;
(==) { }
rhs_m % S.q;
(==) { lemma_b_pow2_256_plus_a_modq_lseq 7 m }
SD.bn_v m % S.q;
(==) { }
rhs_a % S.q;
(==) { lemma_b_pow2_256_plus_a_modq_lseq 8 a }
SD.bn_v a % S.q;
} | val mod_lseq_before_final_lemma: a:lseq uint64 8 ->
Lemma (let (c, res) = mod_lseq_before_final a in
v c * pow2 256 + SD.bn_v res < pow2 133 + pow2 256 /\
(v c * pow2 256 + SD.bn_v res) % S.q == SD.bn_v a % S.q)
let mod_lseq_before_final_lemma a = | false | null | true | let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
mod_lseq_before_final_lemma_aux a;
assert (v c0 = 0 /\ SD.bn_v m = rhs_a);
assert (v c1 = 0 /\ SD.bn_v p = rhs_m);
assert (v c2 * pow2 256 + SD.bn_v r = rhs_p);
assert (rhs_p < pow2 133 + pow2 256);
calc ( == ) {
rhs_p % S.q;
( == ) { lemma_b_pow2_256_plus_a_modq_lseq 5 p }
SD.bn_v p % S.q;
( == ) { () }
rhs_m % S.q;
( == ) { lemma_b_pow2_256_plus_a_modq_lseq 7 m }
SD.bn_v m % S.q;
( == ) { () }
rhs_a % S.q;
( == ) { lemma_b_pow2_256_plus_a_modq_lseq 8 a }
SD.bn_v a % S.q;
} | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"Prims.op_Modulus",
"Spec.K256.PointOps.q",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Hacl.Spec.K256.Scalar.Lemmas.lemma_b_pow2_256_plus_a_modq_lseq",
"Prims.squash",
"Prims._assert",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Addition",
"Prims.pow2",
"Prims.op_Equality",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Prims.l_and",
"Hacl.Spec.K256.Scalar.Lemmas.mod_lseq_before_final_lemma_aux",
"Lib.Sequence.sub",
"Prims.op_Subtraction",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Hacl.Spec.K256.Scalar.mul_pow2_256_minus_q_lseq_add"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end
val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c
val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q))
let mul_pow2_256_minus_q_lemma len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
assert_norm (v t0 + v t1 * pow2 64 = pow2 256 - S.q - pow2 128);
let t01 = create2 t0 t1 in
SD.bn_eval_unfold_i t01 2;
SD.bn_eval_unfold_i t01 1;
SD.bn_eval0 t01;
assert (SD.bn_v t01 = pow2 256 - S.q - pow2 128);
let m0 = SB.bn_mul a t01 in // a * t01
SB.bn_mul_lemma a t01;
assert (SD.bn_v m0 == SD.bn_v a * SD.bn_v t01);
let m10 = create resLen (u64 0) in
let m1 = update_sub m10 2 len a in // a * t2 * pow2 128
SD.bn_update_sub_eval m10 a 2;
assert (SD.bn_v m1 = SD.bn_v m10 - SD.bn_v (sub m10 2 len) * pow2 128 + SD.bn_v a * pow2 128);
SD.bn_eval_zeroes #U64 resLen resLen;
eq_intro (sub m10 2 len) (create len (u64 0));
SD.bn_eval_zeroes #U64 len len;
assert (SD.bn_v m1 = SD.bn_v a * pow2 128);
let c, m2 = SB.bn_add m1 m0 in // a * SECP256K1_N_C
SB.bn_add_lemma m1 m0;
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v m1 + SD.bn_v m0);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * pow2 128 + SD.bn_v a * SD.bn_v t01);
Math.Lemmas.distributivity_add_right (SD.bn_v a) (pow2 128) (SD.bn_v t01);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * (pow2 256 - S.q))
val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129))
let mul_pow2_256_minus_q_lt_lemma p a =
Math.Lemmas.lemma_mult_lt_right (pow2 256 - S.q) a (pow2 p);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.lemma_mult_lt_left (pow2 p) (pow2 256 - S.q) (pow2 129);
Math.Lemmas.pow2_plus p 129
val carry_is_zero (c d e a:nat) : Lemma
(requires
a < pow2 d /\ e < pow2 d /\
c * pow2 d + e = a)
(ensures c = 0)
let carry_is_zero c d e a = ()
val mul_pow2_256_minus_q_add_lemma:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> Lemma
(requires SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma len resLen d a e =
let c0, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
mul_pow2_256_minus_q_lemma len resLen a;
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
mul_pow2_256_minus_q_lt_lemma d (SD.bn_v a);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (d + 129));
Math.Lemmas.pow2_lt_compat (64 * resLen) (d + 129);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (64 * resLen));
SD.bn_eval_bound m resLen;
assert (SD.bn_v m < pow2 (64 * resLen));
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) (SD.bn_v a * (pow2 256 - S.q));
assert (v c0 = 0 /\ SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
let c1, res = SB.bn_add m e in // e + a * SECP256K1_N_C
SB.bn_add_lemma m e;
assert (v c1 * pow2 (64 * resLen) + SD.bn_v res == SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e);
SD.bn_eval_bound e 4;
assert (SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)
val mul_pow2_256_minus_q_add_lemma_carry_is_zero:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> f:nat -> Lemma
(requires
SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen /\
256 <= f /\ d + 129 <= f /\ f + 1 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
v c = 0 /\ SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma_carry_is_zero len resLen d a e f =
let c0, m = mul_pow2_256_minus_q_lseq_add len resLen a e in
mul_pow2_256_minus_q_add_lemma len resLen d a e;
let rhs_m = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e in
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = rhs_m);
assert (rhs_m < pow2 (d + 129) + pow2 256);
Math.Lemmas.pow2_le_compat f 256;
Math.Lemmas.pow2_le_compat f (d + 129);
Math.Lemmas.pow2_double_sum f;
assert (rhs_m < pow2 (f + 1));
Math.Lemmas.pow2_lt_compat (64 * resLen) (f + 1);
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) rhs_m;
assert (v c0 = 0 /\ SD.bn_v m = rhs_m)
val lemma_m_bound: m:lseq uint64 7 -> Lemma
(requires SD.bn_v m < pow2 385 + pow2 256)
(ensures SD.bn_v (sub m 4 3) < pow2 130)
let lemma_m_bound m =
Math.Lemmas.pow2_lt_compat 385 256;
Math.Lemmas.pow2_double_sum 385;
SD.bn_eval_split_i m 4;
assert (SD.bn_v m - SD.bn_v (sub m 0 4) = pow2 256 * SD.bn_v (sub m 4 3));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub m 4 3)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v m - SD.bn_v (sub m 0 4)) 386 256;
assert (SD.bn_v (sub m 4 3) < pow2 130)
val lemma_p_bound: p:lseq uint64 5 -> Lemma
(requires SD.bn_v p < pow2 259 + pow2 256)
(ensures SD.bn_v (sub p 4 1) < pow2 4)
let lemma_p_bound p =
Math.Lemmas.pow2_lt_compat 259 256;
Math.Lemmas.pow2_double_sum 259;
SD.bn_eval_split_i p 4;
assert (SD.bn_v p - SD.bn_v (sub p 0 4) = pow2 256 * SD.bn_v (sub p 4 1));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub p 4 1)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v p - SD.bn_v (sub p 0 4)) 260 256;
assert (SD.bn_v (sub p 4 1) < pow2 4)
val mod_lseq_before_final_lemma_aux: a:lseq uint64 8 -> Lemma
(let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
v c0 = 0 /\ SD.bn_v m = rhs_a /\
v c1 = 0 /\ SD.bn_v p = rhs_m /\
v c2 * pow2 256 + SD.bn_v r = rhs_p /\ rhs_p < pow2 133 + pow2 256)
let mod_lseq_before_final_lemma_aux a =
let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
SD.bn_eval_bound (sub a 4 4) 4;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 4 7 256 (sub a 4 4) (sub a 0 4) 385;
assert (v c0 = 0 /\ SD.bn_v m = rhs_a /\ rhs_a < pow2 385 + pow2 256);
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
lemma_m_bound m;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 3 5 130 (sub m 4 3) (sub m 0 4) 259;
assert (v c1 = 0 /\ SD.bn_v p = rhs_m); ///\ rhs_m < pow2 259 + pow2 256);
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
lemma_p_bound p;
mul_pow2_256_minus_q_add_lemma 1 4 4 (sub p 4 1) (sub p 0 4);
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
assert (v c2 * pow2 256 + SD.bn_v r = rhs_p);
assert (rhs_p < pow2 133 + pow2 256)
val lemma_b_pow2_256_plus_a_modq (a b: nat) :
Lemma ((b * pow2 256 + a) % S.q = (b * (pow2 256 - S.q) + a) % S.q)
let lemma_b_pow2_256_plus_a_modq a b =
calc (==) {
(b * (pow2 256 - S.q) + a) % S.q;
(==) { Math.Lemmas.distributivity_sub_right b (pow2 256) S.q }
(b * pow2 256 - b * S.q + a) % S.q;
(==) { Math.Lemmas.lemma_mod_sub (b * pow2 256 + a) S.q b }
(b * pow2 256 + a) % S.q;
}
val lemma_b_pow2_256_plus_a_modq_lseq: len:size_nat{4 <= len} -> a:lseq uint64 len ->
Lemma (SD.bn_v a % S.q == (SD.bn_v (sub a 4 (len - 4)) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4)) % S.q)
let lemma_b_pow2_256_plus_a_modq_lseq len a =
lemma_b_pow2_256_plus_a_modq (SD.bn_v (sub a 0 4)) (SD.bn_v (sub a 4 (len - 4)));
SD.bn_eval_split_i a 4
val mod_lseq_before_final_lemma: a:lseq uint64 8 ->
Lemma (let (c, res) = mod_lseq_before_final a in
v c * pow2 256 + SD.bn_v res < pow2 133 + pow2 256 /\
(v c * pow2 256 + SD.bn_v res) % S.q == SD.bn_v a % S.q) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_lseq_before_final_lemma: a:lseq uint64 8 ->
Lemma (let (c, res) = mod_lseq_before_final a in
v c * pow2 256 + SD.bn_v res < pow2 133 + pow2 256 /\
(v c * pow2 256 + SD.bn_v res) % S.q == SD.bn_v a % S.q) | [] | Hacl.Spec.K256.Scalar.Lemmas.mod_lseq_before_final_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Lib.Sequence.lseq Lib.IntTypes.uint64 8
-> FStar.Pervasives.Lemma
(ensures
(let _ = Hacl.Spec.K256.Scalar.mod_lseq_before_final a in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ c res = _ in
Lib.IntTypes.v c * Prims.pow2 256 + Hacl.Spec.Bignum.Definitions.bn_v res <
Prims.pow2 133 + Prims.pow2 256 /\
(Lib.IntTypes.v c * Prims.pow2 256 + Hacl.Spec.Bignum.Definitions.bn_v res) %
Spec.K256.PointOps.q ==
Hacl.Spec.Bignum.Definitions.bn_v a % Spec.K256.PointOps.q)
<:
Type0)) | {
"end_col": 5,
"end_line": 383,
"start_col": 35,
"start_line": 356
} |
FStar.Pervasives.Lemma | val mod_lseq_lemma: a:lseq uint64 8 -> Lemma (SD.bn_v (mod_lseq a) == SD.bn_v a % S.q) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_lseq_lemma a =
let c0, r = mod_lseq_before_final a in
mod_lseq_before_final_lemma a;
assert ((v c0 * pow2 256 + SD.bn_v r) % S.q == SD.bn_v a % S.q);
assert (v c0 * pow2 256 + SD.bn_v r < pow2 256 + pow2 133);
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp = pow2 256 - S.q);
let c1, out = SB.bn_add r tmp in
SB.bn_add_lemma r tmp;
assert (v c1 * pow2 256 + SD.bn_v out = SD.bn_v r + pow2 256 - S.q);
Math.Lemmas.small_mod (v c0 + v c1) (pow2 64);
assert (v (c0 +. c1) == v c0 + v c1);
let mask = u64 0 -. (c0 +. c1) in
//let mask = u64 0 -. c1 in
let res = map2 (BB.mask_select mask) out r in
SD.bn_eval_bound r 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v r);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c1);
assert (v c1 = (if SD.bn_v r < S.q then 0 else 1));
if v c0 = 0 then begin
assert (SD.bn_v r % S.q == SD.bn_v a % S.q);
assert (res == mod_short_lseq r);
mod_short_lseq_lemma r;
assert (SD.bn_v res == SD.bn_v a % S.q) end
else begin // v c0 = 1 ==> v c1 = 0
assert ((pow2 256 + SD.bn_v r) % S.q == SD.bn_v a % S.q);
assert (v c1 * pow2 256 + SD.bn_v out = SD.bn_v r + pow2 256 - S.q);
assert (SD.bn_v r < pow2 133);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.pow2_lt_compat 133 129;
Math.Lemmas.pow2_double_sum 133;
assert (SD.bn_v r + pow2 256 - S.q < pow2 134);
Math.Lemmas.pow2_lt_compat 256 134;
carry_is_zero (v c1) 256 (SD.bn_v out) (SD.bn_v r + pow2 256 - S.q);
assert (v c1 = 0);
assert_norm (pow2 134 < S.q);
assert (SD.bn_v r + pow2 256 - S.q < S.q);
BB.lseq_mask_select_lemma out r mask;
assert (SD.bn_v res == SD.bn_v r + pow2 256 - S.q);
Math.Lemmas.lemma_mod_sub (pow2 256 + SD.bn_v r) S.q 1;
assert (SD.bn_v res % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v res) S.q end | val mod_lseq_lemma: a:lseq uint64 8 -> Lemma (SD.bn_v (mod_lseq a) == SD.bn_v a % S.q)
let mod_lseq_lemma a = | false | null | true | let c0, r = mod_lseq_before_final a in
mod_lseq_before_final_lemma a;
assert ((v c0 * pow2 256 + SD.bn_v r) % S.q == SD.bn_v a % S.q);
assert (v c0 * pow2 256 + SD.bn_v r < pow2 256 + pow2 133);
let t0, t1, t2, t3 = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp = pow2 256 - S.q);
let c1, out = SB.bn_add r tmp in
SB.bn_add_lemma r tmp;
assert (v c1 * pow2 256 + SD.bn_v out = SD.bn_v r + pow2 256 - S.q);
Math.Lemmas.small_mod (v c0 + v c1) (pow2 64);
assert (v (c0 +. c1) == v c0 + v c1);
let mask = u64 0 -. (c0 +. c1) in
let res = map2 (BB.mask_select mask) out r in
SD.bn_eval_bound r 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v r);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c1);
assert (v c1 = (if SD.bn_v r < S.q then 0 else 1));
if v c0 = 0
then
(assert (SD.bn_v r % S.q == SD.bn_v a % S.q);
assert (res == mod_short_lseq r);
mod_short_lseq_lemma r;
assert (SD.bn_v res == SD.bn_v a % S.q))
else
(assert ((pow2 256 + SD.bn_v r) % S.q == SD.bn_v a % S.q);
assert (v c1 * pow2 256 + SD.bn_v out = SD.bn_v r + pow2 256 - S.q);
assert (SD.bn_v r < pow2 133);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.pow2_lt_compat 133 129;
Math.Lemmas.pow2_double_sum 133;
assert (SD.bn_v r + pow2 256 - S.q < pow2 134);
Math.Lemmas.pow2_lt_compat 256 134;
carry_is_zero (v c1) 256 (SD.bn_v out) (SD.bn_v r + pow2 256 - S.q);
assert (v c1 = 0);
assert_norm (pow2 134 < S.q);
assert (SD.bn_v r + pow2 256 - S.q < S.q);
BB.lseq_mask_select_lemma out r mask;
assert (SD.bn_v res == SD.bn_v r + pow2 256 - S.q);
Math.Lemmas.lemma_mod_sub (pow2 256 + SD.bn_v r) S.q 1;
assert (SD.bn_v res % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v res) S.q) | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"Hacl.Spec.K256.Scalar.qelem_lseq",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims.op_Equality",
"Prims.int",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Prims._assert",
"Prims.eq2",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.op_Modulus",
"Spec.K256.PointOps.q",
"Prims.unit",
"Hacl.Spec.K256.Scalar.Lemmas.mod_short_lseq_lemma",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.K256.Scalar.mod_short_lseq",
"Prims.bool",
"FStar.Math.Lemmas.small_mod",
"FStar.Math.Lemmas.lemma_mod_sub",
"Prims.op_Addition",
"Prims.pow2",
"Prims.op_Subtraction",
"Hacl.Spec.Bignum.Base.lseq_mask_select_lemma",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Pervasives.assert_norm",
"Hacl.Spec.K256.Scalar.Lemmas.carry_is_zero",
"FStar.Math.Lemmas.pow2_lt_compat",
"FStar.Math.Lemmas.pow2_double_sum",
"FStar.Mul.op_Star",
"Hacl.Spec.K256.Scalar.Lemmas.lemma_get_carry_from_bn_add",
"Hacl.Spec.K256.Scalar.Lemmas.lemma_check_overflow",
"Hacl.Spec.Bignum.Definitions.bn_eval_bound",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Lib.Sequence.index",
"Hacl.Spec.Bignum.Base.mask_select",
"Lib.IntTypes.int_t",
"Lib.Sequence.map2",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.u64",
"Lib.IntTypes.op_Plus_Dot",
"Hacl.Spec.Bignum.bn_add_lemma",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.bn_add",
"Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_is_qas_nat",
"Lib.Sequence.create4",
"Hacl.Spec.K256.Scalar.qelem4",
"Hacl.Spec.K256.Scalar.make_pow2_256_minus_order_k256",
"Hacl.Spec.K256.Scalar.Lemmas.mod_lseq_before_final_lemma",
"Hacl.Spec.K256.Scalar.mod_lseq_before_final"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end
val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c
val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q))
let mul_pow2_256_minus_q_lemma len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
assert_norm (v t0 + v t1 * pow2 64 = pow2 256 - S.q - pow2 128);
let t01 = create2 t0 t1 in
SD.bn_eval_unfold_i t01 2;
SD.bn_eval_unfold_i t01 1;
SD.bn_eval0 t01;
assert (SD.bn_v t01 = pow2 256 - S.q - pow2 128);
let m0 = SB.bn_mul a t01 in // a * t01
SB.bn_mul_lemma a t01;
assert (SD.bn_v m0 == SD.bn_v a * SD.bn_v t01);
let m10 = create resLen (u64 0) in
let m1 = update_sub m10 2 len a in // a * t2 * pow2 128
SD.bn_update_sub_eval m10 a 2;
assert (SD.bn_v m1 = SD.bn_v m10 - SD.bn_v (sub m10 2 len) * pow2 128 + SD.bn_v a * pow2 128);
SD.bn_eval_zeroes #U64 resLen resLen;
eq_intro (sub m10 2 len) (create len (u64 0));
SD.bn_eval_zeroes #U64 len len;
assert (SD.bn_v m1 = SD.bn_v a * pow2 128);
let c, m2 = SB.bn_add m1 m0 in // a * SECP256K1_N_C
SB.bn_add_lemma m1 m0;
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v m1 + SD.bn_v m0);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * pow2 128 + SD.bn_v a * SD.bn_v t01);
Math.Lemmas.distributivity_add_right (SD.bn_v a) (pow2 128) (SD.bn_v t01);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * (pow2 256 - S.q))
val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129))
let mul_pow2_256_minus_q_lt_lemma p a =
Math.Lemmas.lemma_mult_lt_right (pow2 256 - S.q) a (pow2 p);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.lemma_mult_lt_left (pow2 p) (pow2 256 - S.q) (pow2 129);
Math.Lemmas.pow2_plus p 129
val carry_is_zero (c d e a:nat) : Lemma
(requires
a < pow2 d /\ e < pow2 d /\
c * pow2 d + e = a)
(ensures c = 0)
let carry_is_zero c d e a = ()
val mul_pow2_256_minus_q_add_lemma:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> Lemma
(requires SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma len resLen d a e =
let c0, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
mul_pow2_256_minus_q_lemma len resLen a;
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
mul_pow2_256_minus_q_lt_lemma d (SD.bn_v a);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (d + 129));
Math.Lemmas.pow2_lt_compat (64 * resLen) (d + 129);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (64 * resLen));
SD.bn_eval_bound m resLen;
assert (SD.bn_v m < pow2 (64 * resLen));
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) (SD.bn_v a * (pow2 256 - S.q));
assert (v c0 = 0 /\ SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
let c1, res = SB.bn_add m e in // e + a * SECP256K1_N_C
SB.bn_add_lemma m e;
assert (v c1 * pow2 (64 * resLen) + SD.bn_v res == SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e);
SD.bn_eval_bound e 4;
assert (SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)
val mul_pow2_256_minus_q_add_lemma_carry_is_zero:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> f:nat -> Lemma
(requires
SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen /\
256 <= f /\ d + 129 <= f /\ f + 1 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
v c = 0 /\ SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma_carry_is_zero len resLen d a e f =
let c0, m = mul_pow2_256_minus_q_lseq_add len resLen a e in
mul_pow2_256_minus_q_add_lemma len resLen d a e;
let rhs_m = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e in
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = rhs_m);
assert (rhs_m < pow2 (d + 129) + pow2 256);
Math.Lemmas.pow2_le_compat f 256;
Math.Lemmas.pow2_le_compat f (d + 129);
Math.Lemmas.pow2_double_sum f;
assert (rhs_m < pow2 (f + 1));
Math.Lemmas.pow2_lt_compat (64 * resLen) (f + 1);
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) rhs_m;
assert (v c0 = 0 /\ SD.bn_v m = rhs_m)
val lemma_m_bound: m:lseq uint64 7 -> Lemma
(requires SD.bn_v m < pow2 385 + pow2 256)
(ensures SD.bn_v (sub m 4 3) < pow2 130)
let lemma_m_bound m =
Math.Lemmas.pow2_lt_compat 385 256;
Math.Lemmas.pow2_double_sum 385;
SD.bn_eval_split_i m 4;
assert (SD.bn_v m - SD.bn_v (sub m 0 4) = pow2 256 * SD.bn_v (sub m 4 3));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub m 4 3)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v m - SD.bn_v (sub m 0 4)) 386 256;
assert (SD.bn_v (sub m 4 3) < pow2 130)
val lemma_p_bound: p:lseq uint64 5 -> Lemma
(requires SD.bn_v p < pow2 259 + pow2 256)
(ensures SD.bn_v (sub p 4 1) < pow2 4)
let lemma_p_bound p =
Math.Lemmas.pow2_lt_compat 259 256;
Math.Lemmas.pow2_double_sum 259;
SD.bn_eval_split_i p 4;
assert (SD.bn_v p - SD.bn_v (sub p 0 4) = pow2 256 * SD.bn_v (sub p 4 1));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub p 4 1)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v p - SD.bn_v (sub p 0 4)) 260 256;
assert (SD.bn_v (sub p 4 1) < pow2 4)
val mod_lseq_before_final_lemma_aux: a:lseq uint64 8 -> Lemma
(let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
v c0 = 0 /\ SD.bn_v m = rhs_a /\
v c1 = 0 /\ SD.bn_v p = rhs_m /\
v c2 * pow2 256 + SD.bn_v r = rhs_p /\ rhs_p < pow2 133 + pow2 256)
let mod_lseq_before_final_lemma_aux a =
let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
SD.bn_eval_bound (sub a 4 4) 4;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 4 7 256 (sub a 4 4) (sub a 0 4) 385;
assert (v c0 = 0 /\ SD.bn_v m = rhs_a /\ rhs_a < pow2 385 + pow2 256);
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
lemma_m_bound m;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 3 5 130 (sub m 4 3) (sub m 0 4) 259;
assert (v c1 = 0 /\ SD.bn_v p = rhs_m); ///\ rhs_m < pow2 259 + pow2 256);
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
lemma_p_bound p;
mul_pow2_256_minus_q_add_lemma 1 4 4 (sub p 4 1) (sub p 0 4);
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
assert (v c2 * pow2 256 + SD.bn_v r = rhs_p);
assert (rhs_p < pow2 133 + pow2 256)
val lemma_b_pow2_256_plus_a_modq (a b: nat) :
Lemma ((b * pow2 256 + a) % S.q = (b * (pow2 256 - S.q) + a) % S.q)
let lemma_b_pow2_256_plus_a_modq a b =
calc (==) {
(b * (pow2 256 - S.q) + a) % S.q;
(==) { Math.Lemmas.distributivity_sub_right b (pow2 256) S.q }
(b * pow2 256 - b * S.q + a) % S.q;
(==) { Math.Lemmas.lemma_mod_sub (b * pow2 256 + a) S.q b }
(b * pow2 256 + a) % S.q;
}
val lemma_b_pow2_256_plus_a_modq_lseq: len:size_nat{4 <= len} -> a:lseq uint64 len ->
Lemma (SD.bn_v a % S.q == (SD.bn_v (sub a 4 (len - 4)) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4)) % S.q)
let lemma_b_pow2_256_plus_a_modq_lseq len a =
lemma_b_pow2_256_plus_a_modq (SD.bn_v (sub a 0 4)) (SD.bn_v (sub a 4 (len - 4)));
SD.bn_eval_split_i a 4
val mod_lseq_before_final_lemma: a:lseq uint64 8 ->
Lemma (let (c, res) = mod_lseq_before_final a in
v c * pow2 256 + SD.bn_v res < pow2 133 + pow2 256 /\
(v c * pow2 256 + SD.bn_v res) % S.q == SD.bn_v a % S.q)
let mod_lseq_before_final_lemma a =
let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
mod_lseq_before_final_lemma_aux a;
assert (v c0 = 0 /\ SD.bn_v m = rhs_a);
assert (v c1 = 0 /\ SD.bn_v p = rhs_m);
assert (v c2 * pow2 256 + SD.bn_v r = rhs_p);
assert (rhs_p < pow2 133 + pow2 256);
calc (==) { //(v c2 * pow2 256 + SD.bn_v r) % S.q;
rhs_p % S.q;
(==) { lemma_b_pow2_256_plus_a_modq_lseq 5 p }
SD.bn_v p % S.q;
(==) { }
rhs_m % S.q;
(==) { lemma_b_pow2_256_plus_a_modq_lseq 7 m }
SD.bn_v m % S.q;
(==) { }
rhs_a % S.q;
(==) { lemma_b_pow2_256_plus_a_modq_lseq 8 a }
SD.bn_v a % S.q;
} | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_lseq_lemma: a:lseq uint64 8 -> Lemma (SD.bn_v (mod_lseq a) == SD.bn_v a % S.q) | [] | Hacl.Spec.K256.Scalar.Lemmas.mod_lseq_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Lib.Sequence.lseq Lib.IntTypes.uint64 8
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.K256.Scalar.mod_lseq a) ==
Hacl.Spec.Bignum.Definitions.bn_v a % Spec.K256.PointOps.q) | {
"end_col": 47,
"end_line": 437,
"start_col": 22,
"start_line": 387
} |
FStar.Pervasives.Lemma | val mod_lseq_before_final_lemma_aux: a:lseq uint64 8 -> Lemma
(let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
v c0 = 0 /\ SD.bn_v m = rhs_a /\
v c1 = 0 /\ SD.bn_v p = rhs_m /\
v c2 * pow2 256 + SD.bn_v r = rhs_p /\ rhs_p < pow2 133 + pow2 256) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_lseq_before_final_lemma_aux a =
let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
SD.bn_eval_bound (sub a 4 4) 4;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 4 7 256 (sub a 4 4) (sub a 0 4) 385;
assert (v c0 = 0 /\ SD.bn_v m = rhs_a /\ rhs_a < pow2 385 + pow2 256);
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
lemma_m_bound m;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 3 5 130 (sub m 4 3) (sub m 0 4) 259;
assert (v c1 = 0 /\ SD.bn_v p = rhs_m); ///\ rhs_m < pow2 259 + pow2 256);
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
lemma_p_bound p;
mul_pow2_256_minus_q_add_lemma 1 4 4 (sub p 4 1) (sub p 0 4);
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
assert (v c2 * pow2 256 + SD.bn_v r = rhs_p);
assert (rhs_p < pow2 133 + pow2 256) | val mod_lseq_before_final_lemma_aux: a:lseq uint64 8 -> Lemma
(let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
v c0 = 0 /\ SD.bn_v m = rhs_a /\
v c1 = 0 /\ SD.bn_v p = rhs_m /\
v c2 * pow2 256 + SD.bn_v r = rhs_p /\ rhs_p < pow2 133 + pow2 256)
let mod_lseq_before_final_lemma_aux a = | false | null | true | let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
SD.bn_eval_bound (sub a 4 4) 4;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 4 7 256 (sub a 4 4) (sub a 0 4) 385;
assert (v c0 = 0 /\ SD.bn_v m = rhs_a /\ rhs_a < pow2 385 + pow2 256);
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
lemma_m_bound m;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 3 5 130 (sub m 4 3) (sub m 0 4) 259;
assert (v c1 = 0 /\ SD.bn_v p = rhs_m);
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in
lemma_p_bound p;
mul_pow2_256_minus_q_add_lemma 1 4 4 (sub p 4 1) (sub p 0 4);
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
assert (v c2 * pow2 256 + SD.bn_v r = rhs_p);
assert (rhs_p < pow2 133 + pow2 256) | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"Prims._assert",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Addition",
"Prims.pow2",
"Prims.unit",
"Prims.op_Equality",
"Prims.int",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Lib.Sequence.sub",
"Prims.op_Subtraction",
"Spec.K256.PointOps.q",
"Hacl.Spec.K256.Scalar.Lemmas.mul_pow2_256_minus_q_add_lemma",
"Hacl.Spec.K256.Scalar.Lemmas.lemma_p_bound",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Hacl.Spec.K256.Scalar.mul_pow2_256_minus_q_lseq_add",
"Prims.l_and",
"Hacl.Spec.K256.Scalar.Lemmas.mul_pow2_256_minus_q_add_lemma_carry_is_zero",
"Hacl.Spec.K256.Scalar.Lemmas.lemma_m_bound",
"Hacl.Spec.Bignum.Definitions.bn_eval_bound"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end
val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c
val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q))
let mul_pow2_256_minus_q_lemma len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
assert_norm (v t0 + v t1 * pow2 64 = pow2 256 - S.q - pow2 128);
let t01 = create2 t0 t1 in
SD.bn_eval_unfold_i t01 2;
SD.bn_eval_unfold_i t01 1;
SD.bn_eval0 t01;
assert (SD.bn_v t01 = pow2 256 - S.q - pow2 128);
let m0 = SB.bn_mul a t01 in // a * t01
SB.bn_mul_lemma a t01;
assert (SD.bn_v m0 == SD.bn_v a * SD.bn_v t01);
let m10 = create resLen (u64 0) in
let m1 = update_sub m10 2 len a in // a * t2 * pow2 128
SD.bn_update_sub_eval m10 a 2;
assert (SD.bn_v m1 = SD.bn_v m10 - SD.bn_v (sub m10 2 len) * pow2 128 + SD.bn_v a * pow2 128);
SD.bn_eval_zeroes #U64 resLen resLen;
eq_intro (sub m10 2 len) (create len (u64 0));
SD.bn_eval_zeroes #U64 len len;
assert (SD.bn_v m1 = SD.bn_v a * pow2 128);
let c, m2 = SB.bn_add m1 m0 in // a * SECP256K1_N_C
SB.bn_add_lemma m1 m0;
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v m1 + SD.bn_v m0);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * pow2 128 + SD.bn_v a * SD.bn_v t01);
Math.Lemmas.distributivity_add_right (SD.bn_v a) (pow2 128) (SD.bn_v t01);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * (pow2 256 - S.q))
val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129))
let mul_pow2_256_minus_q_lt_lemma p a =
Math.Lemmas.lemma_mult_lt_right (pow2 256 - S.q) a (pow2 p);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.lemma_mult_lt_left (pow2 p) (pow2 256 - S.q) (pow2 129);
Math.Lemmas.pow2_plus p 129
val carry_is_zero (c d e a:nat) : Lemma
(requires
a < pow2 d /\ e < pow2 d /\
c * pow2 d + e = a)
(ensures c = 0)
let carry_is_zero c d e a = ()
val mul_pow2_256_minus_q_add_lemma:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> Lemma
(requires SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma len resLen d a e =
let c0, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
mul_pow2_256_minus_q_lemma len resLen a;
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
mul_pow2_256_minus_q_lt_lemma d (SD.bn_v a);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (d + 129));
Math.Lemmas.pow2_lt_compat (64 * resLen) (d + 129);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (64 * resLen));
SD.bn_eval_bound m resLen;
assert (SD.bn_v m < pow2 (64 * resLen));
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) (SD.bn_v a * (pow2 256 - S.q));
assert (v c0 = 0 /\ SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
let c1, res = SB.bn_add m e in // e + a * SECP256K1_N_C
SB.bn_add_lemma m e;
assert (v c1 * pow2 (64 * resLen) + SD.bn_v res == SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e);
SD.bn_eval_bound e 4;
assert (SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)
val mul_pow2_256_minus_q_add_lemma_carry_is_zero:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> f:nat -> Lemma
(requires
SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen /\
256 <= f /\ d + 129 <= f /\ f + 1 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
v c = 0 /\ SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma_carry_is_zero len resLen d a e f =
let c0, m = mul_pow2_256_minus_q_lseq_add len resLen a e in
mul_pow2_256_minus_q_add_lemma len resLen d a e;
let rhs_m = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e in
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = rhs_m);
assert (rhs_m < pow2 (d + 129) + pow2 256);
Math.Lemmas.pow2_le_compat f 256;
Math.Lemmas.pow2_le_compat f (d + 129);
Math.Lemmas.pow2_double_sum f;
assert (rhs_m < pow2 (f + 1));
Math.Lemmas.pow2_lt_compat (64 * resLen) (f + 1);
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) rhs_m;
assert (v c0 = 0 /\ SD.bn_v m = rhs_m)
val lemma_m_bound: m:lseq uint64 7 -> Lemma
(requires SD.bn_v m < pow2 385 + pow2 256)
(ensures SD.bn_v (sub m 4 3) < pow2 130)
let lemma_m_bound m =
Math.Lemmas.pow2_lt_compat 385 256;
Math.Lemmas.pow2_double_sum 385;
SD.bn_eval_split_i m 4;
assert (SD.bn_v m - SD.bn_v (sub m 0 4) = pow2 256 * SD.bn_v (sub m 4 3));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub m 4 3)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v m - SD.bn_v (sub m 0 4)) 386 256;
assert (SD.bn_v (sub m 4 3) < pow2 130)
val lemma_p_bound: p:lseq uint64 5 -> Lemma
(requires SD.bn_v p < pow2 259 + pow2 256)
(ensures SD.bn_v (sub p 4 1) < pow2 4)
let lemma_p_bound p =
Math.Lemmas.pow2_lt_compat 259 256;
Math.Lemmas.pow2_double_sum 259;
SD.bn_eval_split_i p 4;
assert (SD.bn_v p - SD.bn_v (sub p 0 4) = pow2 256 * SD.bn_v (sub p 4 1));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub p 4 1)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v p - SD.bn_v (sub p 0 4)) 260 256;
assert (SD.bn_v (sub p 4 1) < pow2 4)
val mod_lseq_before_final_lemma_aux: a:lseq uint64 8 -> Lemma
(let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
v c0 = 0 /\ SD.bn_v m = rhs_a /\
v c1 = 0 /\ SD.bn_v p = rhs_m /\
v c2 * pow2 256 + SD.bn_v r = rhs_p /\ rhs_p < pow2 133 + pow2 256) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_lseq_before_final_lemma_aux: a:lseq uint64 8 -> Lemma
(let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
v c0 = 0 /\ SD.bn_v m = rhs_a /\
v c1 = 0 /\ SD.bn_v p = rhs_m /\
v c2 * pow2 256 + SD.bn_v r = rhs_p /\ rhs_p < pow2 133 + pow2 256) | [] | Hacl.Spec.K256.Scalar.Lemmas.mod_lseq_before_final_lemma_aux | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Lib.Sequence.lseq Lib.IntTypes.uint64 8
-> FStar.Pervasives.Lemma
(ensures
(let _ =
Hacl.Spec.K256.Scalar.mul_pow2_256_minus_q_lseq_add 4
7
(Lib.Sequence.sub a 4 4)
(Lib.Sequence.sub a 0 4)
in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ c0 m = _ in
let _ =
Hacl.Spec.K256.Scalar.mul_pow2_256_minus_q_lseq_add 3
5
(Lib.Sequence.sub m 4 3)
(Lib.Sequence.sub m 0 4)
in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ c1 p = _ in
let _ =
Hacl.Spec.K256.Scalar.mul_pow2_256_minus_q_lseq_add 1
4
(Lib.Sequence.sub p 4 1)
(Lib.Sequence.sub p 0 4)
in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ c2 r = _ in
let rhs_a =
Hacl.Spec.Bignum.Definitions.bn_v (Lib.Sequence.sub a 4 4) *
(Prims.pow2 256 - Spec.K256.PointOps.q) +
Hacl.Spec.Bignum.Definitions.bn_v (Lib.Sequence.sub a 0 4)
in
let rhs_m =
Hacl.Spec.Bignum.Definitions.bn_v (Lib.Sequence.sub m 4 3) *
(Prims.pow2 256 - Spec.K256.PointOps.q) +
Hacl.Spec.Bignum.Definitions.bn_v (Lib.Sequence.sub m 0 4)
in
let rhs_p =
Hacl.Spec.Bignum.Definitions.bn_v (Lib.Sequence.sub p 4 1) *
(Prims.pow2 256 - Spec.K256.PointOps.q) +
Hacl.Spec.Bignum.Definitions.bn_v (Lib.Sequence.sub p 0 4)
in
Lib.IntTypes.v c0 = 0 /\ Hacl.Spec.Bignum.Definitions.bn_v m = rhs_a /\
Lib.IntTypes.v c1 = 0 /\ Hacl.Spec.Bignum.Definitions.bn_v p = rhs_m /\
Lib.IntTypes.v c2 * Prims.pow2 256 + Hacl.Spec.Bignum.Definitions.bn_v r = rhs_p /\
rhs_p < Prims.pow2 133 + Prims.pow2 256)
<:
Type0)
<:
Type0)
<:
Type0)) | {
"end_col": 38,
"end_line": 327,
"start_col": 39,
"start_line": 309
} |
FStar.Pervasives.Lemma | val lemma_b_pow2_256_plus_a_modq (a b: nat) :
Lemma ((b * pow2 256 + a) % S.q = (b * (pow2 256 - S.q) + a) % S.q) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_b_pow2_256_plus_a_modq a b =
calc (==) {
(b * (pow2 256 - S.q) + a) % S.q;
(==) { Math.Lemmas.distributivity_sub_right b (pow2 256) S.q }
(b * pow2 256 - b * S.q + a) % S.q;
(==) { Math.Lemmas.lemma_mod_sub (b * pow2 256 + a) S.q b }
(b * pow2 256 + a) % S.q;
} | val lemma_b_pow2_256_plus_a_modq (a b: nat) :
Lemma ((b * pow2 256 + a) % S.q = (b * (pow2 256 - S.q) + a) % S.q)
let lemma_b_pow2_256_plus_a_modq a b = | false | null | true | calc ( == ) {
(b * (pow2 256 - S.q) + a) % S.q;
( == ) { Math.Lemmas.distributivity_sub_right b (pow2 256) S.q }
(b * pow2 256 - b * S.q + a) % S.q;
( == ) { Math.Lemmas.lemma_mod_sub (b * pow2 256 + a) S.q b }
(b * pow2 256 + a) % S.q;
} | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.nat",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"Prims.op_Modulus",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.K256.PointOps.q",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.distributivity_sub_right",
"Prims.squash",
"FStar.Math.Lemmas.lemma_mod_sub"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end
val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c
val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q))
let mul_pow2_256_minus_q_lemma len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
assert_norm (v t0 + v t1 * pow2 64 = pow2 256 - S.q - pow2 128);
let t01 = create2 t0 t1 in
SD.bn_eval_unfold_i t01 2;
SD.bn_eval_unfold_i t01 1;
SD.bn_eval0 t01;
assert (SD.bn_v t01 = pow2 256 - S.q - pow2 128);
let m0 = SB.bn_mul a t01 in // a * t01
SB.bn_mul_lemma a t01;
assert (SD.bn_v m0 == SD.bn_v a * SD.bn_v t01);
let m10 = create resLen (u64 0) in
let m1 = update_sub m10 2 len a in // a * t2 * pow2 128
SD.bn_update_sub_eval m10 a 2;
assert (SD.bn_v m1 = SD.bn_v m10 - SD.bn_v (sub m10 2 len) * pow2 128 + SD.bn_v a * pow2 128);
SD.bn_eval_zeroes #U64 resLen resLen;
eq_intro (sub m10 2 len) (create len (u64 0));
SD.bn_eval_zeroes #U64 len len;
assert (SD.bn_v m1 = SD.bn_v a * pow2 128);
let c, m2 = SB.bn_add m1 m0 in // a * SECP256K1_N_C
SB.bn_add_lemma m1 m0;
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v m1 + SD.bn_v m0);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * pow2 128 + SD.bn_v a * SD.bn_v t01);
Math.Lemmas.distributivity_add_right (SD.bn_v a) (pow2 128) (SD.bn_v t01);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * (pow2 256 - S.q))
val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129))
let mul_pow2_256_minus_q_lt_lemma p a =
Math.Lemmas.lemma_mult_lt_right (pow2 256 - S.q) a (pow2 p);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.lemma_mult_lt_left (pow2 p) (pow2 256 - S.q) (pow2 129);
Math.Lemmas.pow2_plus p 129
val carry_is_zero (c d e a:nat) : Lemma
(requires
a < pow2 d /\ e < pow2 d /\
c * pow2 d + e = a)
(ensures c = 0)
let carry_is_zero c d e a = ()
val mul_pow2_256_minus_q_add_lemma:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> Lemma
(requires SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma len resLen d a e =
let c0, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
mul_pow2_256_minus_q_lemma len resLen a;
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
mul_pow2_256_minus_q_lt_lemma d (SD.bn_v a);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (d + 129));
Math.Lemmas.pow2_lt_compat (64 * resLen) (d + 129);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (64 * resLen));
SD.bn_eval_bound m resLen;
assert (SD.bn_v m < pow2 (64 * resLen));
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) (SD.bn_v a * (pow2 256 - S.q));
assert (v c0 = 0 /\ SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
let c1, res = SB.bn_add m e in // e + a * SECP256K1_N_C
SB.bn_add_lemma m e;
assert (v c1 * pow2 (64 * resLen) + SD.bn_v res == SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e);
SD.bn_eval_bound e 4;
assert (SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)
val mul_pow2_256_minus_q_add_lemma_carry_is_zero:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> f:nat -> Lemma
(requires
SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen /\
256 <= f /\ d + 129 <= f /\ f + 1 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
v c = 0 /\ SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma_carry_is_zero len resLen d a e f =
let c0, m = mul_pow2_256_minus_q_lseq_add len resLen a e in
mul_pow2_256_minus_q_add_lemma len resLen d a e;
let rhs_m = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e in
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = rhs_m);
assert (rhs_m < pow2 (d + 129) + pow2 256);
Math.Lemmas.pow2_le_compat f 256;
Math.Lemmas.pow2_le_compat f (d + 129);
Math.Lemmas.pow2_double_sum f;
assert (rhs_m < pow2 (f + 1));
Math.Lemmas.pow2_lt_compat (64 * resLen) (f + 1);
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) rhs_m;
assert (v c0 = 0 /\ SD.bn_v m = rhs_m)
val lemma_m_bound: m:lseq uint64 7 -> Lemma
(requires SD.bn_v m < pow2 385 + pow2 256)
(ensures SD.bn_v (sub m 4 3) < pow2 130)
let lemma_m_bound m =
Math.Lemmas.pow2_lt_compat 385 256;
Math.Lemmas.pow2_double_sum 385;
SD.bn_eval_split_i m 4;
assert (SD.bn_v m - SD.bn_v (sub m 0 4) = pow2 256 * SD.bn_v (sub m 4 3));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub m 4 3)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v m - SD.bn_v (sub m 0 4)) 386 256;
assert (SD.bn_v (sub m 4 3) < pow2 130)
val lemma_p_bound: p:lseq uint64 5 -> Lemma
(requires SD.bn_v p < pow2 259 + pow2 256)
(ensures SD.bn_v (sub p 4 1) < pow2 4)
let lemma_p_bound p =
Math.Lemmas.pow2_lt_compat 259 256;
Math.Lemmas.pow2_double_sum 259;
SD.bn_eval_split_i p 4;
assert (SD.bn_v p - SD.bn_v (sub p 0 4) = pow2 256 * SD.bn_v (sub p 4 1));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub p 4 1)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v p - SD.bn_v (sub p 0 4)) 260 256;
assert (SD.bn_v (sub p 4 1) < pow2 4)
val mod_lseq_before_final_lemma_aux: a:lseq uint64 8 -> Lemma
(let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
v c0 = 0 /\ SD.bn_v m = rhs_a /\
v c1 = 0 /\ SD.bn_v p = rhs_m /\
v c2 * pow2 256 + SD.bn_v r = rhs_p /\ rhs_p < pow2 133 + pow2 256)
let mod_lseq_before_final_lemma_aux a =
let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
SD.bn_eval_bound (sub a 4 4) 4;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 4 7 256 (sub a 4 4) (sub a 0 4) 385;
assert (v c0 = 0 /\ SD.bn_v m = rhs_a /\ rhs_a < pow2 385 + pow2 256);
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
lemma_m_bound m;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 3 5 130 (sub m 4 3) (sub m 0 4) 259;
assert (v c1 = 0 /\ SD.bn_v p = rhs_m); ///\ rhs_m < pow2 259 + pow2 256);
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
lemma_p_bound p;
mul_pow2_256_minus_q_add_lemma 1 4 4 (sub p 4 1) (sub p 0 4);
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
assert (v c2 * pow2 256 + SD.bn_v r = rhs_p);
assert (rhs_p < pow2 133 + pow2 256)
val lemma_b_pow2_256_plus_a_modq (a b: nat) :
Lemma ((b * pow2 256 + a) % S.q = (b * (pow2 256 - S.q) + a) % S.q) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_b_pow2_256_plus_a_modq (a b: nat) :
Lemma ((b * pow2 256 + a) % S.q = (b * (pow2 256 - S.q) + a) % S.q) | [] | Hacl.Spec.K256.Scalar.Lemmas.lemma_b_pow2_256_plus_a_modq | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Prims.nat -> b: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
(b * Prims.pow2 256 + a) % Spec.K256.PointOps.q =
(b * (Prims.pow2 256 - Spec.K256.PointOps.q) + a) % Spec.K256.PointOps.q) | {
"end_col": 3,
"end_line": 340,
"start_col": 2,
"start_line": 334
} |
FStar.Pervasives.Lemma | val qmul_shift_383_mod_2_lemma : l:lseq uint64 8 ->
Lemma (v l.[5] / pow2 63 = SD.bn_v l / pow2 383 % 2) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qmul_shift_383_mod_2_lemma l =
calc (==) {
v l.[5] / pow2 63;
(==) { SD.bn_eval_index l 5 }
SD.bn_v l / pow2 320 % pow2 64 / pow2 63;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (SD.bn_v l) 320 384 }
SD.bn_v l % pow2 384 / pow2 320 / pow2 63;
(==) { Math.Lemmas.division_multiplication_lemma (SD.bn_v l % pow2 384) (pow2 320) (pow2 63) }
SD.bn_v l % pow2 384 / (pow2 320 * pow2 63);
(==) { Math.Lemmas.pow2_plus 320 63 }
SD.bn_v l % pow2 384 / pow2 383;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (SD.bn_v l) 383 384 }
SD.bn_v l / pow2 383 % pow2 1;
(==) { assert_norm (pow2 1 = 2) }
SD.bn_v l / pow2 383 % 2;
} | val qmul_shift_383_mod_2_lemma : l:lseq uint64 8 ->
Lemma (v l.[5] / pow2 63 = SD.bn_v l / pow2 383 % 2)
let qmul_shift_383_mod_2_lemma l = | false | null | true | calc ( == ) {
v l.[ 5 ] / pow2 63;
( == ) { SD.bn_eval_index l 5 }
SD.bn_v l / pow2 320 % pow2 64 / pow2 63;
( == ) { Math.Lemmas.pow2_modulo_division_lemma_1 (SD.bn_v l) 320 384 }
SD.bn_v l % pow2 384 / pow2 320 / pow2 63;
( == ) { Math.Lemmas.division_multiplication_lemma (SD.bn_v l % pow2 384) (pow2 320) (pow2 63) }
SD.bn_v l % pow2 384 / (pow2 320 * pow2 63);
( == ) { Math.Lemmas.pow2_plus 320 63 }
SD.bn_v l % pow2 384 / pow2 383;
( == ) { Math.Lemmas.pow2_modulo_division_lemma_1 (SD.bn_v l) 383 384 }
SD.bn_v l / pow2 383 % pow2 1;
( == ) { assert_norm (pow2 1 = 2) }
SD.bn_v l / pow2 383 % 2;
} | {
"checked_file": "Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.Lemmas.fst"
} | [
"lemma"
] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"Prims.op_Division",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.Sequence.op_String_Access",
"Prims.pow2",
"Prims.op_Modulus",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Mul.op_Star",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Hacl.Spec.Bignum.Definitions.bn_eval_index",
"Prims.squash",
"FStar.Math.Lemmas.pow2_modulo_division_lemma_1",
"FStar.Math.Lemmas.division_multiplication_lemma",
"FStar.Math.Lemmas.pow2_plus",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality"
] | [] | module Hacl.Spec.K256.Scalar.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.K256.Scalar
module S = Spec.K256
module SD = Hacl.Spec.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val qas_nat4_is_qas_nat (f:qelem_lseq) :
Lemma (SD.bn_v f == qas_nat4 (f.[0], f.[1], f.[2], f.[3]))
let qas_nat4_is_qas_nat f =
SD.bn_eval_unfold_i f 4;
SD.bn_eval_unfold_i f 3;
SD.bn_eval_unfold_i f 2;
SD.bn_eval_unfold_i f 1;
SD.bn_eval0 f
val qas_nat4_inj (f1 f2:qelem4) : Lemma
(requires qas_nat4 f1 = qas_nat4 f2)
(ensures
(let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
a0 == b0 /\ a1 == b1 /\ a2 == b2 /\ a3 == b3))
let qas_nat4_inj f1 f2 =
let (a0,a1,a2,a3) = f1 in
let (b0,b1,b2,b3) = f2 in
let bf1 = create4 a0 a1 a2 a3 in
let bf2 = create4 b0 b1 b2 b3 in
qas_nat4_is_qas_nat bf1;
qas_nat4_is_qas_nat bf2;
SD.bn_eval_inj 4 bf1 bf2
#push-options "--ifuel 1"
val is_qelem_zero_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_zero_vartime4 f == (qas_nat4 f = 0))
let is_qelem_zero_vartime4_lemma f = ()
val is_qelem_lt_q_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_q_vartime4 f == (qas_nat4 f < S.q))
let is_qelem_lt_q_vartime4_lemma f =
assert_norm (0xbfd25e8cd0364141 + 0xbaaedce6af48a03b * pow2 64 +
0xfffffffffffffffe * pow2 128 + 0xffffffffffffffff * pow2 192 = S.q)
val is_qelem_le_q_halved_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_le_q_halved_vartime4 f == (qas_nat4 f <= S.q / 2))
let is_qelem_le_q_halved_vartime4_lemma f =
assert_norm (0xdfe92f46681b20a0 + 0x5d576e7357a4501d * pow2 64 +
0xffffffffffffffff * pow2 128 + 0x7fffffffffffffff * pow2 192 = S.q / 2)
val is_qelem_eq_vartime4_lemma: f1:qelem4 -> f2:qelem4 ->
Lemma (is_qelem_eq_vartime4 f1 f2 == (qas_nat4 f1 = qas_nat4 f2))
let is_qelem_eq_vartime4_lemma f1 f2 =
if qas_nat4 f1 = qas_nat4 f2 then qas_nat4_inj f1 f2
#pop-options
val is_qelem_lt_pow2_128_vartime4_lemma: f:qelem4 ->
Lemma (is_qelem_lt_pow2_128_vartime4 f == (qas_nat4 f < pow2 128))
let is_qelem_lt_pow2_128_vartime4_lemma f =
let (f0, f1, f2, f3) = f in
assert (qas_nat4 f == v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192);
assert (v f0 + v f1 * pow2 64 < pow2 128);
if v f2 = 0 && v f3 = 0 then ()
else begin
Math.Lemmas.pow2_lt_compat 192 128;
assert (pow2 128 <= qas_nat4 f) end
val lemma_check_overflow: b:nat{b < pow2 256} ->
Lemma (let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
overflow = (if b < S.q then 0 else 1))
let lemma_check_overflow b =
let overflow = (b + (pow2 256 - S.q)) / pow2 256 in
if b < S.q then begin
assert (pow2 256 + b - S.q < pow2 256);
assert (pow2 256 - S.q <= pow2 256 + b - S.q);
assert_norm (0 < pow2 256 - S.q);
Math.Lemmas.small_div (pow2 256 + b - S.q) (pow2 256);
assert (overflow = 0) end
else begin
assert (pow2 256 <= pow2 256 + b - S.q);
Math.Lemmas.lemma_div_le (pow2 256) (pow2 256 + b - S.q) (pow2 256);
Math.Lemmas.cancel_mul_div 1 (pow2 256);
assert (1 <= overflow);
assert (pow2 256 + b - S.q < pow2 256 + pow2 256 - S.q);
assert (pow2 256 + b - S.q <= pow2 256 + pow2 256 - S.q - 1);
Math.Lemmas.lemma_div_le (pow2 256 + b - S.q) (pow2 256 + pow2 256 - S.q - 1) (pow2 256);
assert_norm ((pow2 256 + pow2 256 - S.q - 1) / pow2 256 = 1);
assert (overflow <= 1) end
val lemma_get_carry_from_bn_add: r:nat{r < pow2 256} -> c:nat ->
Lemma ((r + c * pow2 256) / pow2 256 = c)
let lemma_get_carry_from_bn_add r c =
Math.Lemmas.lemma_div_plus r c (pow2 256);
Math.Lemmas.small_div r (pow2 256)
val mod_short_lseq_lemma_aux: a:qelem_lseq -> out:qelem_lseq -> c:BB.carry U64 -> Lemma
(requires v c * pow2 256 + SD.bn_v out = SD.bn_v a + pow2 256 - S.q)
(ensures SD.bn_v (map2 (BB.mask_select (u64 0 -. c)) out a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma_aux a out c =
assert_norm (pow2 256 - S.q < S.q);
let mask = u64 0 -. c in
let out1 = map2 (BB.mask_select mask) out a in
assert (v mask = (if v c = 0 then 0 else ones_v U64));
BB.lseq_mask_select_lemma out a mask;
assert (out1 == (if v c = 0 then a else out));
SD.bn_eval_bound a 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v a);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c);
assert (v c = (if SD.bn_v a < S.q then 0 else 1));
if SD.bn_v a < S.q then begin
assert (SD.bn_v out1 == SD.bn_v a);
Math.Lemmas.small_mod (SD.bn_v a) S.q end
else begin
assert (SD.bn_v out1 == SD.bn_v a + (pow2 256 - S.q) - pow2 256);
Math.Lemmas.lemma_mod_sub (SD.bn_v a) S.q 1;
assert (SD.bn_v out1 % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v out1) S.q end
val mod_short_lseq_lemma: a:qelem_lseq ->
Lemma (SD.bn_v (mod_short_lseq a) == SD.bn_v a % S.q)
let mod_short_lseq_lemma a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
SB.bn_add_lemma a tmp;
assert (v c * pow2 256 + SD.bn_v out = SD.bn_v a + SD.bn_v tmp);
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp == pow2 256 - S.q);
mod_short_lseq_lemma_aux a out c
val mul_pow2_256_minus_q_lemma: len:size_nat -> resLen:size_nat{2 + len <= resLen} -> a:lseq uint64 len ->
Lemma (let c, res = mul_pow2_256_minus_q_lseq len resLen a in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q))
let mul_pow2_256_minus_q_lemma len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
assert_norm (v t0 + v t1 * pow2 64 = pow2 256 - S.q - pow2 128);
let t01 = create2 t0 t1 in
SD.bn_eval_unfold_i t01 2;
SD.bn_eval_unfold_i t01 1;
SD.bn_eval0 t01;
assert (SD.bn_v t01 = pow2 256 - S.q - pow2 128);
let m0 = SB.bn_mul a t01 in // a * t01
SB.bn_mul_lemma a t01;
assert (SD.bn_v m0 == SD.bn_v a * SD.bn_v t01);
let m10 = create resLen (u64 0) in
let m1 = update_sub m10 2 len a in // a * t2 * pow2 128
SD.bn_update_sub_eval m10 a 2;
assert (SD.bn_v m1 = SD.bn_v m10 - SD.bn_v (sub m10 2 len) * pow2 128 + SD.bn_v a * pow2 128);
SD.bn_eval_zeroes #U64 resLen resLen;
eq_intro (sub m10 2 len) (create len (u64 0));
SD.bn_eval_zeroes #U64 len len;
assert (SD.bn_v m1 = SD.bn_v a * pow2 128);
let c, m2 = SB.bn_add m1 m0 in // a * SECP256K1_N_C
SB.bn_add_lemma m1 m0;
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v m1 + SD.bn_v m0);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * pow2 128 + SD.bn_v a * SD.bn_v t01);
Math.Lemmas.distributivity_add_right (SD.bn_v a) (pow2 128) (SD.bn_v t01);
assert (v c * pow2 (64 * resLen) + SD.bn_v m2 = SD.bn_v a * (pow2 256 - S.q))
val mul_pow2_256_minus_q_lt_lemma: p:nat -> a:nat{a < pow2 p} ->
Lemma (a * (pow2 256 - S.q) < pow2 (p + 129))
let mul_pow2_256_minus_q_lt_lemma p a =
Math.Lemmas.lemma_mult_lt_right (pow2 256 - S.q) a (pow2 p);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.lemma_mult_lt_left (pow2 p) (pow2 256 - S.q) (pow2 129);
Math.Lemmas.pow2_plus p 129
val carry_is_zero (c d e a:nat) : Lemma
(requires
a < pow2 d /\ e < pow2 d /\
c * pow2 d + e = a)
(ensures c = 0)
let carry_is_zero c d e a = ()
val mul_pow2_256_minus_q_add_lemma:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> Lemma
(requires SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma len resLen d a e =
let c0, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
mul_pow2_256_minus_q_lemma len resLen a;
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
mul_pow2_256_minus_q_lt_lemma d (SD.bn_v a);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (d + 129));
Math.Lemmas.pow2_lt_compat (64 * resLen) (d + 129);
assert (SD.bn_v a * (pow2 256 - S.q) < pow2 (64 * resLen));
SD.bn_eval_bound m resLen;
assert (SD.bn_v m < pow2 (64 * resLen));
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) (SD.bn_v a * (pow2 256 - S.q));
assert (v c0 = 0 /\ SD.bn_v m = SD.bn_v a * (pow2 256 - S.q));
let c1, res = SB.bn_add m e in // e + a * SECP256K1_N_C
SB.bn_add_lemma m e;
assert (v c1 * pow2 (64 * resLen) + SD.bn_v res == SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e);
SD.bn_eval_bound e 4;
assert (SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256)
val mul_pow2_256_minus_q_add_lemma_carry_is_zero:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen} -> d:nat
-> a:lseq uint64 len -> e:lseq uint64 4 -> f:nat -> Lemma
(requires
SD.bn_v a < pow2 d /\ d + 129 < 64 * resLen /\
256 <= f /\ d + 129 <= f /\ f + 1 < 64 * resLen)
(ensures (let c, res = mul_pow2_256_minus_q_lseq_add len resLen a e in
v c * pow2 (64 * resLen) + SD.bn_v res = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e /\
v c = 0 /\ SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e < pow2 (d + 129) + pow2 256))
let mul_pow2_256_minus_q_add_lemma_carry_is_zero len resLen d a e f =
let c0, m = mul_pow2_256_minus_q_lseq_add len resLen a e in
mul_pow2_256_minus_q_add_lemma len resLen d a e;
let rhs_m = SD.bn_v a * (pow2 256 - S.q) + SD.bn_v e in
assert (v c0 * pow2 (64 * resLen) + SD.bn_v m = rhs_m);
assert (rhs_m < pow2 (d + 129) + pow2 256);
Math.Lemmas.pow2_le_compat f 256;
Math.Lemmas.pow2_le_compat f (d + 129);
Math.Lemmas.pow2_double_sum f;
assert (rhs_m < pow2 (f + 1));
Math.Lemmas.pow2_lt_compat (64 * resLen) (f + 1);
carry_is_zero (v c0) (64 * resLen) (SD.bn_v m) rhs_m;
assert (v c0 = 0 /\ SD.bn_v m = rhs_m)
val lemma_m_bound: m:lseq uint64 7 -> Lemma
(requires SD.bn_v m < pow2 385 + pow2 256)
(ensures SD.bn_v (sub m 4 3) < pow2 130)
let lemma_m_bound m =
Math.Lemmas.pow2_lt_compat 385 256;
Math.Lemmas.pow2_double_sum 385;
SD.bn_eval_split_i m 4;
assert (SD.bn_v m - SD.bn_v (sub m 0 4) = pow2 256 * SD.bn_v (sub m 4 3));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub m 4 3)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v m - SD.bn_v (sub m 0 4)) 386 256;
assert (SD.bn_v (sub m 4 3) < pow2 130)
val lemma_p_bound: p:lseq uint64 5 -> Lemma
(requires SD.bn_v p < pow2 259 + pow2 256)
(ensures SD.bn_v (sub p 4 1) < pow2 4)
let lemma_p_bound p =
Math.Lemmas.pow2_lt_compat 259 256;
Math.Lemmas.pow2_double_sum 259;
SD.bn_eval_split_i p 4;
assert (SD.bn_v p - SD.bn_v (sub p 0 4) = pow2 256 * SD.bn_v (sub p 4 1));
Math.Lemmas.cancel_mul_div (SD.bn_v (sub p 4 1)) (pow2 256);
Math.Lemmas.lemma_div_lt (SD.bn_v p - SD.bn_v (sub p 0 4)) 260 256;
assert (SD.bn_v (sub p 4 1) < pow2 4)
val mod_lseq_before_final_lemma_aux: a:lseq uint64 8 -> Lemma
(let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
v c0 = 0 /\ SD.bn_v m = rhs_a /\
v c1 = 0 /\ SD.bn_v p = rhs_m /\
v c2 * pow2 256 + SD.bn_v r = rhs_p /\ rhs_p < pow2 133 + pow2 256)
let mod_lseq_before_final_lemma_aux a =
let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
SD.bn_eval_bound (sub a 4 4) 4;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 4 7 256 (sub a 4 4) (sub a 0 4) 385;
assert (v c0 = 0 /\ SD.bn_v m = rhs_a /\ rhs_a < pow2 385 + pow2 256);
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
lemma_m_bound m;
mul_pow2_256_minus_q_add_lemma_carry_is_zero 3 5 130 (sub m 4 3) (sub m 0 4) 259;
assert (v c1 = 0 /\ SD.bn_v p = rhs_m); ///\ rhs_m < pow2 259 + pow2 256);
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
lemma_p_bound p;
mul_pow2_256_minus_q_add_lemma 1 4 4 (sub p 4 1) (sub p 0 4);
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
assert (v c2 * pow2 256 + SD.bn_v r = rhs_p);
assert (rhs_p < pow2 133 + pow2 256)
val lemma_b_pow2_256_plus_a_modq (a b: nat) :
Lemma ((b * pow2 256 + a) % S.q = (b * (pow2 256 - S.q) + a) % S.q)
let lemma_b_pow2_256_plus_a_modq a b =
calc (==) {
(b * (pow2 256 - S.q) + a) % S.q;
(==) { Math.Lemmas.distributivity_sub_right b (pow2 256) S.q }
(b * pow2 256 - b * S.q + a) % S.q;
(==) { Math.Lemmas.lemma_mod_sub (b * pow2 256 + a) S.q b }
(b * pow2 256 + a) % S.q;
}
val lemma_b_pow2_256_plus_a_modq_lseq: len:size_nat{4 <= len} -> a:lseq uint64 len ->
Lemma (SD.bn_v a % S.q == (SD.bn_v (sub a 4 (len - 4)) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4)) % S.q)
let lemma_b_pow2_256_plus_a_modq_lseq len a =
lemma_b_pow2_256_plus_a_modq (SD.bn_v (sub a 0 4)) (SD.bn_v (sub a 4 (len - 4)));
SD.bn_eval_split_i a 4
val mod_lseq_before_final_lemma: a:lseq uint64 8 ->
Lemma (let (c, res) = mod_lseq_before_final a in
v c * pow2 256 + SD.bn_v res < pow2 133 + pow2 256 /\
(v c * pow2 256 + SD.bn_v res) % S.q == SD.bn_v a % S.q)
let mod_lseq_before_final_lemma a =
let c0, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
let c1, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
let c2, r = mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) in // p[0..3] + p[4] * SECP256K1_N_C
let rhs_a = SD.bn_v (sub a 4 4) * (pow2 256 - S.q) + SD.bn_v (sub a 0 4) in
let rhs_m = SD.bn_v (sub m 4 3) * (pow2 256 - S.q) + SD.bn_v (sub m 0 4) in
let rhs_p = SD.bn_v (sub p 4 1) * (pow2 256 - S.q) + SD.bn_v (sub p 0 4) in
mod_lseq_before_final_lemma_aux a;
assert (v c0 = 0 /\ SD.bn_v m = rhs_a);
assert (v c1 = 0 /\ SD.bn_v p = rhs_m);
assert (v c2 * pow2 256 + SD.bn_v r = rhs_p);
assert (rhs_p < pow2 133 + pow2 256);
calc (==) { //(v c2 * pow2 256 + SD.bn_v r) % S.q;
rhs_p % S.q;
(==) { lemma_b_pow2_256_plus_a_modq_lseq 5 p }
SD.bn_v p % S.q;
(==) { }
rhs_m % S.q;
(==) { lemma_b_pow2_256_plus_a_modq_lseq 7 m }
SD.bn_v m % S.q;
(==) { }
rhs_a % S.q;
(==) { lemma_b_pow2_256_plus_a_modq_lseq 8 a }
SD.bn_v a % S.q;
}
val mod_lseq_lemma: a:lseq uint64 8 -> Lemma (SD.bn_v (mod_lseq a) == SD.bn_v a % S.q)
let mod_lseq_lemma a =
let c0, r = mod_lseq_before_final a in
mod_lseq_before_final_lemma a;
assert ((v c0 * pow2 256 + SD.bn_v r) % S.q == SD.bn_v a % S.q);
assert (v c0 * pow2 256 + SD.bn_v r < pow2 256 + pow2 133);
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
qas_nat4_is_qas_nat tmp;
assert (SD.bn_v tmp = pow2 256 - S.q);
let c1, out = SB.bn_add r tmp in
SB.bn_add_lemma r tmp;
assert (v c1 * pow2 256 + SD.bn_v out = SD.bn_v r + pow2 256 - S.q);
Math.Lemmas.small_mod (v c0 + v c1) (pow2 64);
assert (v (c0 +. c1) == v c0 + v c1);
let mask = u64 0 -. (c0 +. c1) in
//let mask = u64 0 -. c1 in
let res = map2 (BB.mask_select mask) out r in
SD.bn_eval_bound r 4;
SD.bn_eval_bound out 4;
lemma_check_overflow (SD.bn_v r);
lemma_get_carry_from_bn_add (SD.bn_v out) (v c1);
assert (v c1 = (if SD.bn_v r < S.q then 0 else 1));
if v c0 = 0 then begin
assert (SD.bn_v r % S.q == SD.bn_v a % S.q);
assert (res == mod_short_lseq r);
mod_short_lseq_lemma r;
assert (SD.bn_v res == SD.bn_v a % S.q) end
else begin // v c0 = 1 ==> v c1 = 0
assert ((pow2 256 + SD.bn_v r) % S.q == SD.bn_v a % S.q);
assert (v c1 * pow2 256 + SD.bn_v out = SD.bn_v r + pow2 256 - S.q);
assert (SD.bn_v r < pow2 133);
assert_norm (pow2 256 - S.q < pow2 129);
Math.Lemmas.pow2_lt_compat 133 129;
Math.Lemmas.pow2_double_sum 133;
assert (SD.bn_v r + pow2 256 - S.q < pow2 134);
Math.Lemmas.pow2_lt_compat 256 134;
carry_is_zero (v c1) 256 (SD.bn_v out) (SD.bn_v r + pow2 256 - S.q);
assert (v c1 = 0);
assert_norm (pow2 134 < S.q);
assert (SD.bn_v r + pow2 256 - S.q < S.q);
BB.lseq_mask_select_lemma out r mask;
assert (SD.bn_v res == SD.bn_v r + pow2 256 - S.q);
Math.Lemmas.lemma_mod_sub (pow2 256 + SD.bn_v r) S.q 1;
assert (SD.bn_v res % S.q == SD.bn_v a % S.q);
Math.Lemmas.small_mod (SD.bn_v res) S.q end
val qmul_shift_383_mod_2_lemma : l:lseq uint64 8 ->
Lemma (v l.[5] / pow2 63 = SD.bn_v l / pow2 383 % 2) | false | false | Hacl.Spec.K256.Scalar.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qmul_shift_383_mod_2_lemma : l:lseq uint64 8 ->
Lemma (v l.[5] / pow2 63 = SD.bn_v l / pow2 383 % 2) | [] | Hacl.Spec.K256.Scalar.Lemmas.qmul_shift_383_mod_2_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | l: Lib.Sequence.lseq Lib.IntTypes.uint64 8
-> FStar.Pervasives.Lemma
(ensures
Lib.IntTypes.v l.[ 5 ] / Prims.pow2 63 =
Hacl.Spec.Bignum.Definitions.bn_v l / Prims.pow2 383 % 2) | {
"end_col": 3,
"end_line": 457,
"start_col": 2,
"start_line": 443
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Binding",
"short_module": null
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_expr (e:expr') = e, A.dummy_range | let mk_expr (e: expr') = | false | null | false | e, A.dummy_range | {
"checked_file": "Target.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked",
"Binding.fsti.checked",
"Ast.fst.checked"
],
"interface_file": false,
"source_file": "Target.fsti"
} | [
"total"
] | [
"Target.expr'",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"Ast.pos",
"Ast.dummy_range"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Target
(* The abstract syntax for the code produced by 3d *)
open FStar.All
module A = Ast
open Binding
/// The same as A.op, but with `SizeOf` removed
/// and arithmetic operators resolved to their types
type op =
| Eq
| Neq
| And
| Or
| Not
| Plus of A.integer_type
| Minus of A.integer_type
| Mul of A.integer_type
| Division of A.integer_type
| Remainder of A.integer_type
| BitwiseAnd of A.integer_type
| BitwiseXor of A.integer_type
| BitwiseOr of A.integer_type
| BitwiseNot of A.integer_type
| ShiftRight of A.integer_type
| ShiftLeft of A.integer_type
| LT of A.integer_type
| GT of A.integer_type
| LE of A.integer_type
| GE of A.integer_type
| IfThenElse
| BitFieldOf: size: int -> order: A.bitfield_bit_order -> op //BitFieldOf(i, from, to)
| Cast : from:A.integer_type -> to:A.integer_type -> op
| Ext of string
/// Same as A.expr, but with `This` removed
///
/// Carrying around the range information from AST.expr so that we
/// can report errors in terms of their 3d file locations
noeq
type expr' =
| Constant : c:A.constant -> expr'
| Identifier : i:A.ident -> expr'
| App : hd:op -> args:list expr -> expr'
| Record : type_name:A.ident -> list (A.ident * expr) -> expr'
and expr = expr' & A.range | false | true | Target.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_expr : e: Target.expr' -> Target.expr' * (Ast.pos * Ast.pos) | [] | Target.mk_expr | {
"file_name": "src/3d/Target.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | e: Target.expr' -> Target.expr' * (Ast.pos * Ast.pos) | {
"end_col": 40,
"end_line": 64,
"start_col": 24,
"start_line": 64
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Binding",
"short_module": null
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let field_typ = typ | let field_typ = | false | null | false | typ | {
"checked_file": "Target.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked",
"Binding.fsti.checked",
"Ast.fst.checked"
],
"interface_file": false,
"source_file": "Target.fsti"
} | [
"total"
] | [
"Target.typ"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Target
(* The abstract syntax for the code produced by 3d *)
open FStar.All
module A = Ast
open Binding
/// The same as A.op, but with `SizeOf` removed
/// and arithmetic operators resolved to their types
type op =
| Eq
| Neq
| And
| Or
| Not
| Plus of A.integer_type
| Minus of A.integer_type
| Mul of A.integer_type
| Division of A.integer_type
| Remainder of A.integer_type
| BitwiseAnd of A.integer_type
| BitwiseXor of A.integer_type
| BitwiseOr of A.integer_type
| BitwiseNot of A.integer_type
| ShiftRight of A.integer_type
| ShiftLeft of A.integer_type
| LT of A.integer_type
| GT of A.integer_type
| LE of A.integer_type
| GE of A.integer_type
| IfThenElse
| BitFieldOf: size: int -> order: A.bitfield_bit_order -> op //BitFieldOf(i, from, to)
| Cast : from:A.integer_type -> to:A.integer_type -> op
| Ext of string
/// Same as A.expr, but with `This` removed
///
/// Carrying around the range information from AST.expr so that we
/// can report errors in terms of their 3d file locations
noeq
type expr' =
| Constant : c:A.constant -> expr'
| Identifier : i:A.ident -> expr'
| App : hd:op -> args:list expr -> expr'
| Record : type_name:A.ident -> list (A.ident * expr) -> expr'
and expr = expr' & A.range
let mk_expr (e:expr') = e, A.dummy_range
type lam a = (option A.ident) & a
noeq
type atomic_action =
| Action_return of expr
| Action_abort
| Action_field_pos_64
| Action_field_pos_32
| Action_field_ptr
| Action_field_ptr_after: sz: expr -> write_to:A.ident -> atomic_action
| Action_field_ptr_after_with_setter: sz: expr -> write_to_field:A.ident -> write_to_object:expr -> atomic_action
| Action_deref of A.ident
| Action_assignment : lhs:A.ident -> rhs:expr -> atomic_action
| Action_call : f:A.ident -> args:list expr -> atomic_action
noeq
type action =
| Atomic_action of atomic_action
| Action_seq : hd:atomic_action -> tl:action -> action
| Action_ite : hd:expr -> then_:action -> else_:action -> action
| Action_let : i:A.ident -> a:atomic_action -> k:action -> action
| Action_act : action -> action
(* A subset of F* types that the translation targets *)
noeq
type typ =
| T_false : typ
| T_app : hd:A.ident -> A.t_kind -> args:list index -> typ
| T_dep_pair : dfst:typ -> dsnd:(A.ident & typ) -> typ
| T_refine : base:typ -> refinement:lam expr -> typ
| T_if_else : e:expr -> t:typ -> f:typ -> typ
| T_pointer : typ -> typ
| T_with_action: typ -> action -> typ
| T_with_dep_action: typ -> a:lam action -> typ
| T_with_comment: typ -> A.comments -> typ
(* An index is an F* type or an expression
-- we reuse Ast expressions for this
*)
and index = either typ expr | false | true | Target.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val field_typ : Type0 | [] | Target.field_typ | {
"file_name": "src/3d/Target.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | Type0 | {
"end_col": 19,
"end_line": 107,
"start_col": 16,
"start_line": 107
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Binding",
"short_module": null
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let definition = A.ident * list param * typ * expr | let definition = | false | null | false | ((A.ident * list param) * typ) * expr | {
"checked_file": "Target.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked",
"Binding.fsti.checked",
"Ast.fst.checked"
],
"interface_file": false,
"source_file": "Target.fsti"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple4",
"Ast.ident",
"Prims.list",
"Target.param",
"Target.typ",
"Target.expr"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Target
(* The abstract syntax for the code produced by 3d *)
open FStar.All
module A = Ast
open Binding
/// The same as A.op, but with `SizeOf` removed
/// and arithmetic operators resolved to their types
type op =
| Eq
| Neq
| And
| Or
| Not
| Plus of A.integer_type
| Minus of A.integer_type
| Mul of A.integer_type
| Division of A.integer_type
| Remainder of A.integer_type
| BitwiseAnd of A.integer_type
| BitwiseXor of A.integer_type
| BitwiseOr of A.integer_type
| BitwiseNot of A.integer_type
| ShiftRight of A.integer_type
| ShiftLeft of A.integer_type
| LT of A.integer_type
| GT of A.integer_type
| LE of A.integer_type
| GE of A.integer_type
| IfThenElse
| BitFieldOf: size: int -> order: A.bitfield_bit_order -> op //BitFieldOf(i, from, to)
| Cast : from:A.integer_type -> to:A.integer_type -> op
| Ext of string
/// Same as A.expr, but with `This` removed
///
/// Carrying around the range information from AST.expr so that we
/// can report errors in terms of their 3d file locations
noeq
type expr' =
| Constant : c:A.constant -> expr'
| Identifier : i:A.ident -> expr'
| App : hd:op -> args:list expr -> expr'
| Record : type_name:A.ident -> list (A.ident * expr) -> expr'
and expr = expr' & A.range
let mk_expr (e:expr') = e, A.dummy_range
type lam a = (option A.ident) & a
noeq
type atomic_action =
| Action_return of expr
| Action_abort
| Action_field_pos_64
| Action_field_pos_32
| Action_field_ptr
| Action_field_ptr_after: sz: expr -> write_to:A.ident -> atomic_action
| Action_field_ptr_after_with_setter: sz: expr -> write_to_field:A.ident -> write_to_object:expr -> atomic_action
| Action_deref of A.ident
| Action_assignment : lhs:A.ident -> rhs:expr -> atomic_action
| Action_call : f:A.ident -> args:list expr -> atomic_action
noeq
type action =
| Atomic_action of atomic_action
| Action_seq : hd:atomic_action -> tl:action -> action
| Action_ite : hd:expr -> then_:action -> else_:action -> action
| Action_let : i:A.ident -> a:atomic_action -> k:action -> action
| Action_act : action -> action
(* A subset of F* types that the translation targets *)
noeq
type typ =
| T_false : typ
| T_app : hd:A.ident -> A.t_kind -> args:list index -> typ
| T_dep_pair : dfst:typ -> dsnd:(A.ident & typ) -> typ
| T_refine : base:typ -> refinement:lam expr -> typ
| T_if_else : e:expr -> t:typ -> f:typ -> typ
| T_pointer : typ -> typ
| T_with_action: typ -> action -> typ
| T_with_dep_action: typ -> a:lam action -> typ
| T_with_comment: typ -> A.comments -> typ
(* An index is an F* type or an expression
-- we reuse Ast expressions for this
*)
and index = either typ expr
let field_typ = typ
type param = A.ident & typ
noeq
type struct_field = {
sf_dependence: bool;
sf_ident: A.ident;
sf_typ: field_typ
}
type field = struct_field
noeq
type typedef_body =
| TD_abbrev : typ -> typedef_body
| TD_struct : list field -> typedef_body
noeq
type typedef_name = {
td_name:A.ident;
td_params:list param;
td_entrypoint:bool
}
type typedef = typedef_name & typedef_body
////////////////////////////////////////////////////////////////////////////////
noeq
type parser_kind' =
| PK_return
| PK_impos
| PK_base : hd:A.ident -> parser_kind'
| PK_list : parser_kind'
| PK_t_at_most: parser_kind'
| PK_t_exact : parser_kind'
| PK_filter : k:parser_kind -> parser_kind'
| PK_and_then : k1:parser_kind -> k2:parser_kind -> parser_kind'
| PK_glb : k1:parser_kind -> k2:parser_kind -> parser_kind'
| PK_string : parser_kind'
and parser_kind = {
pk_kind : parser_kind';
pk_weak_kind : A.weak_kind ;
pk_nz: bool
}
val expr_eq (e1 e1:expr) : bool
val exprs_eq (es1 es1:list expr) : bool
val fields_eq (fs1 fs2:list (A.ident & expr)) : bool
val parser_kind_eq (k k':parser_kind) : bool
noeq
type parser' =
| Parse_return : v:expr -> parser'
| Parse_app : hd:A.ident -> args:list index -> parser'
| Parse_nlist : n:expr -> t:parser -> parser'
| Parse_t_at_most : n:expr -> t:parser -> parser'
| Parse_t_exact : n:expr -> t:parser -> parser'
| Parse_pair : n1: A.ident -> p:parser -> q:parser -> parser'
| Parse_dep_pair : n1: A.ident -> p:parser -> k:lam parser -> parser'
| Parse_dep_pair_with_refinement: n1: A.ident -> dfst:parser -> refinement:lam expr -> dsnd:lam parser -> parser'
| Parse_dep_pair_with_action: dfst:parser -> a:lam action -> dsnd:lam parser -> parser'
| Parse_dep_pair_with_refinement_and_action: n1: A.ident -> dfst:parser -> refinement:lam expr -> a:lam action -> dsnd:lam parser -> parser'
| Parse_map : p:parser -> f:lam expr -> parser'
| Parse_refinement: n:A.ident -> p:parser -> f:lam expr -> parser'
| Parse_refinement_with_action : n:A.ident -> p:parser -> f:lam expr -> a:lam action -> parser'
| Parse_with_dep_action : name:A.ident -> p:parser -> a:lam action -> parser'
| Parse_with_action: name: A.ident -> p:parser -> a:action -> parser'
| Parse_weaken_left: p:parser -> k:parser_kind -> parser'
| Parse_weaken_right: p:parser -> k:parser_kind -> parser'
| Parse_if_else : e:expr -> parser -> parser -> parser'
| Parse_impos : parser'
| Parse_with_comment: p:parser -> c:A.comments -> parser'
| Parse_string : p:parser -> zero:expr -> parser'
and parser = {
p_kind:parser_kind;
p_typ:typ;
p_parser:parser';
p_typename: A.ident;
p_fieldname: string;
}
noeq
type reader =
| Read_u8
| Read_u16
| Read_u32
| Read_filter : r:reader -> f:lam expr -> reader
| Read_app : hd:A.ident -> args:list index -> reader
noeq
type validator' =
| Validate_return:
validator'
| Validate_app:
hd:A.ident ->
args:list index ->
validator'
| Validate_nlist:
n:expr ->
v:validator ->
validator'
| Validate_nlist_constant_size_without_actions:
n:expr ->
v:validator ->
validator'
| Validate_t_at_most:
n:expr ->
v:validator ->
validator'
| Validate_t_exact:
n:expr ->
v:validator ->
validator'
| Validate_pair:
n1:A.ident ->
v1:validator ->
v2:validator ->
validator'
| Validate_dep_pair:
n1:A.ident ->
v:validator ->
r:reader ->
k:lam validator ->
validator'
| Validate_dep_pair_with_refinement:
p1_is_constant_size_without_actions:bool ->
n1:A.ident ->
dfst:validator ->
r:reader ->
refinement:lam expr ->
dsnd:lam validator ->
validator'
| Validate_dep_pair_with_action:
dfst:validator ->
r:reader ->
a:lam action ->
dsnd:lam validator ->
validator'
| Validate_dep_pair_with_refinement_and_action:
p1_is_constant_size_without_actions:bool ->
n1:A.ident ->
dfst:validator ->
r:reader ->
refinement:lam expr ->
a:lam action ->
dsnd:lam validator ->
validator'
| Validate_map:
p:validator ->
f:lam expr ->
validator'
| Validate_refinement:
n:A.ident ->
v:validator ->
r:reader ->
f:lam expr ->
validator'
| Validate_refinement_with_action:
n:A.ident ->
v:validator ->
r:reader ->
f:lam expr ->
a:lam action ->
validator'
| Validate_with_dep_action:
name:A.ident ->
v:validator ->
r:reader ->
a:lam action ->
validator'
| Validate_with_action:
name:A.ident ->
v:validator ->
a:action ->
validator'
| Validate_weaken_left:
v:validator ->
k:parser_kind ->
validator'
| Validate_weaken_right:
v:validator ->
k:parser_kind ->
validator'
| Validate_if_else:
e:expr ->
validator ->
validator ->
validator'
| Validate_impos:
validator'
| Validate_with_error_handler:
typename:A.ident ->
fieldname:string ->
v:validator ->
validator'
| Validate_with_comment:
v:validator ->
c:A.comments ->
validator'
| Validate_string:
v:validator ->
r:reader ->
zero:expr ->
validator'
and validator = {
v_allow_reading: bool;
v_parser:parser;
v_validator:validator'
}
////////////////////////////////////////////////////////////////////////////////
noeq
type type_decl = {
decl_name: typedef_name;
decl_typ: typedef_body;
decl_parser: parser;
decl_validator: validator;
decl_reader: option reader;
decl_is_enum : bool
} | false | true | Target.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val definition : Type0 | [] | Target.definition | {
"file_name": "src/3d/Target.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | Type0 | {
"end_col": 50,
"end_line": 355,
"start_col": 17,
"start_line": 355
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Binding",
"short_module": null
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let assumption = A.ident * typ | let assumption = | false | null | false | A.ident * typ | {
"checked_file": "Target.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked",
"Binding.fsti.checked",
"Ast.fst.checked"
],
"interface_file": false,
"source_file": "Target.fsti"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"Ast.ident",
"Target.typ"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Target
(* The abstract syntax for the code produced by 3d *)
open FStar.All
module A = Ast
open Binding
/// The same as A.op, but with `SizeOf` removed
/// and arithmetic operators resolved to their types
type op =
| Eq
| Neq
| And
| Or
| Not
| Plus of A.integer_type
| Minus of A.integer_type
| Mul of A.integer_type
| Division of A.integer_type
| Remainder of A.integer_type
| BitwiseAnd of A.integer_type
| BitwiseXor of A.integer_type
| BitwiseOr of A.integer_type
| BitwiseNot of A.integer_type
| ShiftRight of A.integer_type
| ShiftLeft of A.integer_type
| LT of A.integer_type
| GT of A.integer_type
| LE of A.integer_type
| GE of A.integer_type
| IfThenElse
| BitFieldOf: size: int -> order: A.bitfield_bit_order -> op //BitFieldOf(i, from, to)
| Cast : from:A.integer_type -> to:A.integer_type -> op
| Ext of string
/// Same as A.expr, but with `This` removed
///
/// Carrying around the range information from AST.expr so that we
/// can report errors in terms of their 3d file locations
noeq
type expr' =
| Constant : c:A.constant -> expr'
| Identifier : i:A.ident -> expr'
| App : hd:op -> args:list expr -> expr'
| Record : type_name:A.ident -> list (A.ident * expr) -> expr'
and expr = expr' & A.range
let mk_expr (e:expr') = e, A.dummy_range
type lam a = (option A.ident) & a
noeq
type atomic_action =
| Action_return of expr
| Action_abort
| Action_field_pos_64
| Action_field_pos_32
| Action_field_ptr
| Action_field_ptr_after: sz: expr -> write_to:A.ident -> atomic_action
| Action_field_ptr_after_with_setter: sz: expr -> write_to_field:A.ident -> write_to_object:expr -> atomic_action
| Action_deref of A.ident
| Action_assignment : lhs:A.ident -> rhs:expr -> atomic_action
| Action_call : f:A.ident -> args:list expr -> atomic_action
noeq
type action =
| Atomic_action of atomic_action
| Action_seq : hd:atomic_action -> tl:action -> action
| Action_ite : hd:expr -> then_:action -> else_:action -> action
| Action_let : i:A.ident -> a:atomic_action -> k:action -> action
| Action_act : action -> action
(* A subset of F* types that the translation targets *)
noeq
type typ =
| T_false : typ
| T_app : hd:A.ident -> A.t_kind -> args:list index -> typ
| T_dep_pair : dfst:typ -> dsnd:(A.ident & typ) -> typ
| T_refine : base:typ -> refinement:lam expr -> typ
| T_if_else : e:expr -> t:typ -> f:typ -> typ
| T_pointer : typ -> typ
| T_with_action: typ -> action -> typ
| T_with_dep_action: typ -> a:lam action -> typ
| T_with_comment: typ -> A.comments -> typ
(* An index is an F* type or an expression
-- we reuse Ast expressions for this
*)
and index = either typ expr
let field_typ = typ
type param = A.ident & typ
noeq
type struct_field = {
sf_dependence: bool;
sf_ident: A.ident;
sf_typ: field_typ
}
type field = struct_field
noeq
type typedef_body =
| TD_abbrev : typ -> typedef_body
| TD_struct : list field -> typedef_body
noeq
type typedef_name = {
td_name:A.ident;
td_params:list param;
td_entrypoint:bool
}
type typedef = typedef_name & typedef_body
////////////////////////////////////////////////////////////////////////////////
noeq
type parser_kind' =
| PK_return
| PK_impos
| PK_base : hd:A.ident -> parser_kind'
| PK_list : parser_kind'
| PK_t_at_most: parser_kind'
| PK_t_exact : parser_kind'
| PK_filter : k:parser_kind -> parser_kind'
| PK_and_then : k1:parser_kind -> k2:parser_kind -> parser_kind'
| PK_glb : k1:parser_kind -> k2:parser_kind -> parser_kind'
| PK_string : parser_kind'
and parser_kind = {
pk_kind : parser_kind';
pk_weak_kind : A.weak_kind ;
pk_nz: bool
}
val expr_eq (e1 e1:expr) : bool
val exprs_eq (es1 es1:list expr) : bool
val fields_eq (fs1 fs2:list (A.ident & expr)) : bool
val parser_kind_eq (k k':parser_kind) : bool
noeq
type parser' =
| Parse_return : v:expr -> parser'
| Parse_app : hd:A.ident -> args:list index -> parser'
| Parse_nlist : n:expr -> t:parser -> parser'
| Parse_t_at_most : n:expr -> t:parser -> parser'
| Parse_t_exact : n:expr -> t:parser -> parser'
| Parse_pair : n1: A.ident -> p:parser -> q:parser -> parser'
| Parse_dep_pair : n1: A.ident -> p:parser -> k:lam parser -> parser'
| Parse_dep_pair_with_refinement: n1: A.ident -> dfst:parser -> refinement:lam expr -> dsnd:lam parser -> parser'
| Parse_dep_pair_with_action: dfst:parser -> a:lam action -> dsnd:lam parser -> parser'
| Parse_dep_pair_with_refinement_and_action: n1: A.ident -> dfst:parser -> refinement:lam expr -> a:lam action -> dsnd:lam parser -> parser'
| Parse_map : p:parser -> f:lam expr -> parser'
| Parse_refinement: n:A.ident -> p:parser -> f:lam expr -> parser'
| Parse_refinement_with_action : n:A.ident -> p:parser -> f:lam expr -> a:lam action -> parser'
| Parse_with_dep_action : name:A.ident -> p:parser -> a:lam action -> parser'
| Parse_with_action: name: A.ident -> p:parser -> a:action -> parser'
| Parse_weaken_left: p:parser -> k:parser_kind -> parser'
| Parse_weaken_right: p:parser -> k:parser_kind -> parser'
| Parse_if_else : e:expr -> parser -> parser -> parser'
| Parse_impos : parser'
| Parse_with_comment: p:parser -> c:A.comments -> parser'
| Parse_string : p:parser -> zero:expr -> parser'
and parser = {
p_kind:parser_kind;
p_typ:typ;
p_parser:parser';
p_typename: A.ident;
p_fieldname: string;
}
noeq
type reader =
| Read_u8
| Read_u16
| Read_u32
| Read_filter : r:reader -> f:lam expr -> reader
| Read_app : hd:A.ident -> args:list index -> reader
noeq
type validator' =
| Validate_return:
validator'
| Validate_app:
hd:A.ident ->
args:list index ->
validator'
| Validate_nlist:
n:expr ->
v:validator ->
validator'
| Validate_nlist_constant_size_without_actions:
n:expr ->
v:validator ->
validator'
| Validate_t_at_most:
n:expr ->
v:validator ->
validator'
| Validate_t_exact:
n:expr ->
v:validator ->
validator'
| Validate_pair:
n1:A.ident ->
v1:validator ->
v2:validator ->
validator'
| Validate_dep_pair:
n1:A.ident ->
v:validator ->
r:reader ->
k:lam validator ->
validator'
| Validate_dep_pair_with_refinement:
p1_is_constant_size_without_actions:bool ->
n1:A.ident ->
dfst:validator ->
r:reader ->
refinement:lam expr ->
dsnd:lam validator ->
validator'
| Validate_dep_pair_with_action:
dfst:validator ->
r:reader ->
a:lam action ->
dsnd:lam validator ->
validator'
| Validate_dep_pair_with_refinement_and_action:
p1_is_constant_size_without_actions:bool ->
n1:A.ident ->
dfst:validator ->
r:reader ->
refinement:lam expr ->
a:lam action ->
dsnd:lam validator ->
validator'
| Validate_map:
p:validator ->
f:lam expr ->
validator'
| Validate_refinement:
n:A.ident ->
v:validator ->
r:reader ->
f:lam expr ->
validator'
| Validate_refinement_with_action:
n:A.ident ->
v:validator ->
r:reader ->
f:lam expr ->
a:lam action ->
validator'
| Validate_with_dep_action:
name:A.ident ->
v:validator ->
r:reader ->
a:lam action ->
validator'
| Validate_with_action:
name:A.ident ->
v:validator ->
a:action ->
validator'
| Validate_weaken_left:
v:validator ->
k:parser_kind ->
validator'
| Validate_weaken_right:
v:validator ->
k:parser_kind ->
validator'
| Validate_if_else:
e:expr ->
validator ->
validator ->
validator'
| Validate_impos:
validator'
| Validate_with_error_handler:
typename:A.ident ->
fieldname:string ->
v:validator ->
validator'
| Validate_with_comment:
v:validator ->
c:A.comments ->
validator'
| Validate_string:
v:validator ->
r:reader ->
zero:expr ->
validator'
and validator = {
v_allow_reading: bool;
v_parser:parser;
v_validator:validator'
}
////////////////////////////////////////////////////////////////////////////////
noeq
type type_decl = {
decl_name: typedef_name;
decl_typ: typedef_body;
decl_parser: parser;
decl_validator: validator;
decl_reader: option reader;
decl_is_enum : bool
}
let definition = A.ident * list param * typ * expr | false | true | Target.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val assumption : Type0 | [] | Target.assumption | {
"file_name": "src/3d/Target.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | Type0 | {
"end_col": 30,
"end_line": 357,
"start_col": 17,
"start_line": 357
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | false | let pow = fpow | let pow = | false | null | false | fpow | {
"checked_file": "Hacl.Spec.Curve25519.Finv.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Finv.fst"
} | [
"total"
] | [
"Spec.Curve25519.fpow"
] | [] | module Hacl.Spec.Curve25519.Finv
open FStar.Mul
open Spec.Curve25519
module M = Lib.NatMod
module LE = Lib.Exponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | true | Hacl.Spec.Curve25519.Finv.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pow : x: Spec.Curve25519.elem -> b: Prims.nat -> Spec.Curve25519.elem | [] | Hacl.Spec.Curve25519.Finv.pow | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Finv.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.Curve25519.elem -> b: Prims.nat -> Spec.Curve25519.elem | {
"end_col": 14,
"end_line": 11,
"start_col": 10,
"start_line": 11
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | false | let cm_prime = M.mk_nat_mod_comm_monoid prime | let cm_prime = | false | null | false | M.mk_nat_mod_comm_monoid prime | {
"checked_file": "Hacl.Spec.Curve25519.Finv.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Finv.fst"
} | [
"total"
] | [
"Lib.NatMod.mk_nat_mod_comm_monoid",
"Spec.Curve25519.prime"
] | [] | module Hacl.Spec.Curve25519.Finv
open FStar.Mul
open Spec.Curve25519
module M = Lib.NatMod
module LE = Lib.Exponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let fsqr x = fmul x x | false | true | Hacl.Spec.Curve25519.Finv.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val cm_prime : Lib.Exponentiation.Definition.comm_monoid (Lib.NatMod.nat_mod Spec.Curve25519.prime) | [] | Hacl.Spec.Curve25519.Finv.cm_prime | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Finv.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Exponentiation.Definition.comm_monoid (Lib.NatMod.nat_mod Spec.Curve25519.prime) | {
"end_col": 45,
"end_line": 12,
"start_col": 15,
"start_line": 12
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | false | let fsqr x = fmul x x | let fsqr x = | false | null | false | fmul x x | {
"checked_file": "Hacl.Spec.Curve25519.Finv.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Finv.fst"
} | [
"total"
] | [
"Spec.Curve25519.elem",
"Spec.Curve25519.fmul"
] | [] | module Hacl.Spec.Curve25519.Finv
open FStar.Mul
open Spec.Curve25519
module M = Lib.NatMod
module LE = Lib.Exponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | true | Hacl.Spec.Curve25519.Finv.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fsqr : x: Spec.Curve25519.elem -> Spec.Curve25519.elem | [] | Hacl.Spec.Curve25519.Finv.fsqr | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Finv.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.Curve25519.elem -> Spec.Curve25519.elem | {
"end_col": 21,
"end_line": 10,
"start_col": 13,
"start_line": 10
} |
|
Prims.Tot | val pow_t0:nat | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | false | let pow_t0:nat =
assert_norm (pow2 255 - pow2 5 > 0);
pow2 255 - pow2 5 | val pow_t0:nat
let pow_t0:nat = | false | null | false | assert_norm (pow2 255 - pow2 5 > 0);
pow2 255 - pow2 5 | {
"checked_file": "Hacl.Spec.Curve25519.Finv.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Finv.fst"
} | [
"total"
] | [
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_GreaterThan"
] | [] | module Hacl.Spec.Curve25519.Finv
open FStar.Mul
open Spec.Curve25519
module M = Lib.NatMod
module LE = Lib.Exponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let fsqr x = fmul x x
let pow = fpow
let cm_prime = M.mk_nat_mod_comm_monoid prime
val lemma_pow_mod_is_pow_cm : x:elem -> b:nat -> Lemma (pow x b = LE.pow cm_prime x b)
let lemma_pow_mod_is_pow_cm x b =
M.lemma_pow_nat_mod_is_pow #prime x b;
M.lemma_pow_mod #prime x b
val lemma_pow_one: x:elem -> Lemma (x == pow x 1)
let lemma_pow_one x =
lemma_pow_mod_is_pow_cm x 1;
LE.lemma_pow1 cm_prime x
val lemma_pow_add: x:elem -> n:nat -> m:nat ->
Lemma (fmul (pow x n) (pow x m) == pow x (n + m))
let lemma_pow_add x n m =
lemma_pow_mod_is_pow_cm x n;
lemma_pow_mod_is_pow_cm x m;
LE.lemma_pow_add cm_prime x n m;
lemma_pow_mod_is_pow_cm x (n + m)
val lemma_pow_mul: x:elem -> n:nat -> m:nat ->
Lemma (pow (pow x n) m == pow x (n * m))
let lemma_pow_mul x n m =
lemma_pow_mod_is_pow_cm x n;
lemma_pow_mod_is_pow_cm (pow x n) m;
LE.lemma_pow_mul cm_prime x n m;
lemma_pow_mod_is_pow_cm x (n * m)
val lemma_pow_double: a:elem -> b:nat ->
Lemma (pow (a *% a) b == pow a (b + b))
let lemma_pow_double a b =
lemma_pow_mod_is_pow_cm (a *% a) b;
LE.lemma_pow_double cm_prime a b;
lemma_pow_mod_is_pow_cm a (b + b)
val fsquare_times: inp:elem -> n:pos -> out:elem{out == pow inp (pow2 n)}
let fsquare_times inp n =
let out = fsqr inp in
lemma_pow_one inp;
lemma_pow_add inp 1 1;
assert_norm (pow2 1 = 2);
assert (out == pow inp (pow2 1));
let out =
Lib.LoopCombinators.repeati_inductive #elem (n - 1)
(fun i out -> out == pow inp (pow2 (i + 1)))
(fun i out ->
assert (out == pow inp (pow2 (i + 1)));
let res = fsqr out in
calc (==) {
fmul out out;
(==) { lemma_pow_add inp (pow2 (i + 1)) (pow2 (i + 1)) }
pow inp (pow2 (i + 1) + pow2 (i + 1));
(==) { Math.Lemmas.pow2_double_sum (i + 1) }
pow inp (pow2 (i + 2));
};
res) out in
assert (out == pow inp (pow2 n));
out | false | true | Hacl.Spec.Curve25519.Finv.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pow_t0:nat | [] | Hacl.Spec.Curve25519.Finv.pow_t0 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Finv.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.nat | {
"end_col": 19,
"end_line": 74,
"start_col": 2,
"start_line": 73
} |
FStar.Pervasives.Lemma | val lemma_pow_one: x:elem -> Lemma (x == pow x 1) | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | false | let lemma_pow_one x =
lemma_pow_mod_is_pow_cm x 1;
LE.lemma_pow1 cm_prime x | val lemma_pow_one: x:elem -> Lemma (x == pow x 1)
let lemma_pow_one x = | false | null | true | lemma_pow_mod_is_pow_cm x 1;
LE.lemma_pow1 cm_prime x | {
"checked_file": "Hacl.Spec.Curve25519.Finv.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Finv.fst"
} | [
"lemma"
] | [
"Spec.Curve25519.elem",
"Lib.Exponentiation.Definition.lemma_pow1",
"Lib.NatMod.nat_mod",
"Spec.Curve25519.prime",
"Hacl.Spec.Curve25519.Finv.cm_prime",
"Prims.unit",
"Hacl.Spec.Curve25519.Finv.lemma_pow_mod_is_pow_cm"
] | [] | module Hacl.Spec.Curve25519.Finv
open FStar.Mul
open Spec.Curve25519
module M = Lib.NatMod
module LE = Lib.Exponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let fsqr x = fmul x x
let pow = fpow
let cm_prime = M.mk_nat_mod_comm_monoid prime
val lemma_pow_mod_is_pow_cm : x:elem -> b:nat -> Lemma (pow x b = LE.pow cm_prime x b)
let lemma_pow_mod_is_pow_cm x b =
M.lemma_pow_nat_mod_is_pow #prime x b;
M.lemma_pow_mod #prime x b
val lemma_pow_one: x:elem -> Lemma (x == pow x 1) | false | false | Hacl.Spec.Curve25519.Finv.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_pow_one: x:elem -> Lemma (x == pow x 1) | [] | Hacl.Spec.Curve25519.Finv.lemma_pow_one | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Finv.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.Curve25519.elem -> FStar.Pervasives.Lemma (ensures x == Hacl.Spec.Curve25519.Finv.pow x 1) | {
"end_col": 26,
"end_line": 22,
"start_col": 2,
"start_line": 21
} |
FStar.Pervasives.Lemma | val lemma_pow_mod_is_pow_cm : x:elem -> b:nat -> Lemma (pow x b = LE.pow cm_prime x b) | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | false | let lemma_pow_mod_is_pow_cm x b =
M.lemma_pow_nat_mod_is_pow #prime x b;
M.lemma_pow_mod #prime x b | val lemma_pow_mod_is_pow_cm : x:elem -> b:nat -> Lemma (pow x b = LE.pow cm_prime x b)
let lemma_pow_mod_is_pow_cm x b = | false | null | true | M.lemma_pow_nat_mod_is_pow #prime x b;
M.lemma_pow_mod #prime x b | {
"checked_file": "Hacl.Spec.Curve25519.Finv.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Finv.fst"
} | [
"lemma"
] | [
"Spec.Curve25519.elem",
"Prims.nat",
"Lib.NatMod.lemma_pow_mod",
"Spec.Curve25519.prime",
"Prims.unit",
"Lib.NatMod.lemma_pow_nat_mod_is_pow"
] | [] | module Hacl.Spec.Curve25519.Finv
open FStar.Mul
open Spec.Curve25519
module M = Lib.NatMod
module LE = Lib.Exponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let fsqr x = fmul x x
let pow = fpow
let cm_prime = M.mk_nat_mod_comm_monoid prime
val lemma_pow_mod_is_pow_cm : x:elem -> b:nat -> Lemma (pow x b = LE.pow cm_prime x b) | false | false | Hacl.Spec.Curve25519.Finv.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_pow_mod_is_pow_cm : x:elem -> b:nat -> Lemma (pow x b = LE.pow cm_prime x b) | [] | Hacl.Spec.Curve25519.Finv.lemma_pow_mod_is_pow_cm | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Finv.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.Curve25519.elem -> b: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Curve25519.Finv.pow x b =
Lib.Exponentiation.Definition.pow Hacl.Spec.Curve25519.Finv.cm_prime x b) | {
"end_col": 28,
"end_line": 17,
"start_col": 2,
"start_line": 16
} |
FStar.Pervasives.Lemma | val lemma_pow_double: a:elem -> b:nat ->
Lemma (pow (a *% a) b == pow a (b + b)) | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | false | let lemma_pow_double a b =
lemma_pow_mod_is_pow_cm (a *% a) b;
LE.lemma_pow_double cm_prime a b;
lemma_pow_mod_is_pow_cm a (b + b) | val lemma_pow_double: a:elem -> b:nat ->
Lemma (pow (a *% a) b == pow a (b + b))
let lemma_pow_double a b = | false | null | true | lemma_pow_mod_is_pow_cm (a *% a) b;
LE.lemma_pow_double cm_prime a b;
lemma_pow_mod_is_pow_cm a (b + b) | {
"checked_file": "Hacl.Spec.Curve25519.Finv.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Finv.fst"
} | [
"lemma"
] | [
"Spec.Curve25519.elem",
"Prims.nat",
"Hacl.Spec.Curve25519.Finv.lemma_pow_mod_is_pow_cm",
"Prims.op_Addition",
"Prims.unit",
"Lib.Exponentiation.Definition.lemma_pow_double",
"Lib.NatMod.nat_mod",
"Spec.Curve25519.prime",
"Hacl.Spec.Curve25519.Finv.cm_prime",
"Spec.Curve25519.op_Star_Percent"
] | [] | module Hacl.Spec.Curve25519.Finv
open FStar.Mul
open Spec.Curve25519
module M = Lib.NatMod
module LE = Lib.Exponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let fsqr x = fmul x x
let pow = fpow
let cm_prime = M.mk_nat_mod_comm_monoid prime
val lemma_pow_mod_is_pow_cm : x:elem -> b:nat -> Lemma (pow x b = LE.pow cm_prime x b)
let lemma_pow_mod_is_pow_cm x b =
M.lemma_pow_nat_mod_is_pow #prime x b;
M.lemma_pow_mod #prime x b
val lemma_pow_one: x:elem -> Lemma (x == pow x 1)
let lemma_pow_one x =
lemma_pow_mod_is_pow_cm x 1;
LE.lemma_pow1 cm_prime x
val lemma_pow_add: x:elem -> n:nat -> m:nat ->
Lemma (fmul (pow x n) (pow x m) == pow x (n + m))
let lemma_pow_add x n m =
lemma_pow_mod_is_pow_cm x n;
lemma_pow_mod_is_pow_cm x m;
LE.lemma_pow_add cm_prime x n m;
lemma_pow_mod_is_pow_cm x (n + m)
val lemma_pow_mul: x:elem -> n:nat -> m:nat ->
Lemma (pow (pow x n) m == pow x (n * m))
let lemma_pow_mul x n m =
lemma_pow_mod_is_pow_cm x n;
lemma_pow_mod_is_pow_cm (pow x n) m;
LE.lemma_pow_mul cm_prime x n m;
lemma_pow_mod_is_pow_cm x (n * m)
val lemma_pow_double: a:elem -> b:nat ->
Lemma (pow (a *% a) b == pow a (b + b)) | false | false | Hacl.Spec.Curve25519.Finv.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_pow_double: a:elem -> b:nat ->
Lemma (pow (a *% a) b == pow a (b + b)) | [] | Hacl.Spec.Curve25519.Finv.lemma_pow_double | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Finv.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Curve25519.elem -> b: Prims.nat
-> FStar.Pervasives.Lemma
(ensures Hacl.Spec.Curve25519.Finv.pow (a *% a) b == Hacl.Spec.Curve25519.Finv.pow a (b + b)) | {
"end_col": 35,
"end_line": 45,
"start_col": 2,
"start_line": 43
} |
FStar.Pervasives.Lemma | val lemma_pow_add: x:elem -> n:nat -> m:nat ->
Lemma (fmul (pow x n) (pow x m) == pow x (n + m)) | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | false | let lemma_pow_add x n m =
lemma_pow_mod_is_pow_cm x n;
lemma_pow_mod_is_pow_cm x m;
LE.lemma_pow_add cm_prime x n m;
lemma_pow_mod_is_pow_cm x (n + m) | val lemma_pow_add: x:elem -> n:nat -> m:nat ->
Lemma (fmul (pow x n) (pow x m) == pow x (n + m))
let lemma_pow_add x n m = | false | null | true | lemma_pow_mod_is_pow_cm x n;
lemma_pow_mod_is_pow_cm x m;
LE.lemma_pow_add cm_prime x n m;
lemma_pow_mod_is_pow_cm x (n + m) | {
"checked_file": "Hacl.Spec.Curve25519.Finv.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Finv.fst"
} | [
"lemma"
] | [
"Spec.Curve25519.elem",
"Prims.nat",
"Hacl.Spec.Curve25519.Finv.lemma_pow_mod_is_pow_cm",
"Prims.op_Addition",
"Prims.unit",
"Lib.Exponentiation.Definition.lemma_pow_add",
"Lib.NatMod.nat_mod",
"Spec.Curve25519.prime",
"Hacl.Spec.Curve25519.Finv.cm_prime"
] | [] | module Hacl.Spec.Curve25519.Finv
open FStar.Mul
open Spec.Curve25519
module M = Lib.NatMod
module LE = Lib.Exponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let fsqr x = fmul x x
let pow = fpow
let cm_prime = M.mk_nat_mod_comm_monoid prime
val lemma_pow_mod_is_pow_cm : x:elem -> b:nat -> Lemma (pow x b = LE.pow cm_prime x b)
let lemma_pow_mod_is_pow_cm x b =
M.lemma_pow_nat_mod_is_pow #prime x b;
M.lemma_pow_mod #prime x b
val lemma_pow_one: x:elem -> Lemma (x == pow x 1)
let lemma_pow_one x =
lemma_pow_mod_is_pow_cm x 1;
LE.lemma_pow1 cm_prime x
val lemma_pow_add: x:elem -> n:nat -> m:nat ->
Lemma (fmul (pow x n) (pow x m) == pow x (n + m)) | false | false | Hacl.Spec.Curve25519.Finv.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_pow_add: x:elem -> n:nat -> m:nat ->
Lemma (fmul (pow x n) (pow x m) == pow x (n + m)) | [] | Hacl.Spec.Curve25519.Finv.lemma_pow_add | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Finv.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.Curve25519.elem -> n: Prims.nat -> m: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
Spec.Curve25519.fmul (Hacl.Spec.Curve25519.Finv.pow x n) (Hacl.Spec.Curve25519.Finv.pow x m) ==
Hacl.Spec.Curve25519.Finv.pow x (n + m)) | {
"end_col": 35,
"end_line": 30,
"start_col": 2,
"start_line": 27
} |
FStar.Pervasives.Lemma | val lemma_pow_mul: x:elem -> n:nat -> m:nat ->
Lemma (pow (pow x n) m == pow x (n * m)) | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | false | let lemma_pow_mul x n m =
lemma_pow_mod_is_pow_cm x n;
lemma_pow_mod_is_pow_cm (pow x n) m;
LE.lemma_pow_mul cm_prime x n m;
lemma_pow_mod_is_pow_cm x (n * m) | val lemma_pow_mul: x:elem -> n:nat -> m:nat ->
Lemma (pow (pow x n) m == pow x (n * m))
let lemma_pow_mul x n m = | false | null | true | lemma_pow_mod_is_pow_cm x n;
lemma_pow_mod_is_pow_cm (pow x n) m;
LE.lemma_pow_mul cm_prime x n m;
lemma_pow_mod_is_pow_cm x (n * m) | {
"checked_file": "Hacl.Spec.Curve25519.Finv.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Finv.fst"
} | [
"lemma"
] | [
"Spec.Curve25519.elem",
"Prims.nat",
"Hacl.Spec.Curve25519.Finv.lemma_pow_mod_is_pow_cm",
"FStar.Mul.op_Star",
"Prims.unit",
"Lib.Exponentiation.Definition.lemma_pow_mul",
"Lib.NatMod.nat_mod",
"Spec.Curve25519.prime",
"Hacl.Spec.Curve25519.Finv.cm_prime",
"Hacl.Spec.Curve25519.Finv.pow"
] | [] | module Hacl.Spec.Curve25519.Finv
open FStar.Mul
open Spec.Curve25519
module M = Lib.NatMod
module LE = Lib.Exponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let fsqr x = fmul x x
let pow = fpow
let cm_prime = M.mk_nat_mod_comm_monoid prime
val lemma_pow_mod_is_pow_cm : x:elem -> b:nat -> Lemma (pow x b = LE.pow cm_prime x b)
let lemma_pow_mod_is_pow_cm x b =
M.lemma_pow_nat_mod_is_pow #prime x b;
M.lemma_pow_mod #prime x b
val lemma_pow_one: x:elem -> Lemma (x == pow x 1)
let lemma_pow_one x =
lemma_pow_mod_is_pow_cm x 1;
LE.lemma_pow1 cm_prime x
val lemma_pow_add: x:elem -> n:nat -> m:nat ->
Lemma (fmul (pow x n) (pow x m) == pow x (n + m))
let lemma_pow_add x n m =
lemma_pow_mod_is_pow_cm x n;
lemma_pow_mod_is_pow_cm x m;
LE.lemma_pow_add cm_prime x n m;
lemma_pow_mod_is_pow_cm x (n + m)
val lemma_pow_mul: x:elem -> n:nat -> m:nat ->
Lemma (pow (pow x n) m == pow x (n * m)) | false | false | Hacl.Spec.Curve25519.Finv.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_pow_mul: x:elem -> n:nat -> m:nat ->
Lemma (pow (pow x n) m == pow x (n * m)) | [] | Hacl.Spec.Curve25519.Finv.lemma_pow_mul | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Finv.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.Curve25519.elem -> n: Prims.nat -> m: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Curve25519.Finv.pow (Hacl.Spec.Curve25519.Finv.pow x n) m ==
Hacl.Spec.Curve25519.Finv.pow x (n * m)) | {
"end_col": 35,
"end_line": 38,
"start_col": 2,
"start_line": 35
} |
Prims.Tot | val finv: inp:elem -> out:elem{out == fpow inp (pow2 255 - 21)} | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | false | let finv i =
let a, t0 = finv0 i in
(* 2^255 - 21 *) let o = fmul t0 a in
lemma_pow_add i (pow2 255 - pow2 5) 11;
assert_norm (pow2 255 - pow2 5 + 11 = pow2 255 - 21);
assert (o == pow i (pow2 255 - 21));
o | val finv: inp:elem -> out:elem{out == fpow inp (pow2 255 - 21)}
let finv i = | false | null | false | let a, t0 = finv0 i in
let o = fmul t0 a in
lemma_pow_add i (pow2 255 - pow2 5) 11;
assert_norm (pow2 255 - pow2 5 + 11 = pow2 255 - 21);
assert (o == pow i (pow2 255 - 21));
o | {
"checked_file": "Hacl.Spec.Curve25519.Finv.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Finv.fst"
} | [
"total"
] | [
"Spec.Curve25519.elem",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Hacl.Spec.Curve25519.Finv.pow",
"Prims.op_Subtraction",
"Prims.pow2",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Addition",
"Hacl.Spec.Curve25519.Finv.lemma_pow_add",
"Spec.Curve25519.fmul",
"Spec.Curve25519.fpow",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Curve25519.Finv.finv0"
] | [] | module Hacl.Spec.Curve25519.Finv
open FStar.Mul
open Spec.Curve25519
module M = Lib.NatMod
module LE = Lib.Exponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let fsqr x = fmul x x
let pow = fpow
let cm_prime = M.mk_nat_mod_comm_monoid prime
val lemma_pow_mod_is_pow_cm : x:elem -> b:nat -> Lemma (pow x b = LE.pow cm_prime x b)
let lemma_pow_mod_is_pow_cm x b =
M.lemma_pow_nat_mod_is_pow #prime x b;
M.lemma_pow_mod #prime x b
val lemma_pow_one: x:elem -> Lemma (x == pow x 1)
let lemma_pow_one x =
lemma_pow_mod_is_pow_cm x 1;
LE.lemma_pow1 cm_prime x
val lemma_pow_add: x:elem -> n:nat -> m:nat ->
Lemma (fmul (pow x n) (pow x m) == pow x (n + m))
let lemma_pow_add x n m =
lemma_pow_mod_is_pow_cm x n;
lemma_pow_mod_is_pow_cm x m;
LE.lemma_pow_add cm_prime x n m;
lemma_pow_mod_is_pow_cm x (n + m)
val lemma_pow_mul: x:elem -> n:nat -> m:nat ->
Lemma (pow (pow x n) m == pow x (n * m))
let lemma_pow_mul x n m =
lemma_pow_mod_is_pow_cm x n;
lemma_pow_mod_is_pow_cm (pow x n) m;
LE.lemma_pow_mul cm_prime x n m;
lemma_pow_mod_is_pow_cm x (n * m)
val lemma_pow_double: a:elem -> b:nat ->
Lemma (pow (a *% a) b == pow a (b + b))
let lemma_pow_double a b =
lemma_pow_mod_is_pow_cm (a *% a) b;
LE.lemma_pow_double cm_prime a b;
lemma_pow_mod_is_pow_cm a (b + b)
val fsquare_times: inp:elem -> n:pos -> out:elem{out == pow inp (pow2 n)}
let fsquare_times inp n =
let out = fsqr inp in
lemma_pow_one inp;
lemma_pow_add inp 1 1;
assert_norm (pow2 1 = 2);
assert (out == pow inp (pow2 1));
let out =
Lib.LoopCombinators.repeati_inductive #elem (n - 1)
(fun i out -> out == pow inp (pow2 (i + 1)))
(fun i out ->
assert (out == pow inp (pow2 (i + 1)));
let res = fsqr out in
calc (==) {
fmul out out;
(==) { lemma_pow_add inp (pow2 (i + 1)) (pow2 (i + 1)) }
pow inp (pow2 (i + 1) + pow2 (i + 1));
(==) { Math.Lemmas.pow2_double_sum (i + 1) }
pow inp (pow2 (i + 2));
};
res) out in
assert (out == pow inp (pow2 n));
out
let pow_t0:nat =
assert_norm (pow2 255 - pow2 5 > 0);
pow2 255 - pow2 5
val finv0: inp:elem ->
Pure (tuple2 elem elem)
(requires True)
(ensures fun (a, t0) ->
a == pow inp 11 /\
t0 == pow inp pow_t0)
let finv0 i =
(* 2 *) let a = fsquare_times i 1 in
assert (a == pow i 2);
(* 8 *) let t0 = fsquare_times a 2 in
assert (t0 == pow a 4);
lemma_pow_mul i 2 4;
assert (t0 == pow i 8);
(* 9 *) let b = fmul t0 i in
lemma_pow_one i;
lemma_pow_add i 8 1;
assert (b == pow i 9);
(* 11 *) let a = fmul b a in
lemma_pow_add i 9 2;
assert (a == pow i 11);
(* 22 *) let t0 = fsquare_times a 1 in
lemma_pow_mul i 11 2;
assert (t0 == pow i 22);
(* 2^5 - 2^0 = 31 *) let b = fmul t0 b in
lemma_pow_add i 22 9;
assert (b == pow i 31);
(* 2^10 - 2^5 *) let t0 = fsquare_times b 5 in
lemma_pow_mul i 31 (pow2 5);
assert_norm (31 * pow2 5 = pow2 10 - pow2 5);
assert (t0 == pow i (pow2 10 - pow2 5));
(* 2^10 - 2^0 *) let b = fmul t0 b in
assert_norm (31 = pow2 5 - 1);
lemma_pow_add i (pow2 10 - pow2 5) (pow2 5 - 1);
assert (b == pow i (pow2 10 - 1));
(* 2^20 - 2^10 *) let t0 = fsquare_times b 10 in
lemma_pow_mul i (pow2 10 - 1) (pow2 10);
assert_norm ((pow2 10 - 1) * pow2 10 == pow2 20 - pow2 10);
assert (t0 == pow i (pow2 20 - pow2 10));
(* 2^20 - 2^0 *) let c = fmul t0 b in
lemma_pow_add i (pow2 20 - pow2 10) (pow2 10 - 1);
assert_norm (pow2 20 - pow2 10 + pow2 10 - 1 = pow2 20 - 1);
assert (c == pow i (pow2 20 - 1));
(* 2^40 - 2^20 *) let t0 = fsquare_times c 20 in
lemma_pow_mul i (pow2 20 - 1) (pow2 20);
assert_norm ((pow2 20 - 1) * pow2 20 = pow2 40 - pow2 20);
assert (t0 == pow i (pow2 40 - pow2 20));
(* 2^40 - 2^0 *) let t0 = fmul t0 c in
lemma_pow_add i (pow2 40 -pow2 20) (pow2 20 - 1);
assert_norm (pow2 40 - pow2 20 + pow2 20 - 1 = pow2 40 - 1);
assert (t0 == pow i (pow2 40 - 1));
(* 2^50 - 2^10 *) let t0 = fsquare_times t0 10 in
lemma_pow_mul i (pow2 40 - 1) (pow2 10);
assert_norm ((pow2 40 - 1) * pow2 10 = pow2 50 - pow2 10);
assert (t0 == pow i (pow2 50 - pow2 10));
(* 2^50 - 2^0 *) let b = fmul t0 b in
lemma_pow_add i (pow2 50 - pow2 10) (pow2 10 - 1);
assert_norm (pow2 50 - pow2 10 + pow2 10 - 1 = pow2 50 - 1);
assert (b == pow i (pow2 50 - 1));
(* 2^100 - 2^50 *) let t0 = fsquare_times b 50 in
lemma_pow_mul i (pow2 50 - 1) (pow2 50);
assert_norm ((pow2 50 - 1) * pow2 50 = pow2 100 - pow2 50);
assert (t0 == pow i (pow2 100 - pow2 50));
(* 2^100 - 2^0 *) let c = fmul t0 b in
lemma_pow_add i (pow2 100 - pow2 50) (pow2 50 - 1);
assert_norm (pow2 100 - pow2 50 + pow2 50 - 1 = pow2 100 - 1);
assert (c == pow i (pow2 100 - 1));
(* 2^200 - 2^100 *) let t0 = fsquare_times c 100 in
lemma_pow_mul i (pow2 100 - 1) (pow2 100);
assert_norm ((pow2 100 - 1) * pow2 100 = pow2 200 - pow2 100);
assert (t0 == pow i (pow2 200 - pow2 100));
(* 2^200 - 2^0 *) let t0 = fmul t0 c in
lemma_pow_add i (pow2 200 - pow2 100) (pow2 100 - 1);
assert_norm (pow2 200 - pow2 100 + pow2 100 - 1 = pow2 200 - 1);
assert (t0 == pow i (pow2 200 - 1));
(* 2^250 - 2^50 *) let t0 = fsquare_times t0 50 in
lemma_pow_mul i (pow2 200 - 1) (pow2 50);
assert_norm ((pow2 200 - 1) * pow2 50 = pow2 250 - pow2 50);
assert (t0 == pow i (pow2 250 - pow2 50));
(* 2^250 - 2^0 *) let t0 = fmul t0 b in
lemma_pow_add i (pow2 250 - pow2 50) (pow2 50 - 1);
assert_norm (pow2 250 - pow2 50 + pow2 50 - 1 = pow2 250 - 1);
assert (t0 == pow i (pow2 250 - 1));
(* 2^255 - 2^5 *) let t0 = fsquare_times t0 5 in
lemma_pow_mul i (pow2 250 - 1) (pow2 5);
assert_norm ((pow2 250 - 1) * pow2 5 = pow2 255 - pow2 5);
assert (t0 == pow i (pow2 255 - pow2 5));
a, t0 | false | false | Hacl.Spec.Curve25519.Finv.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val finv: inp:elem -> out:elem{out == fpow inp (pow2 255 - 21)} | [] | Hacl.Spec.Curve25519.Finv.finv | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Finv.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | inp: Spec.Curve25519.elem
-> out: Spec.Curve25519.elem{out == Spec.Curve25519.fpow inp (Prims.pow2 255 - 21)} | {
"end_col": 3,
"end_line": 171,
"start_col": 12,
"start_line": 165
} |
Prims.Tot | val fsquare_times: inp:elem -> n:pos -> out:elem{out == pow inp (pow2 n)} | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | false | let fsquare_times inp n =
let out = fsqr inp in
lemma_pow_one inp;
lemma_pow_add inp 1 1;
assert_norm (pow2 1 = 2);
assert (out == pow inp (pow2 1));
let out =
Lib.LoopCombinators.repeati_inductive #elem (n - 1)
(fun i out -> out == pow inp (pow2 (i + 1)))
(fun i out ->
assert (out == pow inp (pow2 (i + 1)));
let res = fsqr out in
calc (==) {
fmul out out;
(==) { lemma_pow_add inp (pow2 (i + 1)) (pow2 (i + 1)) }
pow inp (pow2 (i + 1) + pow2 (i + 1));
(==) { Math.Lemmas.pow2_double_sum (i + 1) }
pow inp (pow2 (i + 2));
};
res) out in
assert (out == pow inp (pow2 n));
out | val fsquare_times: inp:elem -> n:pos -> out:elem{out == pow inp (pow2 n)}
let fsquare_times inp n = | false | null | false | let out = fsqr inp in
lemma_pow_one inp;
lemma_pow_add inp 1 1;
assert_norm (pow2 1 = 2);
assert (out == pow inp (pow2 1));
let out =
Lib.LoopCombinators.repeati_inductive #elem
(n - 1)
(fun i out -> out == pow inp (pow2 (i + 1)))
(fun i out ->
assert (out == pow inp (pow2 (i + 1)));
let res = fsqr out in
calc ( == ) {
fmul out out;
( == ) { lemma_pow_add inp (pow2 (i + 1)) (pow2 (i + 1)) }
pow inp (pow2 (i + 1) + pow2 (i + 1));
( == ) { Math.Lemmas.pow2_double_sum (i + 1) }
pow inp (pow2 (i + 2));
};
res)
out
in
assert (out == pow inp (pow2 n));
out | {
"checked_file": "Hacl.Spec.Curve25519.Finv.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Finv.fst"
} | [
"total"
] | [
"Spec.Curve25519.elem",
"Prims.pos",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Hacl.Spec.Curve25519.Finv.pow",
"Prims.pow2",
"Prims.op_Addition",
"Prims.op_Subtraction",
"Lib.LoopCombinators.repeati_inductive",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"FStar.Calc.calc_finish",
"Spec.Curve25519.fmul",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Hacl.Spec.Curve25519.Finv.lemma_pow_add",
"Prims.squash",
"FStar.Math.Lemmas.pow2_double_sum",
"Hacl.Spec.Curve25519.Finv.fsqr",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"Hacl.Spec.Curve25519.Finv.lemma_pow_one"
] | [] | module Hacl.Spec.Curve25519.Finv
open FStar.Mul
open Spec.Curve25519
module M = Lib.NatMod
module LE = Lib.Exponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let fsqr x = fmul x x
let pow = fpow
let cm_prime = M.mk_nat_mod_comm_monoid prime
val lemma_pow_mod_is_pow_cm : x:elem -> b:nat -> Lemma (pow x b = LE.pow cm_prime x b)
let lemma_pow_mod_is_pow_cm x b =
M.lemma_pow_nat_mod_is_pow #prime x b;
M.lemma_pow_mod #prime x b
val lemma_pow_one: x:elem -> Lemma (x == pow x 1)
let lemma_pow_one x =
lemma_pow_mod_is_pow_cm x 1;
LE.lemma_pow1 cm_prime x
val lemma_pow_add: x:elem -> n:nat -> m:nat ->
Lemma (fmul (pow x n) (pow x m) == pow x (n + m))
let lemma_pow_add x n m =
lemma_pow_mod_is_pow_cm x n;
lemma_pow_mod_is_pow_cm x m;
LE.lemma_pow_add cm_prime x n m;
lemma_pow_mod_is_pow_cm x (n + m)
val lemma_pow_mul: x:elem -> n:nat -> m:nat ->
Lemma (pow (pow x n) m == pow x (n * m))
let lemma_pow_mul x n m =
lemma_pow_mod_is_pow_cm x n;
lemma_pow_mod_is_pow_cm (pow x n) m;
LE.lemma_pow_mul cm_prime x n m;
lemma_pow_mod_is_pow_cm x (n * m)
val lemma_pow_double: a:elem -> b:nat ->
Lemma (pow (a *% a) b == pow a (b + b))
let lemma_pow_double a b =
lemma_pow_mod_is_pow_cm (a *% a) b;
LE.lemma_pow_double cm_prime a b;
lemma_pow_mod_is_pow_cm a (b + b) | false | false | Hacl.Spec.Curve25519.Finv.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fsquare_times: inp:elem -> n:pos -> out:elem{out == pow inp (pow2 n)} | [] | Hacl.Spec.Curve25519.Finv.fsquare_times | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Finv.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | inp: Spec.Curve25519.elem -> n: Prims.pos
-> out: Spec.Curve25519.elem{out == Hacl.Spec.Curve25519.Finv.pow inp (Prims.pow2 n)} | {
"end_col": 5,
"end_line": 70,
"start_col": 25,
"start_line": 49
} |
Prims.Pure | val finv0: inp:elem ->
Pure (tuple2 elem elem)
(requires True)
(ensures fun (a, t0) ->
a == pow inp 11 /\
t0 == pow inp pow_t0) | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | false | let finv0 i =
(* 2 *) let a = fsquare_times i 1 in
assert (a == pow i 2);
(* 8 *) let t0 = fsquare_times a 2 in
assert (t0 == pow a 4);
lemma_pow_mul i 2 4;
assert (t0 == pow i 8);
(* 9 *) let b = fmul t0 i in
lemma_pow_one i;
lemma_pow_add i 8 1;
assert (b == pow i 9);
(* 11 *) let a = fmul b a in
lemma_pow_add i 9 2;
assert (a == pow i 11);
(* 22 *) let t0 = fsquare_times a 1 in
lemma_pow_mul i 11 2;
assert (t0 == pow i 22);
(* 2^5 - 2^0 = 31 *) let b = fmul t0 b in
lemma_pow_add i 22 9;
assert (b == pow i 31);
(* 2^10 - 2^5 *) let t0 = fsquare_times b 5 in
lemma_pow_mul i 31 (pow2 5);
assert_norm (31 * pow2 5 = pow2 10 - pow2 5);
assert (t0 == pow i (pow2 10 - pow2 5));
(* 2^10 - 2^0 *) let b = fmul t0 b in
assert_norm (31 = pow2 5 - 1);
lemma_pow_add i (pow2 10 - pow2 5) (pow2 5 - 1);
assert (b == pow i (pow2 10 - 1));
(* 2^20 - 2^10 *) let t0 = fsquare_times b 10 in
lemma_pow_mul i (pow2 10 - 1) (pow2 10);
assert_norm ((pow2 10 - 1) * pow2 10 == pow2 20 - pow2 10);
assert (t0 == pow i (pow2 20 - pow2 10));
(* 2^20 - 2^0 *) let c = fmul t0 b in
lemma_pow_add i (pow2 20 - pow2 10) (pow2 10 - 1);
assert_norm (pow2 20 - pow2 10 + pow2 10 - 1 = pow2 20 - 1);
assert (c == pow i (pow2 20 - 1));
(* 2^40 - 2^20 *) let t0 = fsquare_times c 20 in
lemma_pow_mul i (pow2 20 - 1) (pow2 20);
assert_norm ((pow2 20 - 1) * pow2 20 = pow2 40 - pow2 20);
assert (t0 == pow i (pow2 40 - pow2 20));
(* 2^40 - 2^0 *) let t0 = fmul t0 c in
lemma_pow_add i (pow2 40 -pow2 20) (pow2 20 - 1);
assert_norm (pow2 40 - pow2 20 + pow2 20 - 1 = pow2 40 - 1);
assert (t0 == pow i (pow2 40 - 1));
(* 2^50 - 2^10 *) let t0 = fsquare_times t0 10 in
lemma_pow_mul i (pow2 40 - 1) (pow2 10);
assert_norm ((pow2 40 - 1) * pow2 10 = pow2 50 - pow2 10);
assert (t0 == pow i (pow2 50 - pow2 10));
(* 2^50 - 2^0 *) let b = fmul t0 b in
lemma_pow_add i (pow2 50 - pow2 10) (pow2 10 - 1);
assert_norm (pow2 50 - pow2 10 + pow2 10 - 1 = pow2 50 - 1);
assert (b == pow i (pow2 50 - 1));
(* 2^100 - 2^50 *) let t0 = fsquare_times b 50 in
lemma_pow_mul i (pow2 50 - 1) (pow2 50);
assert_norm ((pow2 50 - 1) * pow2 50 = pow2 100 - pow2 50);
assert (t0 == pow i (pow2 100 - pow2 50));
(* 2^100 - 2^0 *) let c = fmul t0 b in
lemma_pow_add i (pow2 100 - pow2 50) (pow2 50 - 1);
assert_norm (pow2 100 - pow2 50 + pow2 50 - 1 = pow2 100 - 1);
assert (c == pow i (pow2 100 - 1));
(* 2^200 - 2^100 *) let t0 = fsquare_times c 100 in
lemma_pow_mul i (pow2 100 - 1) (pow2 100);
assert_norm ((pow2 100 - 1) * pow2 100 = pow2 200 - pow2 100);
assert (t0 == pow i (pow2 200 - pow2 100));
(* 2^200 - 2^0 *) let t0 = fmul t0 c in
lemma_pow_add i (pow2 200 - pow2 100) (pow2 100 - 1);
assert_norm (pow2 200 - pow2 100 + pow2 100 - 1 = pow2 200 - 1);
assert (t0 == pow i (pow2 200 - 1));
(* 2^250 - 2^50 *) let t0 = fsquare_times t0 50 in
lemma_pow_mul i (pow2 200 - 1) (pow2 50);
assert_norm ((pow2 200 - 1) * pow2 50 = pow2 250 - pow2 50);
assert (t0 == pow i (pow2 250 - pow2 50));
(* 2^250 - 2^0 *) let t0 = fmul t0 b in
lemma_pow_add i (pow2 250 - pow2 50) (pow2 50 - 1);
assert_norm (pow2 250 - pow2 50 + pow2 50 - 1 = pow2 250 - 1);
assert (t0 == pow i (pow2 250 - 1));
(* 2^255 - 2^5 *) let t0 = fsquare_times t0 5 in
lemma_pow_mul i (pow2 250 - 1) (pow2 5);
assert_norm ((pow2 250 - 1) * pow2 5 = pow2 255 - pow2 5);
assert (t0 == pow i (pow2 255 - pow2 5));
a, t0 | val finv0: inp:elem ->
Pure (tuple2 elem elem)
(requires True)
(ensures fun (a, t0) ->
a == pow inp 11 /\
t0 == pow inp pow_t0)
let finv0 i = | false | null | false | let a = fsquare_times i 1 in
assert (a == pow i 2);
let t0 = fsquare_times a 2 in
assert (t0 == pow a 4);
lemma_pow_mul i 2 4;
assert (t0 == pow i 8);
let b = fmul t0 i in
lemma_pow_one i;
lemma_pow_add i 8 1;
assert (b == pow i 9);
let a = fmul b a in
lemma_pow_add i 9 2;
assert (a == pow i 11);
let t0 = fsquare_times a 1 in
lemma_pow_mul i 11 2;
assert (t0 == pow i 22);
let b = fmul t0 b in
lemma_pow_add i 22 9;
assert (b == pow i 31);
let t0 = fsquare_times b 5 in
lemma_pow_mul i 31 (pow2 5);
assert_norm (31 * pow2 5 = pow2 10 - pow2 5);
assert (t0 == pow i (pow2 10 - pow2 5));
let b = fmul t0 b in
assert_norm (31 = pow2 5 - 1);
lemma_pow_add i (pow2 10 - pow2 5) (pow2 5 - 1);
assert (b == pow i (pow2 10 - 1));
let t0 = fsquare_times b 10 in
lemma_pow_mul i (pow2 10 - 1) (pow2 10);
assert_norm ((pow2 10 - 1) * pow2 10 == pow2 20 - pow2 10);
assert (t0 == pow i (pow2 20 - pow2 10));
let c = fmul t0 b in
lemma_pow_add i (pow2 20 - pow2 10) (pow2 10 - 1);
assert_norm (pow2 20 - pow2 10 + pow2 10 - 1 = pow2 20 - 1);
assert (c == pow i (pow2 20 - 1));
let t0 = fsquare_times c 20 in
lemma_pow_mul i (pow2 20 - 1) (pow2 20);
assert_norm ((pow2 20 - 1) * pow2 20 = pow2 40 - pow2 20);
assert (t0 == pow i (pow2 40 - pow2 20));
let t0 = fmul t0 c in
lemma_pow_add i (pow2 40 - pow2 20) (pow2 20 - 1);
assert_norm (pow2 40 - pow2 20 + pow2 20 - 1 = pow2 40 - 1);
assert (t0 == pow i (pow2 40 - 1));
let t0 = fsquare_times t0 10 in
lemma_pow_mul i (pow2 40 - 1) (pow2 10);
assert_norm ((pow2 40 - 1) * pow2 10 = pow2 50 - pow2 10);
assert (t0 == pow i (pow2 50 - pow2 10));
let b = fmul t0 b in
lemma_pow_add i (pow2 50 - pow2 10) (pow2 10 - 1);
assert_norm (pow2 50 - pow2 10 + pow2 10 - 1 = pow2 50 - 1);
assert (b == pow i (pow2 50 - 1));
let t0 = fsquare_times b 50 in
lemma_pow_mul i (pow2 50 - 1) (pow2 50);
assert_norm ((pow2 50 - 1) * pow2 50 = pow2 100 - pow2 50);
assert (t0 == pow i (pow2 100 - pow2 50));
let c = fmul t0 b in
lemma_pow_add i (pow2 100 - pow2 50) (pow2 50 - 1);
assert_norm (pow2 100 - pow2 50 + pow2 50 - 1 = pow2 100 - 1);
assert (c == pow i (pow2 100 - 1));
let t0 = fsquare_times c 100 in
lemma_pow_mul i (pow2 100 - 1) (pow2 100);
assert_norm ((pow2 100 - 1) * pow2 100 = pow2 200 - pow2 100);
assert (t0 == pow i (pow2 200 - pow2 100));
let t0 = fmul t0 c in
lemma_pow_add i (pow2 200 - pow2 100) (pow2 100 - 1);
assert_norm (pow2 200 - pow2 100 + pow2 100 - 1 = pow2 200 - 1);
assert (t0 == pow i (pow2 200 - 1));
let t0 = fsquare_times t0 50 in
lemma_pow_mul i (pow2 200 - 1) (pow2 50);
assert_norm ((pow2 200 - 1) * pow2 50 = pow2 250 - pow2 50);
assert (t0 == pow i (pow2 250 - pow2 50));
let t0 = fmul t0 b in
lemma_pow_add i (pow2 250 - pow2 50) (pow2 50 - 1);
assert_norm (pow2 250 - pow2 50 + pow2 50 - 1 = pow2 250 - 1);
assert (t0 == pow i (pow2 250 - 1));
let t0 = fsquare_times t0 5 in
lemma_pow_mul i (pow2 250 - 1) (pow2 5);
assert_norm ((pow2 250 - 1) * pow2 5 = pow2 255 - pow2 5);
assert (t0 == pow i (pow2 255 - pow2 5));
a, t0 | {
"checked_file": "Hacl.Spec.Curve25519.Finv.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Finv.fst"
} | [] | [
"Spec.Curve25519.elem",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Hacl.Spec.Curve25519.Finv.pow",
"Prims.op_Subtraction",
"Prims.pow2",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.Mul.op_Star",
"Hacl.Spec.Curve25519.Finv.lemma_pow_mul",
"Hacl.Spec.Curve25519.Finv.fsquare_times",
"Prims.op_Addition",
"Hacl.Spec.Curve25519.Finv.lemma_pow_add",
"Spec.Curve25519.fmul",
"Hacl.Spec.Curve25519.Finv.lemma_pow_one",
"FStar.Pervasives.Native.tuple2"
] | [] | module Hacl.Spec.Curve25519.Finv
open FStar.Mul
open Spec.Curve25519
module M = Lib.NatMod
module LE = Lib.Exponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let fsqr x = fmul x x
let pow = fpow
let cm_prime = M.mk_nat_mod_comm_monoid prime
val lemma_pow_mod_is_pow_cm : x:elem -> b:nat -> Lemma (pow x b = LE.pow cm_prime x b)
let lemma_pow_mod_is_pow_cm x b =
M.lemma_pow_nat_mod_is_pow #prime x b;
M.lemma_pow_mod #prime x b
val lemma_pow_one: x:elem -> Lemma (x == pow x 1)
let lemma_pow_one x =
lemma_pow_mod_is_pow_cm x 1;
LE.lemma_pow1 cm_prime x
val lemma_pow_add: x:elem -> n:nat -> m:nat ->
Lemma (fmul (pow x n) (pow x m) == pow x (n + m))
let lemma_pow_add x n m =
lemma_pow_mod_is_pow_cm x n;
lemma_pow_mod_is_pow_cm x m;
LE.lemma_pow_add cm_prime x n m;
lemma_pow_mod_is_pow_cm x (n + m)
val lemma_pow_mul: x:elem -> n:nat -> m:nat ->
Lemma (pow (pow x n) m == pow x (n * m))
let lemma_pow_mul x n m =
lemma_pow_mod_is_pow_cm x n;
lemma_pow_mod_is_pow_cm (pow x n) m;
LE.lemma_pow_mul cm_prime x n m;
lemma_pow_mod_is_pow_cm x (n * m)
val lemma_pow_double: a:elem -> b:nat ->
Lemma (pow (a *% a) b == pow a (b + b))
let lemma_pow_double a b =
lemma_pow_mod_is_pow_cm (a *% a) b;
LE.lemma_pow_double cm_prime a b;
lemma_pow_mod_is_pow_cm a (b + b)
val fsquare_times: inp:elem -> n:pos -> out:elem{out == pow inp (pow2 n)}
let fsquare_times inp n =
let out = fsqr inp in
lemma_pow_one inp;
lemma_pow_add inp 1 1;
assert_norm (pow2 1 = 2);
assert (out == pow inp (pow2 1));
let out =
Lib.LoopCombinators.repeati_inductive #elem (n - 1)
(fun i out -> out == pow inp (pow2 (i + 1)))
(fun i out ->
assert (out == pow inp (pow2 (i + 1)));
let res = fsqr out in
calc (==) {
fmul out out;
(==) { lemma_pow_add inp (pow2 (i + 1)) (pow2 (i + 1)) }
pow inp (pow2 (i + 1) + pow2 (i + 1));
(==) { Math.Lemmas.pow2_double_sum (i + 1) }
pow inp (pow2 (i + 2));
};
res) out in
assert (out == pow inp (pow2 n));
out
let pow_t0:nat =
assert_norm (pow2 255 - pow2 5 > 0);
pow2 255 - pow2 5
val finv0: inp:elem ->
Pure (tuple2 elem elem)
(requires True)
(ensures fun (a, t0) ->
a == pow inp 11 /\ | false | false | Hacl.Spec.Curve25519.Finv.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val finv0: inp:elem ->
Pure (tuple2 elem elem)
(requires True)
(ensures fun (a, t0) ->
a == pow inp 11 /\
t0 == pow inp pow_t0) | [] | Hacl.Spec.Curve25519.Finv.finv0 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Finv.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | inp: Spec.Curve25519.elem -> Prims.Pure (Spec.Curve25519.elem * Spec.Curve25519.elem) | {
"end_col": 7,
"end_line": 162,
"start_col": 13,
"start_line": 82
} |
Prims.Tot | val mk_ref (t: term) : term | [
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_ref (t:term) : term = tm_pureapp (tm_fvar (as_fv ref_lid)) None t | val mk_ref (t: term) : term
let mk_ref (t: term) : term = | false | null | false | tm_pureapp (tm_fvar (as_fv ref_lid)) None t | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Pure.tm_pureapp",
"Pulse.Syntax.Pure.tm_fvar",
"Pulse.Syntax.Base.as_fv",
"Pulse.Reflection.Util.ref_lid",
"FStar.Pervasives.Native.None",
"Pulse.Syntax.Base.qualifier"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq)
let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1 | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_ref (t: term) : term | [] | Pulse.Typing.mk_ref | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.term | {
"end_col": 72,
"end_line": 60,
"start_col": 29,
"start_line": 60
} |
Prims.Tot | val freshv (g: env) (x: var) : prop | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let freshv (g:env) (x:var) : prop =
None? (lookup g x) | val freshv (g: env) (x: var) : prop
let freshv (g: env) (x: var) : prop = | false | null | false | None? (lookup g x) | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.var",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_None",
"Pulse.Syntax.Base.typ",
"Pulse.Typing.Env.lookup",
"Prims.prop"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq)
let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1
let mk_ref (t:term) : term = tm_pureapp (tm_fvar (as_fv ref_lid)) None t
let mk_pts_to (ty:term) (r:term) (v:term) : term =
let t = tm_fvar (as_fv pts_to_lid) in
let t = tm_pureapp t (Some Implicit) ty in
let t = tm_pureapp t None r in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let comp_return (c:ctag) (use_eq:bool) (u:universe) (t:term) (e:term) (post:term) (x:var)
: comp =
let post_maybe_eq =
if use_eq
then let post = open_term' post (null_var x) 0 in
let post = tm_star post (tm_pure (mk_eq2 u t (null_var x) e)) in
close_term post x
else post in
match c with
| STT ->
C_ST { u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Atomic ->
C_STAtomic tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Ghost ->
C_STGhost tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
module L = FStar.List.Tot
let extend_env_l (f:R.env) (g:env_bindings) : R.env =
L.fold_right
(fun (x, b) g ->
let t = elab_term b in
RT.extend_env g x t)
g
f
let elab_env (e:env) : R.env = extend_env_l (fstar_env e) (bindings e)
(*
* If I call this fresh, I get:
* Pulse.Typing.fst(545,0-546,20): (Error 162) The qualifier list "[assume]" is not permissible for this element: definitions cannot be assumed or marked with equality qualifiers
* What!?!? Oh.. there's a fresh in Pulse.Typing.Env, which is *included*...
*) | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val freshv (g: env) (x: var) : prop | [] | Pulse.Typing.freshv | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | g: Pulse.Typing.Env.env -> x: Pulse.Syntax.Base.var -> Prims.prop | {
"end_col": 20,
"end_line": 107,
"start_col": 2,
"start_line": 107
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tm_false = tm_constant R.C_False | let tm_false = | false | null | false | tm_constant R.C_False | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Pure.tm_constant",
"FStar.Reflection.V2.Data.C_False"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid) | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tm_false : Pulse.Syntax.Base.term | [] | Pulse.Typing.tm_false | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Pulse.Syntax.Base.term | {
"end_col": 36,
"end_line": 24,
"start_col": 15,
"start_line": 24
} |
|
Prims.Tot | val mk_reveal (u: universe) (t e: term) : term | [
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e | val mk_reveal (u: universe) (t e: term) : term
let mk_reveal (u: universe) (t e: term) : term = | false | null | false | let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Pure.tm_pureapp",
"FStar.Pervasives.Native.None",
"Pulse.Syntax.Base.qualifier",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.Implicit",
"Pulse.Syntax.Pure.tm_uinst",
"Pulse.Syntax.Base.as_fv",
"Pulse.Reflection.Util.reveal_lid",
"Prims.Cons",
"Prims.Nil"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_reveal (u: universe) (t e: term) : term | [] | Pulse.Typing.mk_reveal | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | u8: Pulse.Syntax.Base.universe -> t: Pulse.Syntax.Base.term -> e: Pulse.Syntax.Base.term
-> Pulse.Syntax.Base.term | {
"end_col": 22,
"end_line": 35,
"start_col": 53,
"start_line": 32
} |
Prims.Tot | val mk_eq2 (u: universe) (t e0 e1: term) : term | [
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1 | val mk_eq2 (u: universe) (t e0 e1: term) : term
let mk_eq2 (u: universe) (t e0 e1: term) : term = | false | null | false | tm_pureapp (tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t) None e0)
None
e1 | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Pure.tm_pureapp",
"Pulse.Syntax.Pure.tm_uinst",
"Pulse.Syntax.Base.as_fv",
"FStar.Reflection.Const.eq2_qn",
"Prims.Cons",
"Prims.Nil",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.qualifier",
"Pulse.Syntax.Base.Implicit",
"FStar.Pervasives.Native.None"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term) | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_eq2 (u: universe) (t e0 e1: term) : term | [] | Pulse.Typing.mk_eq2 | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
u15: Pulse.Syntax.Base.universe ->
t: Pulse.Syntax.Base.term ->
e0: Pulse.Syntax.Base.term ->
e1: Pulse.Syntax.Base.term
-> Pulse.Syntax.Base.term | {
"end_col": 37,
"end_line": 48,
"start_col": 4,
"start_line": 46
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tm_nat = tm_fvar (as_fv nat_lid) | let tm_nat = | false | null | false | tm_fvar (as_fv nat_lid) | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Pure.tm_fvar",
"Pulse.Syntax.Base.as_fv",
"Pulse.Reflection.Util.nat_lid"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid) | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tm_nat : Pulse.Syntax.Base.term | [] | Pulse.Typing.tm_nat | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Pulse.Syntax.Base.term | {
"end_col": 37,
"end_line": 21,
"start_col": 14,
"start_line": 21
} |
|
Prims.Tot | val mk_pts_to (ty r v: term) : term | [
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_pts_to (ty:term) (r:term) (v:term) : term =
let t = tm_fvar (as_fv pts_to_lid) in
let t = tm_pureapp t (Some Implicit) ty in
let t = tm_pureapp t None r in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v | val mk_pts_to (ty r v: term) : term
let mk_pts_to (ty r v: term) : term = | false | null | false | let t = tm_fvar (as_fv pts_to_lid) in
let t = tm_pureapp t (Some Implicit) ty in
let t = tm_pureapp t None r in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Pure.tm_pureapp",
"FStar.Pervasives.Native.None",
"Pulse.Syntax.Base.qualifier",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.Implicit",
"Pulse.Syntax.Pure.tm_fvar",
"Pulse.Syntax.Base.as_fv",
"Pulse.Reflection.Util.full_perm_lid",
"Pulse.Reflection.Util.pts_to_lid"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq)
let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1
let mk_ref (t:term) : term = tm_pureapp (tm_fvar (as_fv ref_lid)) None t | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_pts_to (ty r v: term) : term | [] | Pulse.Typing.mk_pts_to | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | ty: Pulse.Syntax.Base.term -> r: Pulse.Syntax.Base.term -> v: Pulse.Syntax.Base.term
-> Pulse.Syntax.Base.term | {
"end_col": 21,
"end_line": 67,
"start_col": 50,
"start_line": 62
} |
Prims.Tot | val extend_env_l (f: R.env) (g: env_bindings) : R.env | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let extend_env_l (f:R.env) (g:env_bindings) : R.env =
L.fold_right
(fun (x, b) g ->
let t = elab_term b in
RT.extend_env g x t)
g
f | val extend_env_l (f: R.env) (g: env_bindings) : R.env
let extend_env_l (f: R.env) (g: env_bindings) : R.env = | false | null | false | L.fold_right (fun (x, b) g ->
let t = elab_term b in
RT.extend_env g x t)
g
f | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"FStar.Reflection.Types.env",
"Pulse.Typing.Env.env_bindings",
"FStar.List.Tot.Base.fold_right",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.V2.Data.var",
"Pulse.Syntax.Base.term",
"FStar.Reflection.Typing.extend_env",
"FStar.Reflection.Types.term",
"Pulse.Elaborate.Pure.elab_term"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq)
let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1
let mk_ref (t:term) : term = tm_pureapp (tm_fvar (as_fv ref_lid)) None t
let mk_pts_to (ty:term) (r:term) (v:term) : term =
let t = tm_fvar (as_fv pts_to_lid) in
let t = tm_pureapp t (Some Implicit) ty in
let t = tm_pureapp t None r in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let comp_return (c:ctag) (use_eq:bool) (u:universe) (t:term) (e:term) (post:term) (x:var)
: comp =
let post_maybe_eq =
if use_eq
then let post = open_term' post (null_var x) 0 in
let post = tm_star post (tm_pure (mk_eq2 u t (null_var x) e)) in
close_term post x
else post in
match c with
| STT ->
C_ST { u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Atomic ->
C_STAtomic tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Ghost ->
C_STGhost tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
module L = FStar.List.Tot | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val extend_env_l (f: R.env) (g: env_bindings) : R.env | [] | Pulse.Typing.extend_env_l | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | f: FStar.Reflection.Types.env -> g: Pulse.Typing.Env.env_bindings -> FStar.Reflection.Types.env | {
"end_col": 6,
"end_line": 97,
"start_col": 2,
"start_line": 92
} |
Prims.Tot | val mk_vprop_eq (e0 e1: term) : term | [
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1 | val mk_vprop_eq (e0 e1: term) : term
let mk_vprop_eq (e0 e1: term) : term = | false | null | false | mk_eq2 u2 tm_vprop e0 e1 | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.term",
"Pulse.Typing.mk_eq2",
"Pulse.Syntax.Pure.u2",
"Pulse.Syntax.Base.tm_vprop"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq) | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_vprop_eq (e0 e1: term) : term | [] | Pulse.Typing.mk_vprop_eq | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | e0: Pulse.Syntax.Base.term -> e1: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.term | {
"end_col": 26,
"end_line": 58,
"start_col": 2,
"start_line": 58
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tm_true = tm_constant R.C_True | let tm_true = | false | null | false | tm_constant R.C_True | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Pure.tm_constant",
"FStar.Reflection.V2.Data.C_True"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid) | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tm_true : Pulse.Syntax.Base.term | [] | Pulse.Typing.tm_true | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Pulse.Syntax.Base.term | {
"end_col": 34,
"end_line": 23,
"start_col": 14,
"start_line": 23
} |
|
FStar.Tactics.Effect.Tac | val debug_log (level: string) (g: env) (f: (unit -> T.Tac string)) : T.Tac unit | [
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ())) | val debug_log (level: string) (g: env) (f: (unit -> T.Tac string)) : T.Tac unit
let debug_log (level: string) (g: env) (f: (unit -> T.Tac string)) : T.Tac unit = | true | null | false | if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ())) | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [] | [
"Prims.string",
"Pulse.Typing.Env.env",
"Prims.unit",
"Pulse.RuntimeUtils.debug_at_level",
"Pulse.Typing.Env.fstar_env",
"FStar.Tactics.V2.Builtins.print",
"FStar.Printf.sprintf",
"Prims.bool"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env | false | false | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val debug_log (level: string) (g: env) (f: (unit -> T.Tac string)) : T.Tac unit | [] | Pulse.Typing.debug_log | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
level: Prims.string ->
g: Pulse.Typing.Env.env ->
f: (_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.string)
-> FStar.Tactics.Effect.Tac Prims.unit | {
"end_col": 64,
"end_line": 16,
"start_col": 2,
"start_line": 15
} |
Prims.Tot | val mk_hide (u: universe) (t e: term) : term | [
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e | val mk_hide (u: universe) (t e: term) : term
let mk_hide (u: universe) (t e: term) : term = | false | null | false | let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Pure.tm_pureapp",
"FStar.Pervasives.Native.None",
"Pulse.Syntax.Base.qualifier",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.Implicit",
"Pulse.Syntax.Pure.tm_uinst",
"Pulse.Syntax.Base.as_fv",
"Pulse.Reflection.Util.hide_lid",
"Prims.Cons",
"Prims.Nil"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_hide (u: universe) (t e: term) : term | [] | Pulse.Typing.mk_hide | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | u11: Pulse.Syntax.Base.universe -> t: Pulse.Syntax.Base.term -> e: Pulse.Syntax.Base.term
-> Pulse.Syntax.Base.term | {
"end_col": 22,
"end_line": 40,
"start_col": 51,
"start_line": 37
} |
Prims.Tot | val elab_env (e: env) : R.env | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let elab_env (e:env) : R.env = extend_env_l (fstar_env e) (bindings e) | val elab_env (e: env) : R.env
let elab_env (e: env) : R.env = | false | null | false | extend_env_l (fstar_env e) (bindings e) | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Typing.Env.env",
"Pulse.Typing.extend_env_l",
"Pulse.Typing.Env.fstar_env",
"Pulse.Typing.Env.bindings",
"FStar.Reflection.Types.env"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq)
let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1
let mk_ref (t:term) : term = tm_pureapp (tm_fvar (as_fv ref_lid)) None t
let mk_pts_to (ty:term) (r:term) (v:term) : term =
let t = tm_fvar (as_fv pts_to_lid) in
let t = tm_pureapp t (Some Implicit) ty in
let t = tm_pureapp t None r in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let comp_return (c:ctag) (use_eq:bool) (u:universe) (t:term) (e:term) (post:term) (x:var)
: comp =
let post_maybe_eq =
if use_eq
then let post = open_term' post (null_var x) 0 in
let post = tm_star post (tm_pure (mk_eq2 u t (null_var x) e)) in
close_term post x
else post in
match c with
| STT ->
C_ST { u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Atomic ->
C_STAtomic tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Ghost ->
C_STGhost tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
module L = FStar.List.Tot
let extend_env_l (f:R.env) (g:env_bindings) : R.env =
L.fold_right
(fun (x, b) g ->
let t = elab_term b in
RT.extend_env g x t)
g | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val elab_env (e: env) : R.env | [] | Pulse.Typing.elab_env | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | e: Pulse.Typing.Env.env -> FStar.Reflection.Types.env | {
"end_col": 70,
"end_line": 98,
"start_col": 31,
"start_line": 98
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tm_int = tm_fvar (as_fv int_lid) | let tm_int = | false | null | false | tm_fvar (as_fv int_lid) | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Pure.tm_fvar",
"Pulse.Syntax.Base.as_fv",
"Pulse.Reflection.Util.int_lid"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid) | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tm_int : Pulse.Syntax.Base.term | [] | Pulse.Typing.tm_int | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Pulse.Syntax.Base.term | {
"end_col": 37,
"end_line": 20,
"start_col": 14,
"start_line": 20
} |
|
Prims.Tot | val comp_withlocal_body_pre (pre: vprop) (init_t r init: term) : vprop | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let comp_withlocal_body_pre (pre:vprop) (init_t:term) (r:term) (init:term) : vprop =
tm_star pre (mk_pts_to init_t r init) | val comp_withlocal_body_pre (pre: vprop) (init_t r init: term) : vprop
let comp_withlocal_body_pre (pre: vprop) (init_t r init: term) : vprop = | false | null | false | tm_star pre (mk_pts_to init_t r init) | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.vprop",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.tm_star",
"Pulse.Typing.mk_pts_to"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq)
let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1
let mk_ref (t:term) : term = tm_pureapp (tm_fvar (as_fv ref_lid)) None t
let mk_pts_to (ty:term) (r:term) (v:term) : term =
let t = tm_fvar (as_fv pts_to_lid) in
let t = tm_pureapp t (Some Implicit) ty in
let t = tm_pureapp t None r in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let comp_return (c:ctag) (use_eq:bool) (u:universe) (t:term) (e:term) (post:term) (x:var)
: comp =
let post_maybe_eq =
if use_eq
then let post = open_term' post (null_var x) 0 in
let post = tm_star post (tm_pure (mk_eq2 u t (null_var x) e)) in
close_term post x
else post in
match c with
| STT ->
C_ST { u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Atomic ->
C_STAtomic tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Ghost ->
C_STGhost tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
module L = FStar.List.Tot
let extend_env_l (f:R.env) (g:env_bindings) : R.env =
L.fold_right
(fun (x, b) g ->
let t = elab_term b in
RT.extend_env g x t)
g
f
let elab_env (e:env) : R.env = extend_env_l (fstar_env e) (bindings e)
(*
* If I call this fresh, I get:
* Pulse.Typing.fst(545,0-546,20): (Error 162) The qualifier list "[assume]" is not permissible for this element: definitions cannot be assumed or marked with equality qualifiers
* What!?!? Oh.. there's a fresh in Pulse.Typing.Env, which is *included*...
*)
let freshv (g:env) (x:var) : prop =
None? (lookup g x)
let rec all_fresh (g:env) (xs:list binding) : Tot prop (decreases xs) =
match xs with
| [] -> True
| x::xs -> freshv g (fst x) /\ all_fresh (push_binding g (fst x) ppname_default (snd x)) xs
let rec push_bindings (g:env) (bs:list binding{all_fresh g bs}) : Tot (g':env{env_extends g' g}) (decreases bs) =
match bs with
| [] -> g
| (x,t)::bs -> push_bindings (push_binding g x ppname_default t) bs
let elab_push_binding (g:env) (x:var { ~ (Set.mem x (dom g)) }) (t:typ)
: Lemma (elab_env (push_binding g x ppname_default t) ==
RT.extend_env (elab_env g) x (elab_term t)) = ()
[@@ erasable; no_auto_projectors]
noeq
type vprop_equiv : env -> term -> term -> Type =
| VE_Refl:
g:env ->
t:term ->
vprop_equiv g t t
| VE_Sym:
g:env ->
t1:term ->
t2:term ->
vprop_equiv g t1 t2 ->
vprop_equiv g t2 t1
| VE_Trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g t0 t1 ->
vprop_equiv g t1 t2 ->
vprop_equiv g t0 t2
| VE_Ctxt:
g:env ->
t0:term ->
t1:term ->
t0':term ->
t1':term ->
vprop_equiv g t0 t0' ->
vprop_equiv g t1 t1' ->
vprop_equiv g (tm_star t0 t1) (tm_star t0' t1')
| VE_Unit: (* *)
g:env ->
t:term ->
vprop_equiv g (tm_star tm_emp t) t
| VE_Comm:
g:env ->
t0:term ->
t1:term ->
vprop_equiv g (tm_star t0 t1) (tm_star t1 t0)
| VE_Assoc:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g (tm_star t0 (tm_star t1 t2)) (tm_star (tm_star t0 t1) t2)
| VE_Ext:
g:env ->
t0:term ->
t1:term ->
FTB.equiv_token (elab_env g) (elab_term t0) (elab_term t1) ->
vprop_equiv g t0 t1
// | VE_Ex:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (tm_exists_sl ty t0) (tm_exists_sl ty t1)
// | VE_Fa:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (Tm_ForallSL ty t0) (Tm_ForallSL ty t1)
let add_frame (s:comp_st) (frame:term)
: comp_st
= let add_frame_s (s:st_comp) : st_comp =
{ s with pre = tm_star s.pre frame;
post = tm_star s.post frame }
in
match s with
| C_ST s -> C_ST (add_frame_s s)
| C_STAtomic inames s -> C_STAtomic inames (add_frame_s s)
| C_STGhost inames s -> C_STGhost inames (add_frame_s s)
//
// TODO: there is a observability flag upcoming in the underlying steel framework
// the bind will then also allow for (statomic unobservable, statomic observable)
// and the symmetric one
//
let bind_comp_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| C_ST _, C_ST _ -> True
| _, _ -> False
let bind_comp_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_compatible c1 c2
let bind_comp_out (c1:comp_st) (c2:comp_st{bind_comp_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STGhost _ _ -> C_STGhost inames s
| C_ST _, C_ST _ -> C_ST s
let bind_comp_ghost_l_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STAtomic inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_l_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_l_compatible c1 c2
let bind_comp_ghost_l_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_l_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STAtomic _ _ -> C_STAtomic inames s
let bind_comp_ghost_r_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STAtomic inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_r_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_r_compatible c1 c2
let bind_comp_ghost_r_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_r_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STAtomic inames _, C_STGhost _ _ -> C_STAtomic inames s
let st_equiv_pre (c1 c2:comp_st)
: prop
= comp_u c1 == comp_u c2 /\
(match c1, c2 with
| C_ST _, C_ST _ -> True
| C_STAtomic inames1 _, C_STAtomic inames2 _ ->
inames1 == inames2
| C_STGhost inames1 _, C_STGhost inames2 _ ->
inames1 == inames2
| _, _ -> False)
let non_informative_witness_t (u:universe) (t:term)
: term
= tm_pureapp (tm_uinst (as_fv non_informative_witness_lid) [u])
None
t
let elim_exists_post (u:universe) (t:term) (p:term) (x:nvar)
: term
= let x_tm = term_of_nvar x in
let p = open_term' p (mk_reveal u t x_tm) 0 in
close_term p (snd x)
let comp_elim_exists (u:universe) (t:term) (p:term) (x:nvar)
: comp
= C_STGhost tm_emp_inames
{
u=u;
res=mk_erased u t;
pre=tm_exists_sl u (as_binder t) p;
post=elim_exists_post u t p x
}
let comp_intro_pure (p:term) =
C_STGhost tm_emp_inames
{
u=u_zero;
res=tm_unit;
pre=tm_emp;
post=tm_pure p
}
let named_binder (x:ppname) (t:term) = { binder_ppname = x; binder_ty = t}
let comp_intro_exists (u:universe) (b:binder) (p:term) (e:term)
: comp
= C_STGhost tm_emp_inames
{
u=u0;
res=tm_unit;
pre=open_term' p e 0;
post=tm_exists_sl u b p
}
let comp_intro_exists_erased (u:universe) (b:binder) (p:term) (e:term)
: comp
= C_STGhost tm_emp_inames
{
u=u0;
res=tm_unit;
pre=open_term' p (mk_reveal u b.binder_ty e) 0;
post=tm_exists_sl u b p
}
let comp_while_cond (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_bool;
pre=tm_exists_sl u0 (named_binder x tm_bool) inv;
post=inv
}
let comp_while_body (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_unit;
pre=open_term' inv tm_true 0;
post=tm_exists_sl u0 (named_binder x tm_bool) inv
}
let comp_while (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_unit;
pre=tm_exists_sl u0 (named_binder x tm_bool) inv;
post=open_term' inv tm_false 0
}
let mk_tuple2 (u1 u2:universe) (t1 t2:term) : term =
tm_pureapp (tm_pureapp (tm_uinst (as_fv tuple2_lid) [u1; u2])
None
t1)
None t2
let mk_fst (u1 u2:universe) (a1 a2 e:term) : term =
tm_pureapp (tm_pureapp (tm_pureapp (tm_uinst (as_fv fst_lid) [u1; u2]) (Some Implicit) a1)
(Some Implicit) a2)
None
e
let mk_snd (u1 u2:universe) (a1 a2 e:term) : term =
tm_pureapp (tm_pureapp (tm_pureapp (tm_uinst (as_fv snd_lid) [u1; u2]) (Some Implicit) a1)
(Some Implicit) a2)
None
e
let par_post (uL uR:universe) (aL aR postL postR:term) (x:var) : term =
let x_tm = term_of_no_name_var x in
let postL = open_term' postL (mk_fst uL uR aL aR x_tm) 0 in
let postR = open_term' postR (mk_snd uL uR aL aR x_tm) 0 in
let post = tm_star postL postR in
close_term post x
let comp_par (cL:comp{C_ST? cL}) (cR:comp{C_ST? cR}) (x:var) : comp =
let uL = comp_u cL in
let uR = comp_u cR in
let aL = comp_res cL in
let aR = comp_res cR in
let post = par_post uL uR aL aR (comp_post cL) (comp_post cR) x in
C_ST {
u = uL;
res = mk_tuple2 uL uR aL aR;
pre = tm_star (comp_pre cL) (comp_pre cR);
post
} | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val comp_withlocal_body_pre (pre: vprop) (init_t r init: term) : vprop | [] | Pulse.Typing.comp_withlocal_body_pre | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
pre: Pulse.Syntax.Base.vprop ->
init_t: Pulse.Syntax.Base.term ->
r: Pulse.Syntax.Base.term ->
init: Pulse.Syntax.Base.term
-> Pulse.Syntax.Base.vprop | {
"end_col": 39,
"end_line": 407,
"start_col": 2,
"start_line": 407
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let named_binder (x:ppname) (t:term) = { binder_ppname = x; binder_ty = t} | let named_binder (x: ppname) (t: term) = | false | null | false | { binder_ppname = x; binder_ty = t } | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.ppname",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.Mkbinder",
"Pulse.Syntax.Base.binder"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq)
let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1
let mk_ref (t:term) : term = tm_pureapp (tm_fvar (as_fv ref_lid)) None t
let mk_pts_to (ty:term) (r:term) (v:term) : term =
let t = tm_fvar (as_fv pts_to_lid) in
let t = tm_pureapp t (Some Implicit) ty in
let t = tm_pureapp t None r in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let comp_return (c:ctag) (use_eq:bool) (u:universe) (t:term) (e:term) (post:term) (x:var)
: comp =
let post_maybe_eq =
if use_eq
then let post = open_term' post (null_var x) 0 in
let post = tm_star post (tm_pure (mk_eq2 u t (null_var x) e)) in
close_term post x
else post in
match c with
| STT ->
C_ST { u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Atomic ->
C_STAtomic tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Ghost ->
C_STGhost tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
module L = FStar.List.Tot
let extend_env_l (f:R.env) (g:env_bindings) : R.env =
L.fold_right
(fun (x, b) g ->
let t = elab_term b in
RT.extend_env g x t)
g
f
let elab_env (e:env) : R.env = extend_env_l (fstar_env e) (bindings e)
(*
* If I call this fresh, I get:
* Pulse.Typing.fst(545,0-546,20): (Error 162) The qualifier list "[assume]" is not permissible for this element: definitions cannot be assumed or marked with equality qualifiers
* What!?!? Oh.. there's a fresh in Pulse.Typing.Env, which is *included*...
*)
let freshv (g:env) (x:var) : prop =
None? (lookup g x)
let rec all_fresh (g:env) (xs:list binding) : Tot prop (decreases xs) =
match xs with
| [] -> True
| x::xs -> freshv g (fst x) /\ all_fresh (push_binding g (fst x) ppname_default (snd x)) xs
let rec push_bindings (g:env) (bs:list binding{all_fresh g bs}) : Tot (g':env{env_extends g' g}) (decreases bs) =
match bs with
| [] -> g
| (x,t)::bs -> push_bindings (push_binding g x ppname_default t) bs
let elab_push_binding (g:env) (x:var { ~ (Set.mem x (dom g)) }) (t:typ)
: Lemma (elab_env (push_binding g x ppname_default t) ==
RT.extend_env (elab_env g) x (elab_term t)) = ()
[@@ erasable; no_auto_projectors]
noeq
type vprop_equiv : env -> term -> term -> Type =
| VE_Refl:
g:env ->
t:term ->
vprop_equiv g t t
| VE_Sym:
g:env ->
t1:term ->
t2:term ->
vprop_equiv g t1 t2 ->
vprop_equiv g t2 t1
| VE_Trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g t0 t1 ->
vprop_equiv g t1 t2 ->
vprop_equiv g t0 t2
| VE_Ctxt:
g:env ->
t0:term ->
t1:term ->
t0':term ->
t1':term ->
vprop_equiv g t0 t0' ->
vprop_equiv g t1 t1' ->
vprop_equiv g (tm_star t0 t1) (tm_star t0' t1')
| VE_Unit: (* *)
g:env ->
t:term ->
vprop_equiv g (tm_star tm_emp t) t
| VE_Comm:
g:env ->
t0:term ->
t1:term ->
vprop_equiv g (tm_star t0 t1) (tm_star t1 t0)
| VE_Assoc:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g (tm_star t0 (tm_star t1 t2)) (tm_star (tm_star t0 t1) t2)
| VE_Ext:
g:env ->
t0:term ->
t1:term ->
FTB.equiv_token (elab_env g) (elab_term t0) (elab_term t1) ->
vprop_equiv g t0 t1
// | VE_Ex:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (tm_exists_sl ty t0) (tm_exists_sl ty t1)
// | VE_Fa:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (Tm_ForallSL ty t0) (Tm_ForallSL ty t1)
let add_frame (s:comp_st) (frame:term)
: comp_st
= let add_frame_s (s:st_comp) : st_comp =
{ s with pre = tm_star s.pre frame;
post = tm_star s.post frame }
in
match s with
| C_ST s -> C_ST (add_frame_s s)
| C_STAtomic inames s -> C_STAtomic inames (add_frame_s s)
| C_STGhost inames s -> C_STGhost inames (add_frame_s s)
//
// TODO: there is a observability flag upcoming in the underlying steel framework
// the bind will then also allow for (statomic unobservable, statomic observable)
// and the symmetric one
//
let bind_comp_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| C_ST _, C_ST _ -> True
| _, _ -> False
let bind_comp_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_compatible c1 c2
let bind_comp_out (c1:comp_st) (c2:comp_st{bind_comp_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STGhost _ _ -> C_STGhost inames s
| C_ST _, C_ST _ -> C_ST s
let bind_comp_ghost_l_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STAtomic inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_l_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_l_compatible c1 c2
let bind_comp_ghost_l_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_l_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STAtomic _ _ -> C_STAtomic inames s
let bind_comp_ghost_r_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STAtomic inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_r_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_r_compatible c1 c2
let bind_comp_ghost_r_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_r_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STAtomic inames _, C_STGhost _ _ -> C_STAtomic inames s
let st_equiv_pre (c1 c2:comp_st)
: prop
= comp_u c1 == comp_u c2 /\
(match c1, c2 with
| C_ST _, C_ST _ -> True
| C_STAtomic inames1 _, C_STAtomic inames2 _ ->
inames1 == inames2
| C_STGhost inames1 _, C_STGhost inames2 _ ->
inames1 == inames2
| _, _ -> False)
let non_informative_witness_t (u:universe) (t:term)
: term
= tm_pureapp (tm_uinst (as_fv non_informative_witness_lid) [u])
None
t
let elim_exists_post (u:universe) (t:term) (p:term) (x:nvar)
: term
= let x_tm = term_of_nvar x in
let p = open_term' p (mk_reveal u t x_tm) 0 in
close_term p (snd x)
let comp_elim_exists (u:universe) (t:term) (p:term) (x:nvar)
: comp
= C_STGhost tm_emp_inames
{
u=u;
res=mk_erased u t;
pre=tm_exists_sl u (as_binder t) p;
post=elim_exists_post u t p x
}
let comp_intro_pure (p:term) =
C_STGhost tm_emp_inames
{
u=u_zero;
res=tm_unit;
pre=tm_emp;
post=tm_pure p
} | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val named_binder : x: Pulse.Syntax.Base.ppname -> t: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.binder | [] | Pulse.Typing.named_binder | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: Pulse.Syntax.Base.ppname -> t: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.binder | {
"end_col": 73,
"end_line": 315,
"start_col": 41,
"start_line": 315
} |
|
Prims.Tot | val mk_fst (u1 u2: universe) (a1 a2 e: term) : term | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_fst (u1 u2:universe) (a1 a2 e:term) : term =
tm_pureapp (tm_pureapp (tm_pureapp (tm_uinst (as_fv fst_lid) [u1; u2]) (Some Implicit) a1)
(Some Implicit) a2)
None
e | val mk_fst (u1 u2: universe) (a1 a2 e: term) : term
let mk_fst (u1 u2: universe) (a1 a2 e: term) : term = | false | null | false | tm_pureapp (tm_pureapp (tm_pureapp (tm_uinst (as_fv fst_lid) [u1; u2]) (Some Implicit) a1)
(Some Implicit)
a2)
None
e | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Pure.tm_pureapp",
"Pulse.Syntax.Pure.tm_uinst",
"Pulse.Syntax.Base.as_fv",
"Pulse.Reflection.Util.fst_lid",
"Prims.Cons",
"Prims.Nil",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.qualifier",
"Pulse.Syntax.Base.Implicit",
"FStar.Pervasives.Native.None"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq)
let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1
let mk_ref (t:term) : term = tm_pureapp (tm_fvar (as_fv ref_lid)) None t
let mk_pts_to (ty:term) (r:term) (v:term) : term =
let t = tm_fvar (as_fv pts_to_lid) in
let t = tm_pureapp t (Some Implicit) ty in
let t = tm_pureapp t None r in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let comp_return (c:ctag) (use_eq:bool) (u:universe) (t:term) (e:term) (post:term) (x:var)
: comp =
let post_maybe_eq =
if use_eq
then let post = open_term' post (null_var x) 0 in
let post = tm_star post (tm_pure (mk_eq2 u t (null_var x) e)) in
close_term post x
else post in
match c with
| STT ->
C_ST { u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Atomic ->
C_STAtomic tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Ghost ->
C_STGhost tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
module L = FStar.List.Tot
let extend_env_l (f:R.env) (g:env_bindings) : R.env =
L.fold_right
(fun (x, b) g ->
let t = elab_term b in
RT.extend_env g x t)
g
f
let elab_env (e:env) : R.env = extend_env_l (fstar_env e) (bindings e)
(*
* If I call this fresh, I get:
* Pulse.Typing.fst(545,0-546,20): (Error 162) The qualifier list "[assume]" is not permissible for this element: definitions cannot be assumed or marked with equality qualifiers
* What!?!? Oh.. there's a fresh in Pulse.Typing.Env, which is *included*...
*)
let freshv (g:env) (x:var) : prop =
None? (lookup g x)
let rec all_fresh (g:env) (xs:list binding) : Tot prop (decreases xs) =
match xs with
| [] -> True
| x::xs -> freshv g (fst x) /\ all_fresh (push_binding g (fst x) ppname_default (snd x)) xs
let rec push_bindings (g:env) (bs:list binding{all_fresh g bs}) : Tot (g':env{env_extends g' g}) (decreases bs) =
match bs with
| [] -> g
| (x,t)::bs -> push_bindings (push_binding g x ppname_default t) bs
let elab_push_binding (g:env) (x:var { ~ (Set.mem x (dom g)) }) (t:typ)
: Lemma (elab_env (push_binding g x ppname_default t) ==
RT.extend_env (elab_env g) x (elab_term t)) = ()
[@@ erasable; no_auto_projectors]
noeq
type vprop_equiv : env -> term -> term -> Type =
| VE_Refl:
g:env ->
t:term ->
vprop_equiv g t t
| VE_Sym:
g:env ->
t1:term ->
t2:term ->
vprop_equiv g t1 t2 ->
vprop_equiv g t2 t1
| VE_Trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g t0 t1 ->
vprop_equiv g t1 t2 ->
vprop_equiv g t0 t2
| VE_Ctxt:
g:env ->
t0:term ->
t1:term ->
t0':term ->
t1':term ->
vprop_equiv g t0 t0' ->
vprop_equiv g t1 t1' ->
vprop_equiv g (tm_star t0 t1) (tm_star t0' t1')
| VE_Unit: (* *)
g:env ->
t:term ->
vprop_equiv g (tm_star tm_emp t) t
| VE_Comm:
g:env ->
t0:term ->
t1:term ->
vprop_equiv g (tm_star t0 t1) (tm_star t1 t0)
| VE_Assoc:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g (tm_star t0 (tm_star t1 t2)) (tm_star (tm_star t0 t1) t2)
| VE_Ext:
g:env ->
t0:term ->
t1:term ->
FTB.equiv_token (elab_env g) (elab_term t0) (elab_term t1) ->
vprop_equiv g t0 t1
// | VE_Ex:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (tm_exists_sl ty t0) (tm_exists_sl ty t1)
// | VE_Fa:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (Tm_ForallSL ty t0) (Tm_ForallSL ty t1)
let add_frame (s:comp_st) (frame:term)
: comp_st
= let add_frame_s (s:st_comp) : st_comp =
{ s with pre = tm_star s.pre frame;
post = tm_star s.post frame }
in
match s with
| C_ST s -> C_ST (add_frame_s s)
| C_STAtomic inames s -> C_STAtomic inames (add_frame_s s)
| C_STGhost inames s -> C_STGhost inames (add_frame_s s)
//
// TODO: there is a observability flag upcoming in the underlying steel framework
// the bind will then also allow for (statomic unobservable, statomic observable)
// and the symmetric one
//
let bind_comp_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| C_ST _, C_ST _ -> True
| _, _ -> False
let bind_comp_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_compatible c1 c2
let bind_comp_out (c1:comp_st) (c2:comp_st{bind_comp_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STGhost _ _ -> C_STGhost inames s
| C_ST _, C_ST _ -> C_ST s
let bind_comp_ghost_l_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STAtomic inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_l_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_l_compatible c1 c2
let bind_comp_ghost_l_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_l_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STAtomic _ _ -> C_STAtomic inames s
let bind_comp_ghost_r_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STAtomic inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_r_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_r_compatible c1 c2
let bind_comp_ghost_r_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_r_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STAtomic inames _, C_STGhost _ _ -> C_STAtomic inames s
let st_equiv_pre (c1 c2:comp_st)
: prop
= comp_u c1 == comp_u c2 /\
(match c1, c2 with
| C_ST _, C_ST _ -> True
| C_STAtomic inames1 _, C_STAtomic inames2 _ ->
inames1 == inames2
| C_STGhost inames1 _, C_STGhost inames2 _ ->
inames1 == inames2
| _, _ -> False)
let non_informative_witness_t (u:universe) (t:term)
: term
= tm_pureapp (tm_uinst (as_fv non_informative_witness_lid) [u])
None
t
let elim_exists_post (u:universe) (t:term) (p:term) (x:nvar)
: term
= let x_tm = term_of_nvar x in
let p = open_term' p (mk_reveal u t x_tm) 0 in
close_term p (snd x)
let comp_elim_exists (u:universe) (t:term) (p:term) (x:nvar)
: comp
= C_STGhost tm_emp_inames
{
u=u;
res=mk_erased u t;
pre=tm_exists_sl u (as_binder t) p;
post=elim_exists_post u t p x
}
let comp_intro_pure (p:term) =
C_STGhost tm_emp_inames
{
u=u_zero;
res=tm_unit;
pre=tm_emp;
post=tm_pure p
}
let named_binder (x:ppname) (t:term) = { binder_ppname = x; binder_ty = t}
let comp_intro_exists (u:universe) (b:binder) (p:term) (e:term)
: comp
= C_STGhost tm_emp_inames
{
u=u0;
res=tm_unit;
pre=open_term' p e 0;
post=tm_exists_sl u b p
}
let comp_intro_exists_erased (u:universe) (b:binder) (p:term) (e:term)
: comp
= C_STGhost tm_emp_inames
{
u=u0;
res=tm_unit;
pre=open_term' p (mk_reveal u b.binder_ty e) 0;
post=tm_exists_sl u b p
}
let comp_while_cond (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_bool;
pre=tm_exists_sl u0 (named_binder x tm_bool) inv;
post=inv
}
let comp_while_body (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_unit;
pre=open_term' inv tm_true 0;
post=tm_exists_sl u0 (named_binder x tm_bool) inv
}
let comp_while (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_unit;
pre=tm_exists_sl u0 (named_binder x tm_bool) inv;
post=open_term' inv tm_false 0
}
let mk_tuple2 (u1 u2:universe) (t1 t2:term) : term =
tm_pureapp (tm_pureapp (tm_uinst (as_fv tuple2_lid) [u1; u2])
None
t1)
None t2 | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_fst (u1 u2: universe) (a1 a2 e: term) : term | [] | Pulse.Typing.mk_fst | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
u1: Pulse.Syntax.Base.universe ->
u2: Pulse.Syntax.Base.universe ->
a1: Pulse.Syntax.Base.term ->
a2: Pulse.Syntax.Base.term ->
e: Pulse.Syntax.Base.term
-> Pulse.Syntax.Base.term | {
"end_col": 14,
"end_line": 375,
"start_col": 2,
"start_line": 372
} |
Prims.Tot | val bind_comp_ghost_r_compatible (c1 c2: comp_st) : prop | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bind_comp_ghost_r_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STAtomic inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| _, _ -> False | val bind_comp_ghost_r_compatible (c1 c2: comp_st) : prop
let bind_comp_ghost_r_compatible (c1 c2: comp_st) : prop = | false | null | false | match c1, c2 with
| C_STAtomic inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| _, _ -> False | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.comp_st",
"FStar.Pervasives.Native.Mktuple2",
"Pulse.Syntax.Base.comp",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.st_comp",
"Prims.eq2",
"Prims.l_False",
"Prims.prop"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq)
let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1
let mk_ref (t:term) : term = tm_pureapp (tm_fvar (as_fv ref_lid)) None t
let mk_pts_to (ty:term) (r:term) (v:term) : term =
let t = tm_fvar (as_fv pts_to_lid) in
let t = tm_pureapp t (Some Implicit) ty in
let t = tm_pureapp t None r in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let comp_return (c:ctag) (use_eq:bool) (u:universe) (t:term) (e:term) (post:term) (x:var)
: comp =
let post_maybe_eq =
if use_eq
then let post = open_term' post (null_var x) 0 in
let post = tm_star post (tm_pure (mk_eq2 u t (null_var x) e)) in
close_term post x
else post in
match c with
| STT ->
C_ST { u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Atomic ->
C_STAtomic tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Ghost ->
C_STGhost tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
module L = FStar.List.Tot
let extend_env_l (f:R.env) (g:env_bindings) : R.env =
L.fold_right
(fun (x, b) g ->
let t = elab_term b in
RT.extend_env g x t)
g
f
let elab_env (e:env) : R.env = extend_env_l (fstar_env e) (bindings e)
(*
* If I call this fresh, I get:
* Pulse.Typing.fst(545,0-546,20): (Error 162) The qualifier list "[assume]" is not permissible for this element: definitions cannot be assumed or marked with equality qualifiers
* What!?!? Oh.. there's a fresh in Pulse.Typing.Env, which is *included*...
*)
let freshv (g:env) (x:var) : prop =
None? (lookup g x)
let rec all_fresh (g:env) (xs:list binding) : Tot prop (decreases xs) =
match xs with
| [] -> True
| x::xs -> freshv g (fst x) /\ all_fresh (push_binding g (fst x) ppname_default (snd x)) xs
let rec push_bindings (g:env) (bs:list binding{all_fresh g bs}) : Tot (g':env{env_extends g' g}) (decreases bs) =
match bs with
| [] -> g
| (x,t)::bs -> push_bindings (push_binding g x ppname_default t) bs
let elab_push_binding (g:env) (x:var { ~ (Set.mem x (dom g)) }) (t:typ)
: Lemma (elab_env (push_binding g x ppname_default t) ==
RT.extend_env (elab_env g) x (elab_term t)) = ()
[@@ erasable; no_auto_projectors]
noeq
type vprop_equiv : env -> term -> term -> Type =
| VE_Refl:
g:env ->
t:term ->
vprop_equiv g t t
| VE_Sym:
g:env ->
t1:term ->
t2:term ->
vprop_equiv g t1 t2 ->
vprop_equiv g t2 t1
| VE_Trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g t0 t1 ->
vprop_equiv g t1 t2 ->
vprop_equiv g t0 t2
| VE_Ctxt:
g:env ->
t0:term ->
t1:term ->
t0':term ->
t1':term ->
vprop_equiv g t0 t0' ->
vprop_equiv g t1 t1' ->
vprop_equiv g (tm_star t0 t1) (tm_star t0' t1')
| VE_Unit: (* *)
g:env ->
t:term ->
vprop_equiv g (tm_star tm_emp t) t
| VE_Comm:
g:env ->
t0:term ->
t1:term ->
vprop_equiv g (tm_star t0 t1) (tm_star t1 t0)
| VE_Assoc:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g (tm_star t0 (tm_star t1 t2)) (tm_star (tm_star t0 t1) t2)
| VE_Ext:
g:env ->
t0:term ->
t1:term ->
FTB.equiv_token (elab_env g) (elab_term t0) (elab_term t1) ->
vprop_equiv g t0 t1
// | VE_Ex:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (tm_exists_sl ty t0) (tm_exists_sl ty t1)
// | VE_Fa:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (Tm_ForallSL ty t0) (Tm_ForallSL ty t1)
let add_frame (s:comp_st) (frame:term)
: comp_st
= let add_frame_s (s:st_comp) : st_comp =
{ s with pre = tm_star s.pre frame;
post = tm_star s.post frame }
in
match s with
| C_ST s -> C_ST (add_frame_s s)
| C_STAtomic inames s -> C_STAtomic inames (add_frame_s s)
| C_STGhost inames s -> C_STGhost inames (add_frame_s s)
//
// TODO: there is a observability flag upcoming in the underlying steel framework
// the bind will then also allow for (statomic unobservable, statomic observable)
// and the symmetric one
//
let bind_comp_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| C_ST _, C_ST _ -> True
| _, _ -> False
let bind_comp_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_compatible c1 c2
let bind_comp_out (c1:comp_st) (c2:comp_st{bind_comp_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STGhost _ _ -> C_STGhost inames s
| C_ST _, C_ST _ -> C_ST s
let bind_comp_ghost_l_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STAtomic inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_l_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_l_compatible c1 c2
let bind_comp_ghost_l_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_l_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STAtomic _ _ -> C_STAtomic inames s
let bind_comp_ghost_r_compatible (c1 c2:comp_st) | false | false | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bind_comp_ghost_r_compatible (c1 c2: comp_st) : prop | [] | Pulse.Typing.bind_comp_ghost_r_compatible | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | c1: Pulse.Syntax.Base.comp_st -> c2: Pulse.Syntax.Base.comp_st -> Prims.prop | {
"end_col": 19,
"end_line": 259,
"start_col": 4,
"start_line": 257
} |
Prims.Tot | val comp_rewrite (p q: vprop) : comp | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let comp_rewrite (p q:vprop) : comp =
C_STGhost tm_emp_inames {
u = u0;
res = tm_unit;
pre = p;
post = q;
} | val comp_rewrite (p q: vprop) : comp
let comp_rewrite (p q: vprop) : comp = | false | null | false | C_STGhost tm_emp_inames ({ u = u0; res = tm_unit; pre = p; post = q }) | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.vprop",
"Pulse.Syntax.Base.C_STGhost",
"Pulse.Syntax.Base.tm_emp_inames",
"Pulse.Syntax.Base.Mkst_comp",
"Pulse.Syntax.Pure.u0",
"Pulse.Typing.tm_unit",
"Pulse.Syntax.Base.comp"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq)
let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1
let mk_ref (t:term) : term = tm_pureapp (tm_fvar (as_fv ref_lid)) None t
let mk_pts_to (ty:term) (r:term) (v:term) : term =
let t = tm_fvar (as_fv pts_to_lid) in
let t = tm_pureapp t (Some Implicit) ty in
let t = tm_pureapp t None r in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let comp_return (c:ctag) (use_eq:bool) (u:universe) (t:term) (e:term) (post:term) (x:var)
: comp =
let post_maybe_eq =
if use_eq
then let post = open_term' post (null_var x) 0 in
let post = tm_star post (tm_pure (mk_eq2 u t (null_var x) e)) in
close_term post x
else post in
match c with
| STT ->
C_ST { u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Atomic ->
C_STAtomic tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Ghost ->
C_STGhost tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
module L = FStar.List.Tot
let extend_env_l (f:R.env) (g:env_bindings) : R.env =
L.fold_right
(fun (x, b) g ->
let t = elab_term b in
RT.extend_env g x t)
g
f
let elab_env (e:env) : R.env = extend_env_l (fstar_env e) (bindings e)
(*
* If I call this fresh, I get:
* Pulse.Typing.fst(545,0-546,20): (Error 162) The qualifier list "[assume]" is not permissible for this element: definitions cannot be assumed or marked with equality qualifiers
* What!?!? Oh.. there's a fresh in Pulse.Typing.Env, which is *included*...
*)
let freshv (g:env) (x:var) : prop =
None? (lookup g x)
let rec all_fresh (g:env) (xs:list binding) : Tot prop (decreases xs) =
match xs with
| [] -> True
| x::xs -> freshv g (fst x) /\ all_fresh (push_binding g (fst x) ppname_default (snd x)) xs
let rec push_bindings (g:env) (bs:list binding{all_fresh g bs}) : Tot (g':env{env_extends g' g}) (decreases bs) =
match bs with
| [] -> g
| (x,t)::bs -> push_bindings (push_binding g x ppname_default t) bs
let elab_push_binding (g:env) (x:var { ~ (Set.mem x (dom g)) }) (t:typ)
: Lemma (elab_env (push_binding g x ppname_default t) ==
RT.extend_env (elab_env g) x (elab_term t)) = ()
[@@ erasable; no_auto_projectors]
noeq
type vprop_equiv : env -> term -> term -> Type =
| VE_Refl:
g:env ->
t:term ->
vprop_equiv g t t
| VE_Sym:
g:env ->
t1:term ->
t2:term ->
vprop_equiv g t1 t2 ->
vprop_equiv g t2 t1
| VE_Trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g t0 t1 ->
vprop_equiv g t1 t2 ->
vprop_equiv g t0 t2
| VE_Ctxt:
g:env ->
t0:term ->
t1:term ->
t0':term ->
t1':term ->
vprop_equiv g t0 t0' ->
vprop_equiv g t1 t1' ->
vprop_equiv g (tm_star t0 t1) (tm_star t0' t1')
| VE_Unit: (* *)
g:env ->
t:term ->
vprop_equiv g (tm_star tm_emp t) t
| VE_Comm:
g:env ->
t0:term ->
t1:term ->
vprop_equiv g (tm_star t0 t1) (tm_star t1 t0)
| VE_Assoc:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g (tm_star t0 (tm_star t1 t2)) (tm_star (tm_star t0 t1) t2)
| VE_Ext:
g:env ->
t0:term ->
t1:term ->
FTB.equiv_token (elab_env g) (elab_term t0) (elab_term t1) ->
vprop_equiv g t0 t1
// | VE_Ex:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (tm_exists_sl ty t0) (tm_exists_sl ty t1)
// | VE_Fa:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (Tm_ForallSL ty t0) (Tm_ForallSL ty t1)
let add_frame (s:comp_st) (frame:term)
: comp_st
= let add_frame_s (s:st_comp) : st_comp =
{ s with pre = tm_star s.pre frame;
post = tm_star s.post frame }
in
match s with
| C_ST s -> C_ST (add_frame_s s)
| C_STAtomic inames s -> C_STAtomic inames (add_frame_s s)
| C_STGhost inames s -> C_STGhost inames (add_frame_s s)
//
// TODO: there is a observability flag upcoming in the underlying steel framework
// the bind will then also allow for (statomic unobservable, statomic observable)
// and the symmetric one
//
let bind_comp_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| C_ST _, C_ST _ -> True
| _, _ -> False
let bind_comp_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_compatible c1 c2
let bind_comp_out (c1:comp_st) (c2:comp_st{bind_comp_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STGhost _ _ -> C_STGhost inames s
| C_ST _, C_ST _ -> C_ST s
let bind_comp_ghost_l_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STAtomic inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_l_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_l_compatible c1 c2
let bind_comp_ghost_l_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_l_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STAtomic _ _ -> C_STAtomic inames s
let bind_comp_ghost_r_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STAtomic inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_r_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_r_compatible c1 c2
let bind_comp_ghost_r_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_r_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STAtomic inames _, C_STGhost _ _ -> C_STAtomic inames s
let st_equiv_pre (c1 c2:comp_st)
: prop
= comp_u c1 == comp_u c2 /\
(match c1, c2 with
| C_ST _, C_ST _ -> True
| C_STAtomic inames1 _, C_STAtomic inames2 _ ->
inames1 == inames2
| C_STGhost inames1 _, C_STGhost inames2 _ ->
inames1 == inames2
| _, _ -> False)
let non_informative_witness_t (u:universe) (t:term)
: term
= tm_pureapp (tm_uinst (as_fv non_informative_witness_lid) [u])
None
t
let elim_exists_post (u:universe) (t:term) (p:term) (x:nvar)
: term
= let x_tm = term_of_nvar x in
let p = open_term' p (mk_reveal u t x_tm) 0 in
close_term p (snd x)
let comp_elim_exists (u:universe) (t:term) (p:term) (x:nvar)
: comp
= C_STGhost tm_emp_inames
{
u=u;
res=mk_erased u t;
pre=tm_exists_sl u (as_binder t) p;
post=elim_exists_post u t p x
}
let comp_intro_pure (p:term) =
C_STGhost tm_emp_inames
{
u=u_zero;
res=tm_unit;
pre=tm_emp;
post=tm_pure p
}
let named_binder (x:ppname) (t:term) = { binder_ppname = x; binder_ty = t}
let comp_intro_exists (u:universe) (b:binder) (p:term) (e:term)
: comp
= C_STGhost tm_emp_inames
{
u=u0;
res=tm_unit;
pre=open_term' p e 0;
post=tm_exists_sl u b p
}
let comp_intro_exists_erased (u:universe) (b:binder) (p:term) (e:term)
: comp
= C_STGhost tm_emp_inames
{
u=u0;
res=tm_unit;
pre=open_term' p (mk_reveal u b.binder_ty e) 0;
post=tm_exists_sl u b p
}
let comp_while_cond (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_bool;
pre=tm_exists_sl u0 (named_binder x tm_bool) inv;
post=inv
}
let comp_while_body (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_unit;
pre=open_term' inv tm_true 0;
post=tm_exists_sl u0 (named_binder x tm_bool) inv
}
let comp_while (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_unit;
pre=tm_exists_sl u0 (named_binder x tm_bool) inv;
post=open_term' inv tm_false 0
}
let mk_tuple2 (u1 u2:universe) (t1 t2:term) : term =
tm_pureapp (tm_pureapp (tm_uinst (as_fv tuple2_lid) [u1; u2])
None
t1)
None t2
let mk_fst (u1 u2:universe) (a1 a2 e:term) : term =
tm_pureapp (tm_pureapp (tm_pureapp (tm_uinst (as_fv fst_lid) [u1; u2]) (Some Implicit) a1)
(Some Implicit) a2)
None
e
let mk_snd (u1 u2:universe) (a1 a2 e:term) : term =
tm_pureapp (tm_pureapp (tm_pureapp (tm_uinst (as_fv snd_lid) [u1; u2]) (Some Implicit) a1)
(Some Implicit) a2)
None
e
let par_post (uL uR:universe) (aL aR postL postR:term) (x:var) : term =
let x_tm = term_of_no_name_var x in
let postL = open_term' postL (mk_fst uL uR aL aR x_tm) 0 in
let postR = open_term' postR (mk_snd uL uR aL aR x_tm) 0 in
let post = tm_star postL postR in
close_term post x
let comp_par (cL:comp{C_ST? cL}) (cR:comp{C_ST? cR}) (x:var) : comp =
let uL = comp_u cL in
let uR = comp_u cR in
let aL = comp_res cL in
let aR = comp_res cR in
let post = par_post uL uR aL aR (comp_post cL) (comp_post cR) x in
C_ST {
u = uL;
res = mk_tuple2 uL uR aL aR;
pre = tm_star (comp_pre cL) (comp_pre cR);
post
}
let comp_withlocal_body_pre (pre:vprop) (init_t:term) (r:term) (init:term) : vprop =
tm_star pre (mk_pts_to init_t r init)
let comp_withlocal_body_post (post:term) (init_t:term) (r:term) : term =
tm_star post (tm_exists_sl u0 (as_binder init_t) (mk_pts_to init_t r (null_bvar 0)))
let comp_withlocal_body (r:var) (init_t:term) (init:term) (c:comp{C_ST? c}) : comp =
let r = null_var r in
C_ST {
u = comp_u c;
res = comp_res c;
pre = comp_withlocal_body_pre (comp_pre c) init_t r init;
post = comp_withlocal_body_post (comp_post c) init_t r
}
let mk_array (a:term) : term = tm_pureapp (tm_fvar (as_fv array_lid)) None a
let mk_array_length (a:term) (arr:term) : term =
let t = tm_fvar (as_fv array_length_lid) in
let t = tm_pureapp t (Some Implicit) a in
tm_pureapp t None arr
let mk_array_pts_to (a:term) (arr:term) (v:term) : term =
let t = tm_fvar (as_fv array_pts_to_lid) in
let t = tm_pureapp t (Some Implicit) a in
let t = tm_pureapp t None arr in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let mk_array_is_full (a:term) (arr:term) : term =
let t = tm_fvar (as_fv array_is_full_lid) in
let t = tm_pureapp t (Some Implicit) a in
tm_pureapp t None arr
let mk_seq_create (u:universe) (a:term) (len:term) (v:term) : term =
let t = tm_uinst (as_fv seq_create_lid) [u] in
let t = tm_pureapp t (Some Implicit) a in
let t = tm_pureapp t None len in
tm_pureapp t None v
let mk_szv (n:term) : term =
let t = tm_fvar (as_fv szv_lid) in
tm_pureapp t None n
let comp_withlocal_array_body_pre (pre:vprop) (a:term) (arr:term) (init:term) (len:term) : vprop =
tm_star pre
(tm_star (mk_array_pts_to a arr (mk_seq_create u0 a (mk_szv len) init))
(tm_star (tm_pure (mk_array_is_full a arr))
(tm_pure (mk_eq2 u0 tm_nat (mk_array_length a arr) (mk_szv len)))))
let mk_seq (u:universe) (a:term) : term =
let t = tm_uinst (as_fv seq_lid) [u] in
tm_pureapp t None a
let comp_withlocal_array_body_post (post:term) (a:term) (arr:term) : term =
tm_star post (tm_exists_sl u0 (as_binder (mk_seq u0 a)) (mk_array_pts_to a arr (null_bvar 0)))
let comp_withlocal_array_body (arr:var) (a:term) (init:term) (len:term) (c:comp{C_ST? c}) : comp =
let arr = null_var arr in
C_ST {
u = comp_u c;
res = comp_res c;
pre = comp_withlocal_array_body_pre (comp_pre c) a arr init len;
post = comp_withlocal_array_body_post (comp_post c) a arr
} | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val comp_rewrite (p q: vprop) : comp | [] | Pulse.Typing.comp_rewrite | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Pulse.Syntax.Base.vprop -> q: Pulse.Syntax.Base.vprop -> Pulse.Syntax.Base.comp | {
"end_col": 3,
"end_line": 478,
"start_col": 2,
"start_line": 473
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tm_szt = tm_fvar (as_fv szt_lid) | let tm_szt = | false | null | false | tm_fvar (as_fv szt_lid) | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Pure.tm_fvar",
"Pulse.Syntax.Base.as_fv",
"Pulse.Reflection.Util.szt_lid"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid) | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tm_szt : Pulse.Syntax.Base.term | [] | Pulse.Typing.tm_szt | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Pulse.Syntax.Base.term | {
"end_col": 37,
"end_line": 22,
"start_col": 14,
"start_line": 22
} |
|
Prims.Tot | val mk_array_pts_to (a arr v: term) : term | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_array_pts_to (a:term) (arr:term) (v:term) : term =
let t = tm_fvar (as_fv array_pts_to_lid) in
let t = tm_pureapp t (Some Implicit) a in
let t = tm_pureapp t None arr in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v | val mk_array_pts_to (a arr v: term) : term
let mk_array_pts_to (a arr v: term) : term = | false | null | false | let t = tm_fvar (as_fv array_pts_to_lid) in
let t = tm_pureapp t (Some Implicit) a in
let t = tm_pureapp t None arr in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Pure.tm_pureapp",
"FStar.Pervasives.Native.None",
"Pulse.Syntax.Base.qualifier",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.Implicit",
"Pulse.Syntax.Pure.tm_fvar",
"Pulse.Syntax.Base.as_fv",
"Pulse.Reflection.Util.full_perm_lid",
"Pulse.Reflection.Util.array_pts_to_lid"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq)
let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1
let mk_ref (t:term) : term = tm_pureapp (tm_fvar (as_fv ref_lid)) None t
let mk_pts_to (ty:term) (r:term) (v:term) : term =
let t = tm_fvar (as_fv pts_to_lid) in
let t = tm_pureapp t (Some Implicit) ty in
let t = tm_pureapp t None r in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let comp_return (c:ctag) (use_eq:bool) (u:universe) (t:term) (e:term) (post:term) (x:var)
: comp =
let post_maybe_eq =
if use_eq
then let post = open_term' post (null_var x) 0 in
let post = tm_star post (tm_pure (mk_eq2 u t (null_var x) e)) in
close_term post x
else post in
match c with
| STT ->
C_ST { u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Atomic ->
C_STAtomic tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Ghost ->
C_STGhost tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
module L = FStar.List.Tot
let extend_env_l (f:R.env) (g:env_bindings) : R.env =
L.fold_right
(fun (x, b) g ->
let t = elab_term b in
RT.extend_env g x t)
g
f
let elab_env (e:env) : R.env = extend_env_l (fstar_env e) (bindings e)
(*
* If I call this fresh, I get:
* Pulse.Typing.fst(545,0-546,20): (Error 162) The qualifier list "[assume]" is not permissible for this element: definitions cannot be assumed or marked with equality qualifiers
* What!?!? Oh.. there's a fresh in Pulse.Typing.Env, which is *included*...
*)
let freshv (g:env) (x:var) : prop =
None? (lookup g x)
let rec all_fresh (g:env) (xs:list binding) : Tot prop (decreases xs) =
match xs with
| [] -> True
| x::xs -> freshv g (fst x) /\ all_fresh (push_binding g (fst x) ppname_default (snd x)) xs
let rec push_bindings (g:env) (bs:list binding{all_fresh g bs}) : Tot (g':env{env_extends g' g}) (decreases bs) =
match bs with
| [] -> g
| (x,t)::bs -> push_bindings (push_binding g x ppname_default t) bs
let elab_push_binding (g:env) (x:var { ~ (Set.mem x (dom g)) }) (t:typ)
: Lemma (elab_env (push_binding g x ppname_default t) ==
RT.extend_env (elab_env g) x (elab_term t)) = ()
[@@ erasable; no_auto_projectors]
noeq
type vprop_equiv : env -> term -> term -> Type =
| VE_Refl:
g:env ->
t:term ->
vprop_equiv g t t
| VE_Sym:
g:env ->
t1:term ->
t2:term ->
vprop_equiv g t1 t2 ->
vprop_equiv g t2 t1
| VE_Trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g t0 t1 ->
vprop_equiv g t1 t2 ->
vprop_equiv g t0 t2
| VE_Ctxt:
g:env ->
t0:term ->
t1:term ->
t0':term ->
t1':term ->
vprop_equiv g t0 t0' ->
vprop_equiv g t1 t1' ->
vprop_equiv g (tm_star t0 t1) (tm_star t0' t1')
| VE_Unit: (* *)
g:env ->
t:term ->
vprop_equiv g (tm_star tm_emp t) t
| VE_Comm:
g:env ->
t0:term ->
t1:term ->
vprop_equiv g (tm_star t0 t1) (tm_star t1 t0)
| VE_Assoc:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g (tm_star t0 (tm_star t1 t2)) (tm_star (tm_star t0 t1) t2)
| VE_Ext:
g:env ->
t0:term ->
t1:term ->
FTB.equiv_token (elab_env g) (elab_term t0) (elab_term t1) ->
vprop_equiv g t0 t1
// | VE_Ex:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (tm_exists_sl ty t0) (tm_exists_sl ty t1)
// | VE_Fa:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (Tm_ForallSL ty t0) (Tm_ForallSL ty t1)
let add_frame (s:comp_st) (frame:term)
: comp_st
= let add_frame_s (s:st_comp) : st_comp =
{ s with pre = tm_star s.pre frame;
post = tm_star s.post frame }
in
match s with
| C_ST s -> C_ST (add_frame_s s)
| C_STAtomic inames s -> C_STAtomic inames (add_frame_s s)
| C_STGhost inames s -> C_STGhost inames (add_frame_s s)
//
// TODO: there is a observability flag upcoming in the underlying steel framework
// the bind will then also allow for (statomic unobservable, statomic observable)
// and the symmetric one
//
let bind_comp_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| C_ST _, C_ST _ -> True
| _, _ -> False
let bind_comp_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_compatible c1 c2
let bind_comp_out (c1:comp_st) (c2:comp_st{bind_comp_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STGhost _ _ -> C_STGhost inames s
| C_ST _, C_ST _ -> C_ST s
let bind_comp_ghost_l_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STAtomic inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_l_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_l_compatible c1 c2
let bind_comp_ghost_l_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_l_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STAtomic _ _ -> C_STAtomic inames s
let bind_comp_ghost_r_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STAtomic inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_r_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_r_compatible c1 c2
let bind_comp_ghost_r_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_r_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STAtomic inames _, C_STGhost _ _ -> C_STAtomic inames s
let st_equiv_pre (c1 c2:comp_st)
: prop
= comp_u c1 == comp_u c2 /\
(match c1, c2 with
| C_ST _, C_ST _ -> True
| C_STAtomic inames1 _, C_STAtomic inames2 _ ->
inames1 == inames2
| C_STGhost inames1 _, C_STGhost inames2 _ ->
inames1 == inames2
| _, _ -> False)
let non_informative_witness_t (u:universe) (t:term)
: term
= tm_pureapp (tm_uinst (as_fv non_informative_witness_lid) [u])
None
t
let elim_exists_post (u:universe) (t:term) (p:term) (x:nvar)
: term
= let x_tm = term_of_nvar x in
let p = open_term' p (mk_reveal u t x_tm) 0 in
close_term p (snd x)
let comp_elim_exists (u:universe) (t:term) (p:term) (x:nvar)
: comp
= C_STGhost tm_emp_inames
{
u=u;
res=mk_erased u t;
pre=tm_exists_sl u (as_binder t) p;
post=elim_exists_post u t p x
}
let comp_intro_pure (p:term) =
C_STGhost tm_emp_inames
{
u=u_zero;
res=tm_unit;
pre=tm_emp;
post=tm_pure p
}
let named_binder (x:ppname) (t:term) = { binder_ppname = x; binder_ty = t}
let comp_intro_exists (u:universe) (b:binder) (p:term) (e:term)
: comp
= C_STGhost tm_emp_inames
{
u=u0;
res=tm_unit;
pre=open_term' p e 0;
post=tm_exists_sl u b p
}
let comp_intro_exists_erased (u:universe) (b:binder) (p:term) (e:term)
: comp
= C_STGhost tm_emp_inames
{
u=u0;
res=tm_unit;
pre=open_term' p (mk_reveal u b.binder_ty e) 0;
post=tm_exists_sl u b p
}
let comp_while_cond (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_bool;
pre=tm_exists_sl u0 (named_binder x tm_bool) inv;
post=inv
}
let comp_while_body (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_unit;
pre=open_term' inv tm_true 0;
post=tm_exists_sl u0 (named_binder x tm_bool) inv
}
let comp_while (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_unit;
pre=tm_exists_sl u0 (named_binder x tm_bool) inv;
post=open_term' inv tm_false 0
}
let mk_tuple2 (u1 u2:universe) (t1 t2:term) : term =
tm_pureapp (tm_pureapp (tm_uinst (as_fv tuple2_lid) [u1; u2])
None
t1)
None t2
let mk_fst (u1 u2:universe) (a1 a2 e:term) : term =
tm_pureapp (tm_pureapp (tm_pureapp (tm_uinst (as_fv fst_lid) [u1; u2]) (Some Implicit) a1)
(Some Implicit) a2)
None
e
let mk_snd (u1 u2:universe) (a1 a2 e:term) : term =
tm_pureapp (tm_pureapp (tm_pureapp (tm_uinst (as_fv snd_lid) [u1; u2]) (Some Implicit) a1)
(Some Implicit) a2)
None
e
let par_post (uL uR:universe) (aL aR postL postR:term) (x:var) : term =
let x_tm = term_of_no_name_var x in
let postL = open_term' postL (mk_fst uL uR aL aR x_tm) 0 in
let postR = open_term' postR (mk_snd uL uR aL aR x_tm) 0 in
let post = tm_star postL postR in
close_term post x
let comp_par (cL:comp{C_ST? cL}) (cR:comp{C_ST? cR}) (x:var) : comp =
let uL = comp_u cL in
let uR = comp_u cR in
let aL = comp_res cL in
let aR = comp_res cR in
let post = par_post uL uR aL aR (comp_post cL) (comp_post cR) x in
C_ST {
u = uL;
res = mk_tuple2 uL uR aL aR;
pre = tm_star (comp_pre cL) (comp_pre cR);
post
}
let comp_withlocal_body_pre (pre:vprop) (init_t:term) (r:term) (init:term) : vprop =
tm_star pre (mk_pts_to init_t r init)
let comp_withlocal_body_post (post:term) (init_t:term) (r:term) : term =
tm_star post (tm_exists_sl u0 (as_binder init_t) (mk_pts_to init_t r (null_bvar 0)))
let comp_withlocal_body (r:var) (init_t:term) (init:term) (c:comp{C_ST? c}) : comp =
let r = null_var r in
C_ST {
u = comp_u c;
res = comp_res c;
pre = comp_withlocal_body_pre (comp_pre c) init_t r init;
post = comp_withlocal_body_post (comp_post c) init_t r
}
let mk_array (a:term) : term = tm_pureapp (tm_fvar (as_fv array_lid)) None a
let mk_array_length (a:term) (arr:term) : term =
let t = tm_fvar (as_fv array_length_lid) in
let t = tm_pureapp t (Some Implicit) a in
tm_pureapp t None arr | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_array_pts_to (a arr v: term) : term | [] | Pulse.Typing.mk_array_pts_to | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | a: Pulse.Syntax.Base.term -> arr: Pulse.Syntax.Base.term -> v: Pulse.Syntax.Base.term
-> Pulse.Syntax.Base.term | {
"end_col": 21,
"end_line": 433,
"start_col": 57,
"start_line": 428
} |
Prims.Tot | val par_post (uL uR: universe) (aL aR postL postR: term) (x: var) : term | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let par_post (uL uR:universe) (aL aR postL postR:term) (x:var) : term =
let x_tm = term_of_no_name_var x in
let postL = open_term' postL (mk_fst uL uR aL aR x_tm) 0 in
let postR = open_term' postR (mk_snd uL uR aL aR x_tm) 0 in
let post = tm_star postL postR in
close_term post x | val par_post (uL uR: universe) (aL aR postL postR: term) (x: var) : term
let par_post (uL uR: universe) (aL aR postL postR: term) (x: var) : term = | false | null | false | let x_tm = term_of_no_name_var x in
let postL = open_term' postL (mk_fst uL uR aL aR x_tm) 0 in
let postR = open_term' postR (mk_snd uL uR aL aR x_tm) 0 in
let post = tm_star postL postR in
close_term post x | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.var",
"Pulse.Syntax.Naming.close_term",
"Pulse.Syntax.Base.tm_star",
"Pulse.Syntax.Naming.open_term'",
"Pulse.Typing.mk_snd",
"Pulse.Typing.mk_fst",
"Pulse.Syntax.Pure.term_of_no_name_var"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq)
let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1
let mk_ref (t:term) : term = tm_pureapp (tm_fvar (as_fv ref_lid)) None t
let mk_pts_to (ty:term) (r:term) (v:term) : term =
let t = tm_fvar (as_fv pts_to_lid) in
let t = tm_pureapp t (Some Implicit) ty in
let t = tm_pureapp t None r in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let comp_return (c:ctag) (use_eq:bool) (u:universe) (t:term) (e:term) (post:term) (x:var)
: comp =
let post_maybe_eq =
if use_eq
then let post = open_term' post (null_var x) 0 in
let post = tm_star post (tm_pure (mk_eq2 u t (null_var x) e)) in
close_term post x
else post in
match c with
| STT ->
C_ST { u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Atomic ->
C_STAtomic tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Ghost ->
C_STGhost tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
module L = FStar.List.Tot
let extend_env_l (f:R.env) (g:env_bindings) : R.env =
L.fold_right
(fun (x, b) g ->
let t = elab_term b in
RT.extend_env g x t)
g
f
let elab_env (e:env) : R.env = extend_env_l (fstar_env e) (bindings e)
(*
* If I call this fresh, I get:
* Pulse.Typing.fst(545,0-546,20): (Error 162) The qualifier list "[assume]" is not permissible for this element: definitions cannot be assumed or marked with equality qualifiers
* What!?!? Oh.. there's a fresh in Pulse.Typing.Env, which is *included*...
*)
let freshv (g:env) (x:var) : prop =
None? (lookup g x)
let rec all_fresh (g:env) (xs:list binding) : Tot prop (decreases xs) =
match xs with
| [] -> True
| x::xs -> freshv g (fst x) /\ all_fresh (push_binding g (fst x) ppname_default (snd x)) xs
let rec push_bindings (g:env) (bs:list binding{all_fresh g bs}) : Tot (g':env{env_extends g' g}) (decreases bs) =
match bs with
| [] -> g
| (x,t)::bs -> push_bindings (push_binding g x ppname_default t) bs
let elab_push_binding (g:env) (x:var { ~ (Set.mem x (dom g)) }) (t:typ)
: Lemma (elab_env (push_binding g x ppname_default t) ==
RT.extend_env (elab_env g) x (elab_term t)) = ()
[@@ erasable; no_auto_projectors]
noeq
type vprop_equiv : env -> term -> term -> Type =
| VE_Refl:
g:env ->
t:term ->
vprop_equiv g t t
| VE_Sym:
g:env ->
t1:term ->
t2:term ->
vprop_equiv g t1 t2 ->
vprop_equiv g t2 t1
| VE_Trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g t0 t1 ->
vprop_equiv g t1 t2 ->
vprop_equiv g t0 t2
| VE_Ctxt:
g:env ->
t0:term ->
t1:term ->
t0':term ->
t1':term ->
vprop_equiv g t0 t0' ->
vprop_equiv g t1 t1' ->
vprop_equiv g (tm_star t0 t1) (tm_star t0' t1')
| VE_Unit: (* *)
g:env ->
t:term ->
vprop_equiv g (tm_star tm_emp t) t
| VE_Comm:
g:env ->
t0:term ->
t1:term ->
vprop_equiv g (tm_star t0 t1) (tm_star t1 t0)
| VE_Assoc:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g (tm_star t0 (tm_star t1 t2)) (tm_star (tm_star t0 t1) t2)
| VE_Ext:
g:env ->
t0:term ->
t1:term ->
FTB.equiv_token (elab_env g) (elab_term t0) (elab_term t1) ->
vprop_equiv g t0 t1
// | VE_Ex:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (tm_exists_sl ty t0) (tm_exists_sl ty t1)
// | VE_Fa:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (Tm_ForallSL ty t0) (Tm_ForallSL ty t1)
let add_frame (s:comp_st) (frame:term)
: comp_st
= let add_frame_s (s:st_comp) : st_comp =
{ s with pre = tm_star s.pre frame;
post = tm_star s.post frame }
in
match s with
| C_ST s -> C_ST (add_frame_s s)
| C_STAtomic inames s -> C_STAtomic inames (add_frame_s s)
| C_STGhost inames s -> C_STGhost inames (add_frame_s s)
//
// TODO: there is a observability flag upcoming in the underlying steel framework
// the bind will then also allow for (statomic unobservable, statomic observable)
// and the symmetric one
//
let bind_comp_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| C_ST _, C_ST _ -> True
| _, _ -> False
let bind_comp_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_compatible c1 c2
let bind_comp_out (c1:comp_st) (c2:comp_st{bind_comp_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STGhost _ _ -> C_STGhost inames s
| C_ST _, C_ST _ -> C_ST s
let bind_comp_ghost_l_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STAtomic inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_l_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_l_compatible c1 c2
let bind_comp_ghost_l_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_l_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STAtomic _ _ -> C_STAtomic inames s
let bind_comp_ghost_r_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STAtomic inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_r_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_r_compatible c1 c2
let bind_comp_ghost_r_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_r_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STAtomic inames _, C_STGhost _ _ -> C_STAtomic inames s
let st_equiv_pre (c1 c2:comp_st)
: prop
= comp_u c1 == comp_u c2 /\
(match c1, c2 with
| C_ST _, C_ST _ -> True
| C_STAtomic inames1 _, C_STAtomic inames2 _ ->
inames1 == inames2
| C_STGhost inames1 _, C_STGhost inames2 _ ->
inames1 == inames2
| _, _ -> False)
let non_informative_witness_t (u:universe) (t:term)
: term
= tm_pureapp (tm_uinst (as_fv non_informative_witness_lid) [u])
None
t
let elim_exists_post (u:universe) (t:term) (p:term) (x:nvar)
: term
= let x_tm = term_of_nvar x in
let p = open_term' p (mk_reveal u t x_tm) 0 in
close_term p (snd x)
let comp_elim_exists (u:universe) (t:term) (p:term) (x:nvar)
: comp
= C_STGhost tm_emp_inames
{
u=u;
res=mk_erased u t;
pre=tm_exists_sl u (as_binder t) p;
post=elim_exists_post u t p x
}
let comp_intro_pure (p:term) =
C_STGhost tm_emp_inames
{
u=u_zero;
res=tm_unit;
pre=tm_emp;
post=tm_pure p
}
let named_binder (x:ppname) (t:term) = { binder_ppname = x; binder_ty = t}
let comp_intro_exists (u:universe) (b:binder) (p:term) (e:term)
: comp
= C_STGhost tm_emp_inames
{
u=u0;
res=tm_unit;
pre=open_term' p e 0;
post=tm_exists_sl u b p
}
let comp_intro_exists_erased (u:universe) (b:binder) (p:term) (e:term)
: comp
= C_STGhost tm_emp_inames
{
u=u0;
res=tm_unit;
pre=open_term' p (mk_reveal u b.binder_ty e) 0;
post=tm_exists_sl u b p
}
let comp_while_cond (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_bool;
pre=tm_exists_sl u0 (named_binder x tm_bool) inv;
post=inv
}
let comp_while_body (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_unit;
pre=open_term' inv tm_true 0;
post=tm_exists_sl u0 (named_binder x tm_bool) inv
}
let comp_while (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_unit;
pre=tm_exists_sl u0 (named_binder x tm_bool) inv;
post=open_term' inv tm_false 0
}
let mk_tuple2 (u1 u2:universe) (t1 t2:term) : term =
tm_pureapp (tm_pureapp (tm_uinst (as_fv tuple2_lid) [u1; u2])
None
t1)
None t2
let mk_fst (u1 u2:universe) (a1 a2 e:term) : term =
tm_pureapp (tm_pureapp (tm_pureapp (tm_uinst (as_fv fst_lid) [u1; u2]) (Some Implicit) a1)
(Some Implicit) a2)
None
e
let mk_snd (u1 u2:universe) (a1 a2 e:term) : term =
tm_pureapp (tm_pureapp (tm_pureapp (tm_uinst (as_fv snd_lid) [u1; u2]) (Some Implicit) a1)
(Some Implicit) a2)
None
e | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val par_post (uL uR: universe) (aL aR postL postR: term) (x: var) : term | [] | Pulse.Typing.par_post | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
uL: Pulse.Syntax.Base.universe ->
uR: Pulse.Syntax.Base.universe ->
aL: Pulse.Syntax.Base.term ->
aR: Pulse.Syntax.Base.term ->
postL: Pulse.Syntax.Base.term ->
postR: Pulse.Syntax.Base.term ->
x: Pulse.Syntax.Base.var
-> Pulse.Syntax.Base.term | {
"end_col": 19,
"end_line": 389,
"start_col": 71,
"start_line": 383
} |
Prims.Tot | val mk_seq_create (u: universe) (a len v: term) : term | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_seq_create (u:universe) (a:term) (len:term) (v:term) : term =
let t = tm_uinst (as_fv seq_create_lid) [u] in
let t = tm_pureapp t (Some Implicit) a in
let t = tm_pureapp t None len in
tm_pureapp t None v | val mk_seq_create (u: universe) (a len v: term) : term
let mk_seq_create (u: universe) (a len v: term) : term = | false | null | false | let t = tm_uinst (as_fv seq_create_lid) [u] in
let t = tm_pureapp t (Some Implicit) a in
let t = tm_pureapp t None len in
tm_pureapp t None v | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Pure.tm_pureapp",
"FStar.Pervasives.Native.None",
"Pulse.Syntax.Base.qualifier",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.Implicit",
"Pulse.Syntax.Pure.tm_uinst",
"Pulse.Syntax.Base.as_fv",
"Pulse.Reflection.Util.seq_create_lid",
"Prims.Cons",
"Prims.Nil"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq)
let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1
let mk_ref (t:term) : term = tm_pureapp (tm_fvar (as_fv ref_lid)) None t
let mk_pts_to (ty:term) (r:term) (v:term) : term =
let t = tm_fvar (as_fv pts_to_lid) in
let t = tm_pureapp t (Some Implicit) ty in
let t = tm_pureapp t None r in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let comp_return (c:ctag) (use_eq:bool) (u:universe) (t:term) (e:term) (post:term) (x:var)
: comp =
let post_maybe_eq =
if use_eq
then let post = open_term' post (null_var x) 0 in
let post = tm_star post (tm_pure (mk_eq2 u t (null_var x) e)) in
close_term post x
else post in
match c with
| STT ->
C_ST { u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Atomic ->
C_STAtomic tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Ghost ->
C_STGhost tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
module L = FStar.List.Tot
let extend_env_l (f:R.env) (g:env_bindings) : R.env =
L.fold_right
(fun (x, b) g ->
let t = elab_term b in
RT.extend_env g x t)
g
f
let elab_env (e:env) : R.env = extend_env_l (fstar_env e) (bindings e)
(*
* If I call this fresh, I get:
* Pulse.Typing.fst(545,0-546,20): (Error 162) The qualifier list "[assume]" is not permissible for this element: definitions cannot be assumed or marked with equality qualifiers
* What!?!? Oh.. there's a fresh in Pulse.Typing.Env, which is *included*...
*)
let freshv (g:env) (x:var) : prop =
None? (lookup g x)
let rec all_fresh (g:env) (xs:list binding) : Tot prop (decreases xs) =
match xs with
| [] -> True
| x::xs -> freshv g (fst x) /\ all_fresh (push_binding g (fst x) ppname_default (snd x)) xs
let rec push_bindings (g:env) (bs:list binding{all_fresh g bs}) : Tot (g':env{env_extends g' g}) (decreases bs) =
match bs with
| [] -> g
| (x,t)::bs -> push_bindings (push_binding g x ppname_default t) bs
let elab_push_binding (g:env) (x:var { ~ (Set.mem x (dom g)) }) (t:typ)
: Lemma (elab_env (push_binding g x ppname_default t) ==
RT.extend_env (elab_env g) x (elab_term t)) = ()
[@@ erasable; no_auto_projectors]
noeq
type vprop_equiv : env -> term -> term -> Type =
| VE_Refl:
g:env ->
t:term ->
vprop_equiv g t t
| VE_Sym:
g:env ->
t1:term ->
t2:term ->
vprop_equiv g t1 t2 ->
vprop_equiv g t2 t1
| VE_Trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g t0 t1 ->
vprop_equiv g t1 t2 ->
vprop_equiv g t0 t2
| VE_Ctxt:
g:env ->
t0:term ->
t1:term ->
t0':term ->
t1':term ->
vprop_equiv g t0 t0' ->
vprop_equiv g t1 t1' ->
vprop_equiv g (tm_star t0 t1) (tm_star t0' t1')
| VE_Unit: (* *)
g:env ->
t:term ->
vprop_equiv g (tm_star tm_emp t) t
| VE_Comm:
g:env ->
t0:term ->
t1:term ->
vprop_equiv g (tm_star t0 t1) (tm_star t1 t0)
| VE_Assoc:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g (tm_star t0 (tm_star t1 t2)) (tm_star (tm_star t0 t1) t2)
| VE_Ext:
g:env ->
t0:term ->
t1:term ->
FTB.equiv_token (elab_env g) (elab_term t0) (elab_term t1) ->
vprop_equiv g t0 t1
// | VE_Ex:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (tm_exists_sl ty t0) (tm_exists_sl ty t1)
// | VE_Fa:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (Tm_ForallSL ty t0) (Tm_ForallSL ty t1)
let add_frame (s:comp_st) (frame:term)
: comp_st
= let add_frame_s (s:st_comp) : st_comp =
{ s with pre = tm_star s.pre frame;
post = tm_star s.post frame }
in
match s with
| C_ST s -> C_ST (add_frame_s s)
| C_STAtomic inames s -> C_STAtomic inames (add_frame_s s)
| C_STGhost inames s -> C_STGhost inames (add_frame_s s)
//
// TODO: there is a observability flag upcoming in the underlying steel framework
// the bind will then also allow for (statomic unobservable, statomic observable)
// and the symmetric one
//
let bind_comp_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| C_ST _, C_ST _ -> True
| _, _ -> False
let bind_comp_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_compatible c1 c2
let bind_comp_out (c1:comp_st) (c2:comp_st{bind_comp_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STGhost _ _ -> C_STGhost inames s
| C_ST _, C_ST _ -> C_ST s
let bind_comp_ghost_l_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STAtomic inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_l_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_l_compatible c1 c2
let bind_comp_ghost_l_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_l_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STAtomic _ _ -> C_STAtomic inames s
let bind_comp_ghost_r_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STAtomic inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_r_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_r_compatible c1 c2
let bind_comp_ghost_r_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_r_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STAtomic inames _, C_STGhost _ _ -> C_STAtomic inames s
let st_equiv_pre (c1 c2:comp_st)
: prop
= comp_u c1 == comp_u c2 /\
(match c1, c2 with
| C_ST _, C_ST _ -> True
| C_STAtomic inames1 _, C_STAtomic inames2 _ ->
inames1 == inames2
| C_STGhost inames1 _, C_STGhost inames2 _ ->
inames1 == inames2
| _, _ -> False)
let non_informative_witness_t (u:universe) (t:term)
: term
= tm_pureapp (tm_uinst (as_fv non_informative_witness_lid) [u])
None
t
let elim_exists_post (u:universe) (t:term) (p:term) (x:nvar)
: term
= let x_tm = term_of_nvar x in
let p = open_term' p (mk_reveal u t x_tm) 0 in
close_term p (snd x)
let comp_elim_exists (u:universe) (t:term) (p:term) (x:nvar)
: comp
= C_STGhost tm_emp_inames
{
u=u;
res=mk_erased u t;
pre=tm_exists_sl u (as_binder t) p;
post=elim_exists_post u t p x
}
let comp_intro_pure (p:term) =
C_STGhost tm_emp_inames
{
u=u_zero;
res=tm_unit;
pre=tm_emp;
post=tm_pure p
}
let named_binder (x:ppname) (t:term) = { binder_ppname = x; binder_ty = t}
let comp_intro_exists (u:universe) (b:binder) (p:term) (e:term)
: comp
= C_STGhost tm_emp_inames
{
u=u0;
res=tm_unit;
pre=open_term' p e 0;
post=tm_exists_sl u b p
}
let comp_intro_exists_erased (u:universe) (b:binder) (p:term) (e:term)
: comp
= C_STGhost tm_emp_inames
{
u=u0;
res=tm_unit;
pre=open_term' p (mk_reveal u b.binder_ty e) 0;
post=tm_exists_sl u b p
}
let comp_while_cond (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_bool;
pre=tm_exists_sl u0 (named_binder x tm_bool) inv;
post=inv
}
let comp_while_body (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_unit;
pre=open_term' inv tm_true 0;
post=tm_exists_sl u0 (named_binder x tm_bool) inv
}
let comp_while (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_unit;
pre=tm_exists_sl u0 (named_binder x tm_bool) inv;
post=open_term' inv tm_false 0
}
let mk_tuple2 (u1 u2:universe) (t1 t2:term) : term =
tm_pureapp (tm_pureapp (tm_uinst (as_fv tuple2_lid) [u1; u2])
None
t1)
None t2
let mk_fst (u1 u2:universe) (a1 a2 e:term) : term =
tm_pureapp (tm_pureapp (tm_pureapp (tm_uinst (as_fv fst_lid) [u1; u2]) (Some Implicit) a1)
(Some Implicit) a2)
None
e
let mk_snd (u1 u2:universe) (a1 a2 e:term) : term =
tm_pureapp (tm_pureapp (tm_pureapp (tm_uinst (as_fv snd_lid) [u1; u2]) (Some Implicit) a1)
(Some Implicit) a2)
None
e
let par_post (uL uR:universe) (aL aR postL postR:term) (x:var) : term =
let x_tm = term_of_no_name_var x in
let postL = open_term' postL (mk_fst uL uR aL aR x_tm) 0 in
let postR = open_term' postR (mk_snd uL uR aL aR x_tm) 0 in
let post = tm_star postL postR in
close_term post x
let comp_par (cL:comp{C_ST? cL}) (cR:comp{C_ST? cR}) (x:var) : comp =
let uL = comp_u cL in
let uR = comp_u cR in
let aL = comp_res cL in
let aR = comp_res cR in
let post = par_post uL uR aL aR (comp_post cL) (comp_post cR) x in
C_ST {
u = uL;
res = mk_tuple2 uL uR aL aR;
pre = tm_star (comp_pre cL) (comp_pre cR);
post
}
let comp_withlocal_body_pre (pre:vprop) (init_t:term) (r:term) (init:term) : vprop =
tm_star pre (mk_pts_to init_t r init)
let comp_withlocal_body_post (post:term) (init_t:term) (r:term) : term =
tm_star post (tm_exists_sl u0 (as_binder init_t) (mk_pts_to init_t r (null_bvar 0)))
let comp_withlocal_body (r:var) (init_t:term) (init:term) (c:comp{C_ST? c}) : comp =
let r = null_var r in
C_ST {
u = comp_u c;
res = comp_res c;
pre = comp_withlocal_body_pre (comp_pre c) init_t r init;
post = comp_withlocal_body_post (comp_post c) init_t r
}
let mk_array (a:term) : term = tm_pureapp (tm_fvar (as_fv array_lid)) None a
let mk_array_length (a:term) (arr:term) : term =
let t = tm_fvar (as_fv array_length_lid) in
let t = tm_pureapp t (Some Implicit) a in
tm_pureapp t None arr
let mk_array_pts_to (a:term) (arr:term) (v:term) : term =
let t = tm_fvar (as_fv array_pts_to_lid) in
let t = tm_pureapp t (Some Implicit) a in
let t = tm_pureapp t None arr in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let mk_array_is_full (a:term) (arr:term) : term =
let t = tm_fvar (as_fv array_is_full_lid) in
let t = tm_pureapp t (Some Implicit) a in
tm_pureapp t None arr | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_seq_create (u: universe) (a len v: term) : term | [] | Pulse.Typing.mk_seq_create | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
u175: Pulse.Syntax.Base.universe ->
a: Pulse.Syntax.Base.term ->
len: Pulse.Syntax.Base.term ->
v: Pulse.Syntax.Base.term
-> Pulse.Syntax.Base.term | {
"end_col": 21,
"end_line": 444,
"start_col": 68,
"start_line": 440
} |
Prims.Tot | val elim_exists_post (u: universe) (t p: term) (x: nvar) : term | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let elim_exists_post (u:universe) (t:term) (p:term) (x:nvar)
: term
= let x_tm = term_of_nvar x in
let p = open_term' p (mk_reveal u t x_tm) 0 in
close_term p (snd x) | val elim_exists_post (u: universe) (t p: term) (x: nvar) : term
let elim_exists_post (u: universe) (t p: term) (x: nvar) : term = | false | null | false | let x_tm = term_of_nvar x in
let p = open_term' p (mk_reveal u t x_tm) 0 in
close_term p (snd x) | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.nvar",
"Pulse.Syntax.Naming.close_term",
"FStar.Pervasives.Native.snd",
"Pulse.Syntax.Base.ppname",
"Pulse.Syntax.Base.var",
"Pulse.Syntax.Naming.open_term'",
"Pulse.Typing.mk_reveal",
"Pulse.Syntax.Pure.term_of_nvar"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq)
let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1
let mk_ref (t:term) : term = tm_pureapp (tm_fvar (as_fv ref_lid)) None t
let mk_pts_to (ty:term) (r:term) (v:term) : term =
let t = tm_fvar (as_fv pts_to_lid) in
let t = tm_pureapp t (Some Implicit) ty in
let t = tm_pureapp t None r in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let comp_return (c:ctag) (use_eq:bool) (u:universe) (t:term) (e:term) (post:term) (x:var)
: comp =
let post_maybe_eq =
if use_eq
then let post = open_term' post (null_var x) 0 in
let post = tm_star post (tm_pure (mk_eq2 u t (null_var x) e)) in
close_term post x
else post in
match c with
| STT ->
C_ST { u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Atomic ->
C_STAtomic tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Ghost ->
C_STGhost tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
module L = FStar.List.Tot
let extend_env_l (f:R.env) (g:env_bindings) : R.env =
L.fold_right
(fun (x, b) g ->
let t = elab_term b in
RT.extend_env g x t)
g
f
let elab_env (e:env) : R.env = extend_env_l (fstar_env e) (bindings e)
(*
* If I call this fresh, I get:
* Pulse.Typing.fst(545,0-546,20): (Error 162) The qualifier list "[assume]" is not permissible for this element: definitions cannot be assumed or marked with equality qualifiers
* What!?!? Oh.. there's a fresh in Pulse.Typing.Env, which is *included*...
*)
let freshv (g:env) (x:var) : prop =
None? (lookup g x)
let rec all_fresh (g:env) (xs:list binding) : Tot prop (decreases xs) =
match xs with
| [] -> True
| x::xs -> freshv g (fst x) /\ all_fresh (push_binding g (fst x) ppname_default (snd x)) xs
let rec push_bindings (g:env) (bs:list binding{all_fresh g bs}) : Tot (g':env{env_extends g' g}) (decreases bs) =
match bs with
| [] -> g
| (x,t)::bs -> push_bindings (push_binding g x ppname_default t) bs
let elab_push_binding (g:env) (x:var { ~ (Set.mem x (dom g)) }) (t:typ)
: Lemma (elab_env (push_binding g x ppname_default t) ==
RT.extend_env (elab_env g) x (elab_term t)) = ()
[@@ erasable; no_auto_projectors]
noeq
type vprop_equiv : env -> term -> term -> Type =
| VE_Refl:
g:env ->
t:term ->
vprop_equiv g t t
| VE_Sym:
g:env ->
t1:term ->
t2:term ->
vprop_equiv g t1 t2 ->
vprop_equiv g t2 t1
| VE_Trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g t0 t1 ->
vprop_equiv g t1 t2 ->
vprop_equiv g t0 t2
| VE_Ctxt:
g:env ->
t0:term ->
t1:term ->
t0':term ->
t1':term ->
vprop_equiv g t0 t0' ->
vprop_equiv g t1 t1' ->
vprop_equiv g (tm_star t0 t1) (tm_star t0' t1')
| VE_Unit: (* *)
g:env ->
t:term ->
vprop_equiv g (tm_star tm_emp t) t
| VE_Comm:
g:env ->
t0:term ->
t1:term ->
vprop_equiv g (tm_star t0 t1) (tm_star t1 t0)
| VE_Assoc:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g (tm_star t0 (tm_star t1 t2)) (tm_star (tm_star t0 t1) t2)
| VE_Ext:
g:env ->
t0:term ->
t1:term ->
FTB.equiv_token (elab_env g) (elab_term t0) (elab_term t1) ->
vprop_equiv g t0 t1
// | VE_Ex:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (tm_exists_sl ty t0) (tm_exists_sl ty t1)
// | VE_Fa:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (Tm_ForallSL ty t0) (Tm_ForallSL ty t1)
let add_frame (s:comp_st) (frame:term)
: comp_st
= let add_frame_s (s:st_comp) : st_comp =
{ s with pre = tm_star s.pre frame;
post = tm_star s.post frame }
in
match s with
| C_ST s -> C_ST (add_frame_s s)
| C_STAtomic inames s -> C_STAtomic inames (add_frame_s s)
| C_STGhost inames s -> C_STGhost inames (add_frame_s s)
//
// TODO: there is a observability flag upcoming in the underlying steel framework
// the bind will then also allow for (statomic unobservable, statomic observable)
// and the symmetric one
//
let bind_comp_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| C_ST _, C_ST _ -> True
| _, _ -> False
let bind_comp_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_compatible c1 c2
let bind_comp_out (c1:comp_st) (c2:comp_st{bind_comp_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STGhost _ _ -> C_STGhost inames s
| C_ST _, C_ST _ -> C_ST s
let bind_comp_ghost_l_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STAtomic inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_l_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_l_compatible c1 c2
let bind_comp_ghost_l_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_l_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STAtomic _ _ -> C_STAtomic inames s
let bind_comp_ghost_r_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STAtomic inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_r_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_r_compatible c1 c2
let bind_comp_ghost_r_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_r_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STAtomic inames _, C_STGhost _ _ -> C_STAtomic inames s
let st_equiv_pre (c1 c2:comp_st)
: prop
= comp_u c1 == comp_u c2 /\
(match c1, c2 with
| C_ST _, C_ST _ -> True
| C_STAtomic inames1 _, C_STAtomic inames2 _ ->
inames1 == inames2
| C_STGhost inames1 _, C_STGhost inames2 _ ->
inames1 == inames2
| _, _ -> False)
let non_informative_witness_t (u:universe) (t:term)
: term
= tm_pureapp (tm_uinst (as_fv non_informative_witness_lid) [u])
None
t
let elim_exists_post (u:universe) (t:term) (p:term) (x:nvar) | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val elim_exists_post (u: universe) (t p: term) (x: nvar) : term | [] | Pulse.Typing.elim_exists_post | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
u107: Pulse.Syntax.Base.universe ->
t: Pulse.Syntax.Base.term ->
p: Pulse.Syntax.Base.term ->
x: Pulse.Syntax.Base.nvar
-> Pulse.Syntax.Base.term | {
"end_col": 24,
"end_line": 294,
"start_col": 3,
"start_line": 292
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "FTB"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let typing (g:env) (e:term) (eff:T.tot_or_ghost) (t:term) =
my_erased (RT.typing (elab_env g) (elab_term e) (eff, elab_term t)) | let typing (g: env) (e: term) (eff: T.tot_or_ghost) (t: term) = | false | null | false | my_erased (RT.typing (elab_env g) (elab_term e) (eff, elab_term t)) | {
"checked_file": "Pulse.Typing.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.fst"
} | [
"total"
] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.term",
"FStar.Stubs.TypeChecker.Core.tot_or_ghost",
"Pulse.Typing.my_erased",
"FStar.Reflection.Typing.typing",
"Pulse.Typing.elab_env",
"Pulse.Elaborate.Pure.elab_term",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.Types.typ"
] | [] | module Pulse.Typing
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
open Pulse.Reflection.Util
open FStar.List.Tot
open Pulse.Syntax
module L = FStar.List.Tot
module FTB = FStar.Tactics.V2
module RU = Pulse.RuntimeUtils
module T= FStar.Tactics.V2
include Pulse.Typing.Env
let debug_log (level:string) (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) level
then T.print (Printf.sprintf "Debug@%s:{ %s }\n" level (f ()))
let tm_unit = tm_fvar (as_fv unit_lid)
let tm_bool = tm_fvar (as_fv bool_lid)
let tm_int = tm_fvar (as_fv int_lid)
let tm_nat = tm_fvar (as_fv nat_lid)
let tm_szt = tm_fvar (as_fv szt_lid)
let tm_true = tm_constant R.C_True
let tm_false = tm_constant R.C_False
let tm_prop = with_range (Tm_FStar FStar.Reflection.Typing.tm_prop) Range.range_0
let mk_erased (u:universe) (t:term) : term =
let hd = tm_uinst (as_fv erased_lid) [u] in
tm_pureapp hd None t
let mk_reveal (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv reveal_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_hide (u:universe) (t:term) (e:term) : term =
let hd = tm_uinst (as_fv hide_lid) [u] in
let hd = tm_pureapp hd (Some Implicit) t in
tm_pureapp hd None e
let mk_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= tm_pureapp
(tm_pureapp (tm_pureapp (tm_uinst (as_fv R.eq2_qn) [u]) (Some Implicit) t)
None e0) None e1
let mk_sq_eq2 (u:universe)
(t:term)
(e0 e1:term)
: term
= let eq = mk_eq2 u t e0 e1 in
(tm_pureapp (tm_uinst (as_fv R.squash_qn) [u]) None eq)
let mk_vprop_eq (e0 e1:term) : term =
mk_eq2 u2 tm_vprop e0 e1
let mk_ref (t:term) : term = tm_pureapp (tm_fvar (as_fv ref_lid)) None t
let mk_pts_to (ty:term) (r:term) (v:term) : term =
let t = tm_fvar (as_fv pts_to_lid) in
let t = tm_pureapp t (Some Implicit) ty in
let t = tm_pureapp t None r in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let comp_return (c:ctag) (use_eq:bool) (u:universe) (t:term) (e:term) (post:term) (x:var)
: comp =
let post_maybe_eq =
if use_eq
then let post = open_term' post (null_var x) 0 in
let post = tm_star post (tm_pure (mk_eq2 u t (null_var x) e)) in
close_term post x
else post in
match c with
| STT ->
C_ST { u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Atomic ->
C_STAtomic tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
| STT_Ghost ->
C_STGhost tm_emp_inames
{ u; res = t; pre = open_term' post e 0; post = post_maybe_eq }
module L = FStar.List.Tot
let extend_env_l (f:R.env) (g:env_bindings) : R.env =
L.fold_right
(fun (x, b) g ->
let t = elab_term b in
RT.extend_env g x t)
g
f
let elab_env (e:env) : R.env = extend_env_l (fstar_env e) (bindings e)
(*
* If I call this fresh, I get:
* Pulse.Typing.fst(545,0-546,20): (Error 162) The qualifier list "[assume]" is not permissible for this element: definitions cannot be assumed or marked with equality qualifiers
* What!?!? Oh.. there's a fresh in Pulse.Typing.Env, which is *included*...
*)
let freshv (g:env) (x:var) : prop =
None? (lookup g x)
let rec all_fresh (g:env) (xs:list binding) : Tot prop (decreases xs) =
match xs with
| [] -> True
| x::xs -> freshv g (fst x) /\ all_fresh (push_binding g (fst x) ppname_default (snd x)) xs
let rec push_bindings (g:env) (bs:list binding{all_fresh g bs}) : Tot (g':env{env_extends g' g}) (decreases bs) =
match bs with
| [] -> g
| (x,t)::bs -> push_bindings (push_binding g x ppname_default t) bs
let elab_push_binding (g:env) (x:var { ~ (Set.mem x (dom g)) }) (t:typ)
: Lemma (elab_env (push_binding g x ppname_default t) ==
RT.extend_env (elab_env g) x (elab_term t)) = ()
[@@ erasable; no_auto_projectors]
noeq
type vprop_equiv : env -> term -> term -> Type =
| VE_Refl:
g:env ->
t:term ->
vprop_equiv g t t
| VE_Sym:
g:env ->
t1:term ->
t2:term ->
vprop_equiv g t1 t2 ->
vprop_equiv g t2 t1
| VE_Trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g t0 t1 ->
vprop_equiv g t1 t2 ->
vprop_equiv g t0 t2
| VE_Ctxt:
g:env ->
t0:term ->
t1:term ->
t0':term ->
t1':term ->
vprop_equiv g t0 t0' ->
vprop_equiv g t1 t1' ->
vprop_equiv g (tm_star t0 t1) (tm_star t0' t1')
| VE_Unit: (* *)
g:env ->
t:term ->
vprop_equiv g (tm_star tm_emp t) t
| VE_Comm:
g:env ->
t0:term ->
t1:term ->
vprop_equiv g (tm_star t0 t1) (tm_star t1 t0)
| VE_Assoc:
g:env ->
t0:term ->
t1:term ->
t2:term ->
vprop_equiv g (tm_star t0 (tm_star t1 t2)) (tm_star (tm_star t0 t1) t2)
| VE_Ext:
g:env ->
t0:term ->
t1:term ->
FTB.equiv_token (elab_env g) (elab_term t0) (elab_term t1) ->
vprop_equiv g t0 t1
// | VE_Ex:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (tm_exists_sl ty t0) (tm_exists_sl ty t1)
// | VE_Fa:
// g:env ->
// x:var { None? (lookup_ty g x) } ->
// ty:term ->
// t0:term ->
// t1:term ->
// vprop_equiv f ((x, Inl ty)::g) (open_term t0 x) (open_term t1 x) ->
// vprop_equiv f g (Tm_ForallSL ty t0) (Tm_ForallSL ty t1)
let add_frame (s:comp_st) (frame:term)
: comp_st
= let add_frame_s (s:st_comp) : st_comp =
{ s with pre = tm_star s.pre frame;
post = tm_star s.post frame }
in
match s with
| C_ST s -> C_ST (add_frame_s s)
| C_STAtomic inames s -> C_STAtomic inames (add_frame_s s)
| C_STGhost inames s -> C_STGhost inames (add_frame_s s)
//
// TODO: there is a observability flag upcoming in the underlying steel framework
// the bind will then also allow for (statomic unobservable, statomic observable)
// and the symmetric one
//
let bind_comp_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| C_ST _, C_ST _ -> True
| _, _ -> False
let bind_comp_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_compatible c1 c2
let bind_comp_out (c1:comp_st) (c2:comp_st{bind_comp_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STGhost _ _ -> C_STGhost inames s
| C_ST _, C_ST _ -> C_ST s
let bind_comp_ghost_l_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STGhost inames1 _, C_STAtomic inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_l_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_l_compatible c1 c2
let bind_comp_ghost_l_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_l_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STGhost inames _, C_STAtomic _ _ -> C_STAtomic inames s
let bind_comp_ghost_r_compatible (c1 c2:comp_st)
: prop
= match c1, c2 with
| C_STAtomic inames1 _, C_STGhost inames2 _ -> inames1 == inames2
| _, _ -> False
let bind_comp_ghost_r_pre (x:var) (c1 c2:comp_st)
: prop
= open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))) /\ //x doesn't escape in the result type
bind_comp_ghost_r_compatible c1 c2
let bind_comp_ghost_r_out (c1:comp_st) (c2:comp_st{bind_comp_ghost_r_compatible c1 c2})
: comp_st
= let s : st_comp = {u=comp_u c2; res=comp_res c2; pre=comp_pre c1; post=comp_post c2} in
match c1, c2 with
| C_STAtomic inames _, C_STGhost _ _ -> C_STAtomic inames s
let st_equiv_pre (c1 c2:comp_st)
: prop
= comp_u c1 == comp_u c2 /\
(match c1, c2 with
| C_ST _, C_ST _ -> True
| C_STAtomic inames1 _, C_STAtomic inames2 _ ->
inames1 == inames2
| C_STGhost inames1 _, C_STGhost inames2 _ ->
inames1 == inames2
| _, _ -> False)
let non_informative_witness_t (u:universe) (t:term)
: term
= tm_pureapp (tm_uinst (as_fv non_informative_witness_lid) [u])
None
t
let elim_exists_post (u:universe) (t:term) (p:term) (x:nvar)
: term
= let x_tm = term_of_nvar x in
let p = open_term' p (mk_reveal u t x_tm) 0 in
close_term p (snd x)
let comp_elim_exists (u:universe) (t:term) (p:term) (x:nvar)
: comp
= C_STGhost tm_emp_inames
{
u=u;
res=mk_erased u t;
pre=tm_exists_sl u (as_binder t) p;
post=elim_exists_post u t p x
}
let comp_intro_pure (p:term) =
C_STGhost tm_emp_inames
{
u=u_zero;
res=tm_unit;
pre=tm_emp;
post=tm_pure p
}
let named_binder (x:ppname) (t:term) = { binder_ppname = x; binder_ty = t}
let comp_intro_exists (u:universe) (b:binder) (p:term) (e:term)
: comp
= C_STGhost tm_emp_inames
{
u=u0;
res=tm_unit;
pre=open_term' p e 0;
post=tm_exists_sl u b p
}
let comp_intro_exists_erased (u:universe) (b:binder) (p:term) (e:term)
: comp
= C_STGhost tm_emp_inames
{
u=u0;
res=tm_unit;
pre=open_term' p (mk_reveal u b.binder_ty e) 0;
post=tm_exists_sl u b p
}
let comp_while_cond (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_bool;
pre=tm_exists_sl u0 (named_binder x tm_bool) inv;
post=inv
}
let comp_while_body (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_unit;
pre=open_term' inv tm_true 0;
post=tm_exists_sl u0 (named_binder x tm_bool) inv
}
let comp_while (x:ppname) (inv:term)
: comp
= C_ST {
u=u0;
res=tm_unit;
pre=tm_exists_sl u0 (named_binder x tm_bool) inv;
post=open_term' inv tm_false 0
}
let mk_tuple2 (u1 u2:universe) (t1 t2:term) : term =
tm_pureapp (tm_pureapp (tm_uinst (as_fv tuple2_lid) [u1; u2])
None
t1)
None t2
let mk_fst (u1 u2:universe) (a1 a2 e:term) : term =
tm_pureapp (tm_pureapp (tm_pureapp (tm_uinst (as_fv fst_lid) [u1; u2]) (Some Implicit) a1)
(Some Implicit) a2)
None
e
let mk_snd (u1 u2:universe) (a1 a2 e:term) : term =
tm_pureapp (tm_pureapp (tm_pureapp (tm_uinst (as_fv snd_lid) [u1; u2]) (Some Implicit) a1)
(Some Implicit) a2)
None
e
let par_post (uL uR:universe) (aL aR postL postR:term) (x:var) : term =
let x_tm = term_of_no_name_var x in
let postL = open_term' postL (mk_fst uL uR aL aR x_tm) 0 in
let postR = open_term' postR (mk_snd uL uR aL aR x_tm) 0 in
let post = tm_star postL postR in
close_term post x
let comp_par (cL:comp{C_ST? cL}) (cR:comp{C_ST? cR}) (x:var) : comp =
let uL = comp_u cL in
let uR = comp_u cR in
let aL = comp_res cL in
let aR = comp_res cR in
let post = par_post uL uR aL aR (comp_post cL) (comp_post cR) x in
C_ST {
u = uL;
res = mk_tuple2 uL uR aL aR;
pre = tm_star (comp_pre cL) (comp_pre cR);
post
}
let comp_withlocal_body_pre (pre:vprop) (init_t:term) (r:term) (init:term) : vprop =
tm_star pre (mk_pts_to init_t r init)
let comp_withlocal_body_post (post:term) (init_t:term) (r:term) : term =
tm_star post (tm_exists_sl u0 (as_binder init_t) (mk_pts_to init_t r (null_bvar 0)))
let comp_withlocal_body (r:var) (init_t:term) (init:term) (c:comp{C_ST? c}) : comp =
let r = null_var r in
C_ST {
u = comp_u c;
res = comp_res c;
pre = comp_withlocal_body_pre (comp_pre c) init_t r init;
post = comp_withlocal_body_post (comp_post c) init_t r
}
let mk_array (a:term) : term = tm_pureapp (tm_fvar (as_fv array_lid)) None a
let mk_array_length (a:term) (arr:term) : term =
let t = tm_fvar (as_fv array_length_lid) in
let t = tm_pureapp t (Some Implicit) a in
tm_pureapp t None arr
let mk_array_pts_to (a:term) (arr:term) (v:term) : term =
let t = tm_fvar (as_fv array_pts_to_lid) in
let t = tm_pureapp t (Some Implicit) a in
let t = tm_pureapp t None arr in
let t = tm_pureapp t (Some Implicit) (tm_fvar (as_fv full_perm_lid)) in
tm_pureapp t None v
let mk_array_is_full (a:term) (arr:term) : term =
let t = tm_fvar (as_fv array_is_full_lid) in
let t = tm_pureapp t (Some Implicit) a in
tm_pureapp t None arr
let mk_seq_create (u:universe) (a:term) (len:term) (v:term) : term =
let t = tm_uinst (as_fv seq_create_lid) [u] in
let t = tm_pureapp t (Some Implicit) a in
let t = tm_pureapp t None len in
tm_pureapp t None v
let mk_szv (n:term) : term =
let t = tm_fvar (as_fv szv_lid) in
tm_pureapp t None n
let comp_withlocal_array_body_pre (pre:vprop) (a:term) (arr:term) (init:term) (len:term) : vprop =
tm_star pre
(tm_star (mk_array_pts_to a arr (mk_seq_create u0 a (mk_szv len) init))
(tm_star (tm_pure (mk_array_is_full a arr))
(tm_pure (mk_eq2 u0 tm_nat (mk_array_length a arr) (mk_szv len)))))
let mk_seq (u:universe) (a:term) : term =
let t = tm_uinst (as_fv seq_lid) [u] in
tm_pureapp t None a
let comp_withlocal_array_body_post (post:term) (a:term) (arr:term) : term =
tm_star post (tm_exists_sl u0 (as_binder (mk_seq u0 a)) (mk_array_pts_to a arr (null_bvar 0)))
let comp_withlocal_array_body (arr:var) (a:term) (init:term) (len:term) (c:comp{C_ST? c}) : comp =
let arr = null_var arr in
C_ST {
u = comp_u c;
res = comp_res c;
pre = comp_withlocal_array_body_pre (comp_pre c) a arr init len;
post = comp_withlocal_array_body_post (comp_post c) a arr
}
let comp_rewrite (p q:vprop) : comp =
C_STGhost tm_emp_inames {
u = u0;
res = tm_unit;
pre = p;
post = q;
}
let comp_admit (c:ctag) (s:st_comp) : comp =
match c with
| STT -> C_ST s
| STT_Atomic -> C_STAtomic tm_emp_inames s
| STT_Ghost -> C_STGhost tm_emp_inames s
[@@erasable]
noeq
type my_erased (a:Type) = | E of a | false | true | Pulse.Typing.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val typing : g: Pulse.Typing.Env.env ->
e: Pulse.Syntax.Base.term ->
eff: FStar.Stubs.TypeChecker.Core.tot_or_ghost ->
t: Pulse.Syntax.Base.term
-> Type0 | [] | Pulse.Typing.typing | {
"file_name": "lib/steel/pulse/Pulse.Typing.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
g: Pulse.Typing.Env.env ->
e: Pulse.Syntax.Base.term ->
eff: FStar.Stubs.TypeChecker.Core.tot_or_ghost ->
t: Pulse.Syntax.Base.term
-> Type0 | {
"end_col": 69,
"end_line": 491,
"start_col": 2,
"start_line": 491
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.