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
val eval_VShufpd (permutation: int) (src1 src2: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2)
val eval_VShufpd (permutation: int) (src1 src2: quad32) : option quad32 let eval_VShufpd (permutation: int) (src1 src2: quad32) : option quad32 =
false
null
false
check_avx (eval_Shufpd_raw permutation src1 src2)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Prims.int", "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_avx", "Vale.X64.Instructions_s.eval_Shufpd_raw", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_VShufpd (permutation: int) (src1 src2: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_VShufpd
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
permutation: Prims.int -> src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 51, "end_line": 185, "start_col": 2, "start_line": 185 }
Prims.Tot
val eval_Pxor (dst src: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val eval_Pxor (dst src: quad32) : option quad32 let eval_Pxor (dst src: quad32) : option quad32 =
false
null
false
check_sse2 (Some (quad32_xor dst src))
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_sse2", "FStar.Pervasives.Native.Some", "Vale.Def.Types_s.quad32_xor", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Pxor (dst src: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_Pxor
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Machine_s.quad32 -> src: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 87, "end_line": 113, "start_col": 49, "start_line": 113 }
Prims.Tot
val eval_VPslldq (count: nat8) (src: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val eval_VPslldq (count: nat8) (src: quad32) : option quad32 let eval_VPslldq (count: nat8) (src: quad32) : option quad32 =
false
null
false
check_avx (eval_Pslldq_raw count src)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat8", "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_avx", "Vale.X64.Instructions_s.eval_Pslldq_raw", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_VPslldq (count: nat8) (src: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_VPslldq
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
count: Vale.Def.Types_s.nat8 -> src: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 98, "end_line": 280, "start_col": 61, "start_line": 280 }
Prims.Tot
val is_full_byte_reversal_mask (q: quad32) : bool
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203
val is_full_byte_reversal_mask (q: quad32) : bool let is_full_byte_reversal_mask (q: quad32) : bool =
false
null
false
q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "Prims.op_AmpAmp", "Prims.op_Equality", "Prims.int", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Prims.bool" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_full_byte_reversal_mask (q: quad32) : bool
[]
Vale.X64.Instructions_s.is_full_byte_reversal_mask
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: Vale.X64.Machine_s.quad32 -> Prims.bool
{ "end_col": 20, "end_line": 193, "start_col": 2, "start_line": 190 }
Prims.Tot
val eval_Comment:option unit
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Comment : option unit = Some ()
val eval_Comment:option unit let eval_Comment:option unit =
false
null
false
Some ()
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "FStar.Pervasives.Native.Some", "Prims.unit" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm) let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2) val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm) let eval_AESNI_enc (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2) val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2) else None val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2) val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last let eval_AESNI_dec (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src) else None val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec let eval_AESNI_dec_last (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src) else None val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last let eval_AESNI_imc (src:quad32) : option quad32 = if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 = if aesni_enabled then Some (Mkfour (Vale.AES.AES_s.sub_word src.lo1) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm) (Vale.AES.AES_s.sub_word src.hi3) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm)) else None val ins_AESNI_keygen_assist (imm:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm) let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 = if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None val ins_SHA256_rnds2 : instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2 let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 = if sha_enabled then Some (sha256_msg1_spec src1 src2) else None val ins_SHA256_msg1 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg1 let eval_SHA256_msg2 (src1 src2:quad32) : option quad32 = if sha_enabled then Some (sha256_msg2_spec src1 src2) else None val ins_SHA256_msg2 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg2 let eval_Ghost : option unit = Some () val ins_Ghost : instr_dep [] [] PreserveFlags eval_Ghost
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Comment:option unit
[]
Vale.X64.Instructions_s.eval_Comment
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.Pervasives.Native.option Prims.unit
{ "end_col": 40, "end_line": 373, "start_col": 33, "start_line": 373 }
Prims.Tot
val eval_VAESNI_enc_last (src1 src2: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2)
val eval_VAESNI_enc_last (src1 src2: quad32) : option quad32 let eval_VAESNI_enc_last (src1 src2: quad32) : option quad32 =
false
null
false
check_avx (eval_AESNI_enc_last src1 src2)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_avx", "Vale.X64.Instructions_s.eval_AESNI_enc_last", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm) let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2) val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm) let eval_AESNI_enc (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2) val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2) else None val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_VAESNI_enc_last (src1 src2: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_VAESNI_enc_last
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 103, "end_line": 327, "start_col": 62, "start_line": 327 }
Prims.Tot
val eval_Bswap64 (dst: nat64) : option nat64
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val eval_Bswap64 (dst: nat64) : option nat64 let eval_Bswap64 (dst: nat64) : option nat64 =
false
null
false
Some (reverse_bytes_nat64 dst)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.nat64", "FStar.Pervasives.Native.Some", "Vale.Def.Types_s.reverse_bytes_nat64", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Bswap64 (dst: nat64) : option nat64
[]
Vale.X64.Instructions_s.eval_Bswap64
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.nat64
{ "end_col": 76, "end_line": 19, "start_col": 46, "start_line": 19 }
Prims.Tot
val eval_Psrldq_8_raw (count: nat8) (src: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None
val eval_Psrldq_8_raw (count: nat8) (src: quad32) : option quad32 let eval_Psrldq_8_raw (count: nat8) (src: quad32) : option quad32 =
false
null
false
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat8", "Vale.X64.Machine_s.quad32", "Prims.op_Equality", "Prims.int", "FStar.Pervasives.Native.Some", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Psrldq_8_raw (count: nat8) (src: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_Psrldq_8_raw
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
count: Vale.Def.Types_s.nat8 -> src: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 11, "end_line": 286, "start_col": 2, "start_line": 285 }
Prims.Tot
val eval_AESNI_imc (src: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_AESNI_imc (src:quad32) : option quad32 = if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None
val eval_AESNI_imc (src: quad32) : option quad32 let eval_AESNI_imc (src: quad32) : option quad32 =
false
null
false
if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "Vale.X64.CPU_Features_s.aesni_enabled", "FStar.Pervasives.Native.Some", "Vale.AES.AES_s.inv_mix_columns_LE", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm) let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2) val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm) let eval_AESNI_enc (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2) val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2) else None val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2) val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last let eval_AESNI_dec (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src) else None val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec let eval_AESNI_dec_last (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src) else None val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_AESNI_imc (src: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_AESNI_imc
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 78, "end_line": 343, "start_col": 2, "start_line": 343 }
Prims.Tot
val eval_AESNI_enc (src1 src2: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_AESNI_enc (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None
val eval_AESNI_enc (src1 src2: quad32) : option quad32 let eval_AESNI_enc (src1 src2: quad32) : option quad32 =
false
null
false
if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "Vale.X64.CPU_Features_s.aesni_enabled", "FStar.Pervasives.Native.Some", "Vale.Def.Types_s.quad32_xor", "Vale.AES.AES_s.mix_columns_LE", "Vale.AES.AES_common_s.sub_bytes", "Vale.AES.AES_s.shift_rows_LE", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm) let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2) val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_AESNI_enc (src1 src2: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_AESNI_enc
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 11, "end_line": 315, "start_col": 2, "start_line": 313 }
Prims.Tot
val eval_SHA256_msg1 (src1 src2: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 = if sha_enabled then Some (sha256_msg1_spec src1 src2) else None
val eval_SHA256_msg1 (src1 src2: quad32) : option quad32 let eval_SHA256_msg1 (src1 src2: quad32) : option quad32 =
false
null
false
if sha_enabled then Some (sha256_msg1_spec src1 src2) else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "Vale.X64.CPU_Features_s.sha_enabled", "FStar.Pervasives.Native.Some", "Vale.X64.CryptoInstructions_s.sha256_msg1_spec", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm) let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2) val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm) let eval_AESNI_enc (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2) val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2) else None val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2) val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last let eval_AESNI_dec (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src) else None val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec let eval_AESNI_dec_last (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src) else None val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last let eval_AESNI_imc (src:quad32) : option quad32 = if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 = if aesni_enabled then Some (Mkfour (Vale.AES.AES_s.sub_word src.lo1) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm) (Vale.AES.AES_s.sub_word src.hi3) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm)) else None val ins_AESNI_keygen_assist (imm:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm) let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 = if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None val ins_SHA256_rnds2 : instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_SHA256_msg1 (src1 src2: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_SHA256_msg1
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 65, "end_line": 363, "start_col": 2, "start_line": 363 }
Prims.Tot
val eval_VPsrldq (count: nat8) (src: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val eval_VPsrldq (count: nat8) (src: quad32) : option quad32 let eval_VPsrldq (count: nat8) (src: quad32) : option quad32 =
false
null
false
check_avx (eval_Psrldq_8_raw count src)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat8", "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_avx", "Vale.X64.Instructions_s.eval_Psrldq_8_raw", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_VPsrldq (count: nat8) (src: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_VPsrldq
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
count: Vale.Def.Types_s.nat8 -> src: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 100, "end_line": 287, "start_col": 61, "start_line": 287 }
Prims.Tot
val is_high_dup_reversal_mask (q: quad32) : bool
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B
val is_high_dup_reversal_mask (q: quad32) : bool let is_high_dup_reversal_mask (q: quad32) : bool =
false
null
false
q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "Prims.op_AmpAmp", "Prims.op_Equality", "Prims.int", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Prims.bool" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_high_dup_reversal_mask (q: quad32) : bool
[]
Vale.X64.Instructions_s.is_high_dup_reversal_mask
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: Vale.X64.Machine_s.quad32 -> Prims.bool
{ "end_col": 20, "end_line": 205, "start_col": 2, "start_line": 202 }
Prims.Tot
val eval_Pshufb_raw (src1 src2: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None
val eval_Pshufb_raw (src1 src2: quad32) : option quad32 let eval_Pshufb_raw (src1 src2: quad32) : option quad32 =
false
null
false
if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.is_full_byte_reversal_mask", "FStar.Pervasives.Native.Some", "Vale.Def.Types_s.reverse_bytes_quad32", "Prims.bool", "Vale.X64.Instructions_s.is_byte_reversal_mask", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Vale.Def.Types_s.reverse_bytes_nat32", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.X64.Instructions_s.is_high_dup_reversal_mask", "Vale.X64.Instructions_s.is_lower_upper_byte_reversal_mask", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Pshufb_raw (src1 src2: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_Pshufb_raw
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 11, "end_line": 235, "start_col": 2, "start_line": 215 }
Prims.Tot
val eval_Space:option unit
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Space : option unit = Some ()
val eval_Space:option unit let eval_Space:option unit =
false
null
false
Some ()
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "FStar.Pervasives.Native.Some", "Prims.unit" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm) let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2) val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm) let eval_AESNI_enc (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2) val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2) else None val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2) val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last let eval_AESNI_dec (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src) else None val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec let eval_AESNI_dec_last (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src) else None val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last let eval_AESNI_imc (src:quad32) : option quad32 = if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 = if aesni_enabled then Some (Mkfour (Vale.AES.AES_s.sub_word src.lo1) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm) (Vale.AES.AES_s.sub_word src.hi3) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm)) else None val ins_AESNI_keygen_assist (imm:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm) let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 = if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None val ins_SHA256_rnds2 : instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2 let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 = if sha_enabled then Some (sha256_msg1_spec src1 src2) else None val ins_SHA256_msg1 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg1 let eval_SHA256_msg2 (src1 src2:quad32) : option quad32 = if sha_enabled then Some (sha256_msg2_spec src1 src2) else None val ins_SHA256_msg2 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg2 let eval_Ghost : option unit = Some () val ins_Ghost : instr_dep [] [] PreserveFlags eval_Ghost let eval_Comment : option unit = Some () val ins_Comment (_:string) : instr_dep [] [] PreserveFlags eval_Comment let eval_LargeComment : option unit = Some () val ins_LargeComment (_:string) : instr_dep [] [] PreserveFlags eval_LargeComment let eval_Newline : option unit = Some () val ins_Newline : instr_dep [] [] PreserveFlags eval_Newline
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Space:option unit
[]
Vale.X64.Instructions_s.eval_Space
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.Pervasives.Native.option Prims.unit
{ "end_col": 38, "end_line": 382, "start_col": 31, "start_line": 382 }
Prims.Tot
val eval_AESNI_dec (dst src: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_AESNI_dec (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src) else None
val eval_AESNI_dec (dst src: quad32) : option quad32 let eval_AESNI_dec (dst src: quad32) : option quad32 =
false
null
false
if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src) else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "Vale.X64.CPU_Features_s.aesni_enabled", "FStar.Pervasives.Native.Some", "Vale.Def.Types_s.quad32_xor", "Vale.AES.AES_s.inv_mix_columns_LE", "Vale.AES.AES_common_s.inv_sub_bytes", "Vale.AES.AES_s.inv_shift_rows_LE", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm) let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2) val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm) let eval_AESNI_enc (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2) val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2) else None val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2) val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_AESNI_dec (dst src: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_AESNI_dec
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Machine_s.quad32 -> src: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 11, "end_line": 333, "start_col": 2, "start_line": 331 }
Prims.Tot
val eval_Newline:option unit
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Newline : option unit = Some ()
val eval_Newline:option unit let eval_Newline:option unit =
false
null
false
Some ()
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "FStar.Pervasives.Native.Some", "Prims.unit" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm) let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2) val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm) let eval_AESNI_enc (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2) val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2) else None val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2) val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last let eval_AESNI_dec (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src) else None val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec let eval_AESNI_dec_last (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src) else None val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last let eval_AESNI_imc (src:quad32) : option quad32 = if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 = if aesni_enabled then Some (Mkfour (Vale.AES.AES_s.sub_word src.lo1) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm) (Vale.AES.AES_s.sub_word src.hi3) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm)) else None val ins_AESNI_keygen_assist (imm:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm) let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 = if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None val ins_SHA256_rnds2 : instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2 let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 = if sha_enabled then Some (sha256_msg1_spec src1 src2) else None val ins_SHA256_msg1 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg1 let eval_SHA256_msg2 (src1 src2:quad32) : option quad32 = if sha_enabled then Some (sha256_msg2_spec src1 src2) else None val ins_SHA256_msg2 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg2 let eval_Ghost : option unit = Some () val ins_Ghost : instr_dep [] [] PreserveFlags eval_Ghost let eval_Comment : option unit = Some () val ins_Comment (_:string) : instr_dep [] [] PreserveFlags eval_Comment let eval_LargeComment : option unit = Some () val ins_LargeComment (_:string) : instr_dep [] [] PreserveFlags eval_LargeComment
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Newline:option unit
[]
Vale.X64.Instructions_s.eval_Newline
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.Pervasives.Native.option Prims.unit
{ "end_col": 40, "end_line": 379, "start_col": 33, "start_line": 379 }
Prims.Tot
val eval_SHA256_rnds2 (src1 src2 wk: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 = if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None
val eval_SHA256_rnds2 (src1 src2 wk: quad32) : option quad32 let eval_SHA256_rnds2 (src1 src2 wk: quad32) : option quad32 =
false
null
false
if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "Vale.X64.CPU_Features_s.sha_enabled", "FStar.Pervasives.Native.Some", "Vale.X64.CryptoInstructions_s.sha256_rnds2_spec", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm) let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2) val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm) let eval_AESNI_enc (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2) val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2) else None val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2) val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last let eval_AESNI_dec (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src) else None val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec let eval_AESNI_dec_last (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src) else None val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last let eval_AESNI_imc (src:quad32) : option quad32 = if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 = if aesni_enabled then Some (Mkfour (Vale.AES.AES_s.sub_word src.lo1) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm) (Vale.AES.AES_s.sub_word src.hi3) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm)) else None val ins_AESNI_keygen_assist (imm:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm)
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_SHA256_rnds2 (src1 src2 wk: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_SHA256_rnds2
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32 -> wk: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 69, "end_line": 358, "start_col": 2, "start_line": 358 }
Prims.Tot
val check_sse2 (#a: Type0) (x: option a) : option a
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None
val check_sse2 (#a: Type0) (x: option a) : option a let check_sse2 (#a: Type0) (x: option a) : option a =
false
null
false
if sse2_enabled then x else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "FStar.Pervasives.Native.option", "Vale.X64.CPU_Features_s.sse2_enabled", "Prims.bool", "FStar.Pervasives.Native.None" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None
false
false
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val check_sse2 (#a: Type0) (x: option a) : option a
[]
Vale.X64.Instructions_s.check_sse2
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: FStar.Pervasives.Native.option a -> FStar.Pervasives.Native.option a
{ "end_col": 34, "end_line": 102, "start_col": 2, "start_line": 102 }
Prims.Tot
val eval_VPclmulqdq (imm: int) (src1 src2: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2)
val eval_VPclmulqdq (imm: int) (src1 src2: quad32) : option quad32 let eval_VPclmulqdq (imm: int) (src1 src2: quad32) : option quad32 =
false
null
false
check_avx (eval_Pclmulqdq imm src1 src2)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Prims.int", "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_avx", "Vale.X64.Instructions_s.eval_Pclmulqdq", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_VPclmulqdq (imm: int) (src1 src2: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_VPclmulqdq
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
imm: Prims.int -> src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 42, "end_line": 309, "start_col": 2, "start_line": 309 }
Prims.Tot
val eval_Shr64 (dst amt: nat64) : option nat64
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val eval_Shr64 (dst amt: nat64) : option nat64 let eval_Shr64 (dst amt: nat64) : option nat64 =
false
null
false
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.nat64", "Prims.op_LessThan", "FStar.Pervasives.Native.Some", "Vale.Def.Types_s.ishr", "Vale.Def.Words_s.pow2_64", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Shr64 (dst amt: nat64) : option nat64
[]
Vale.X64.Instructions_s.eval_Shr64
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Machine_s.nat64 -> amt: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.nat64
{ "end_col": 65, "end_line": 74, "start_col": 2, "start_line": 74 }
Prims.Tot
val eval_Cpuid (rax rcx: nat64) : option (nat64 & (nat64 & (nat64 & nat64)))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val eval_Cpuid (rax rcx: nat64) : option (nat64 & (nat64 & (nat64 & nat64))) let eval_Cpuid (rax rcx: nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
false
null
false
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.nat64", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.CPU_Features_s.cpuid", "Vale.X64.Machine_s.rRax", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rRdx", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Cpuid (rax rcx: nat64) : option (nat64 & (nat64 & (nat64 & nat64)))
[]
Vale.X64.Instructions_s.eval_Cpuid
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
rax: Vale.X64.Machine_s.nat64 -> rcx: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option (Vale.X64.Machine_s.nat64 * (Vale.X64.Machine_s.nat64 * (Vale.X64.Machine_s.nat64 * Vale.X64.Machine_s.nat64)))
{ "end_col": 91, "end_line": 82, "start_col": 2, "start_line": 82 }
Prims.Tot
val eval_Movdqu (src: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val eval_Movdqu (src: quad32) : option quad32 let eval_Movdqu (src: quad32) : option quad32 =
false
null
false
check_sse2 (Some src)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_sse2", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Movdqu (src: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_Movdqu
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 68, "end_line": 110, "start_col": 47, "start_line": 110 }
Prims.Tot
val check_ssse3 (#a: Type0) (x: option a) : option a
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None
val check_ssse3 (#a: Type0) (x: option a) : option a let check_ssse3 (#a: Type0) (x: option a) : option a =
false
null
false
if ssse3_enabled then x else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "FStar.Pervasives.Native.option", "Vale.X64.CPU_Features_s.ssse3_enabled", "Prims.bool", "FStar.Pervasives.Native.None" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None
false
false
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val check_ssse3 (#a: Type0) (x: option a) : option a
[]
Vale.X64.Instructions_s.check_ssse3
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: FStar.Pervasives.Native.option a -> FStar.Pervasives.Native.option a
{ "end_col": 35, "end_line": 105, "start_col": 2, "start_line": 105 }
Prims.Tot
val eval_And64 (dst src: nat64) : option nat64
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val eval_And64 (dst src: nat64) : option nat64 let eval_And64 (dst src: nat64) : option nat64 =
false
null
false
Some (iand dst src)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.nat64", "FStar.Pervasives.Native.Some", "Vale.Def.Types_s.iand", "Vale.Def.Words_s.pow2_64", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_And64 (dst src: nat64) : option nat64
[]
Vale.X64.Instructions_s.eval_And64
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Machine_s.nat64 -> src: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.nat64
{ "end_col": 67, "end_line": 66, "start_col": 48, "start_line": 66 }
Prims.Tot
val eval_Xgetbv (rcx: nat64) : option (nat64 & nat64)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val eval_Xgetbv (rcx: nat64) : option (nat64 & nat64) let eval_Xgetbv (rcx: nat64) : option (nat64 & nat64) =
false
null
false
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.nat64", "Prims.op_AmpAmp", "Vale.X64.CPU_Features_s.osxsave_enabled", "Prims.op_Equality", "Prims.int", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.CPU_Features_s.xgetbv", "Vale.X64.Machine_s.rRax", "Vale.X64.Machine_s.rRdx", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Xgetbv (rcx: nat64) : option (nat64 & nat64)
[]
Vale.X64.Instructions_s.eval_Xgetbv
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
rcx: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option (Vale.X64.Machine_s.nat64 * Vale.X64.Machine_s.nat64)
{ "end_col": 86, "end_line": 92, "start_col": 2, "start_line": 92 }
Prims.Tot
val check_sse4_1 (#a: Type0) (x: option a) : option a
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None
val check_sse4_1 (#a: Type0) (x: option a) : option a let check_sse4_1 (#a: Type0) (x: option a) : option a =
false
null
false
if sse4_1_enabled then x else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "FStar.Pervasives.Native.option", "Vale.X64.CPU_Features_s.sse4_1_enabled", "Prims.bool", "FStar.Pervasives.Native.None" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None
false
false
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val check_sse4_1 (#a: Type0) (x: option a) : option a
[]
Vale.X64.Instructions_s.check_sse4_1
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: FStar.Pervasives.Native.option a -> FStar.Pervasives.Native.option a
{ "end_col": 36, "end_line": 108, "start_col": 2, "start_line": 108 }
Prims.Tot
val eval_Shufpd (permutation: int) (src1 src2: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2)
val eval_Shufpd (permutation: int) (src1 src2: quad32) : option quad32 let eval_Shufpd (permutation: int) (src1 src2: quad32) : option quad32 =
false
null
false
check_sse2 (eval_Shufpd_raw permutation src1 src2)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Prims.int", "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_sse2", "Vale.X64.Instructions_s.eval_Shufpd_raw", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Shufpd (permutation: int) (src1 src2: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_Shufpd
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
permutation: Prims.int -> src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 52, "end_line": 180, "start_col": 2, "start_line": 180 }
Prims.Tot
val eval_Psrld (amt: int) (dst: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val eval_Psrld (amt: int) (dst: quad32) : option quad32 let eval_Psrld (amt: int) (dst: quad32) : option quad32 =
false
null
false
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Prims.int", "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_sse2", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "FStar.Pervasives.Native.Some", "Vale.Def.Words.Four_s.four_map", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.pow2_32", "Vale.Def.Types_s.ishr", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Psrld (amt: int) (dst: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_Psrld
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
amt: Prims.int -> dst: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 95, "end_line": 140, "start_col": 2, "start_line": 140 }
Prims.Tot
val eval_Pand (dst src: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val eval_Pand (dst src: quad32) : option quad32 let eval_Pand (dst src: quad32) : option quad32 =
false
null
false
check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_sse2", "FStar.Pervasives.Native.Some", "Vale.Def.Words.Four_s.four_map2", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.pow2_32", "Vale.Def.Types_s.iand", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Pand (dst src: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_Pand
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Machine_s.quad32 -> src: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 112, "end_line": 119, "start_col": 49, "start_line": 119 }
Prims.Tot
val eval_Cmovc64 (dst src: nat64) (carry: bool) : option nat64
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val eval_Cmovc64 (dst src: nat64) (carry: bool) : option nat64 let eval_Cmovc64 (dst src: nat64) (carry: bool) : option nat64 =
false
null
false
Some (if carry then src else dst)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.nat64", "Prims.bool", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Cmovc64 (dst src: nat64) (carry: bool) : option nat64
[]
Vale.X64.Instructions_s.eval_Cmovc64
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Machine_s.nat64 -> src: Vale.X64.Machine_s.nat64 -> carry: Prims.bool -> FStar.Pervasives.Native.option Vale.X64.Machine_s.nat64
{ "end_col": 96, "end_line": 22, "start_col": 63, "start_line": 22 }
Prims.Tot
val eval_Pslldq_raw (count: nat8) (src: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None
val eval_Pslldq_raw (count: nat8) (src: quad32) : option quad32 let eval_Pslldq_raw (count: nat8) (src: quad32) : option quad32 =
false
null
false
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat8", "Vale.X64.Machine_s.quad32", "Prims.op_Equality", "Prims.int", "FStar.Pervasives.Native.Some", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Pslldq_raw (count: nat8) (src: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_Pslldq_raw
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
count: Vale.Def.Types_s.nat8 -> src: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 11, "end_line": 279, "start_col": 2, "start_line": 277 }
Prims.Tot
val eval_Pshufd (permutation: nat8) (src: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3)))
val eval_Pshufd (permutation: nat8) (src: quad32) : option quad32 let eval_Pshufd (permutation: nat8) (src: quad32) : option quad32 =
false
null
false
check_sse2 (let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3)))
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat8", "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_sse2", "FStar.Pervasives.Native.Some", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Vale.Def.Types_s.select_word", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Types_s.twobits", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Types_s.bits_of_byte", "Vale.Def.Types_s.byte_to_twobits", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Pshufd (permutation: nat8) (src: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_Pshufd
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
permutation: Vale.Def.Types_s.nat8 -> src: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 32, "end_line": 249, "start_col": 66, "start_line": 243 }
Prims.Tot
val eval_LargeComment:option unit
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_LargeComment : option unit = Some ()
val eval_LargeComment:option unit let eval_LargeComment:option unit =
false
null
false
Some ()
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "FStar.Pervasives.Native.Some", "Prims.unit" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm) let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2) val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm) let eval_AESNI_enc (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2) val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2) else None val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2) val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last let eval_AESNI_dec (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src) else None val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec let eval_AESNI_dec_last (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src) else None val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last let eval_AESNI_imc (src:quad32) : option quad32 = if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 = if aesni_enabled then Some (Mkfour (Vale.AES.AES_s.sub_word src.lo1) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm) (Vale.AES.AES_s.sub_word src.hi3) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm)) else None val ins_AESNI_keygen_assist (imm:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm) let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 = if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None val ins_SHA256_rnds2 : instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2 let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 = if sha_enabled then Some (sha256_msg1_spec src1 src2) else None val ins_SHA256_msg1 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg1 let eval_SHA256_msg2 (src1 src2:quad32) : option quad32 = if sha_enabled then Some (sha256_msg2_spec src1 src2) else None val ins_SHA256_msg2 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg2 let eval_Ghost : option unit = Some () val ins_Ghost : instr_dep [] [] PreserveFlags eval_Ghost let eval_Comment : option unit = Some () val ins_Comment (_:string) : instr_dep [] [] PreserveFlags eval_Comment
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_LargeComment:option unit
[]
Vale.X64.Instructions_s.eval_LargeComment
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.Pervasives.Native.option Prims.unit
{ "end_col": 45, "end_line": 376, "start_col": 38, "start_line": 376 }
Prims.Tot
val eval_Palignr (amount: nat8) (src1 src2: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2)
val eval_Palignr (amount: nat8) (src1 src2: quad32) : option quad32 let eval_Palignr (amount: nat8) (src1 src2: quad32) : option quad32 =
false
null
false
check_ssse3 (eval_Palignr_raw amount src1 src2)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat8", "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_ssse3", "Vale.X64.Instructions_s.eval_Palignr_raw", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Palignr (amount: nat8) (src1 src2: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_Palignr
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
amount: Vale.Def.Types_s.nat8 -> src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 49, "end_line": 161, "start_col": 2, "start_line": 161 }
Prims.Tot
val eval_Prefetchnta: nat64 -> option unit
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Prefetchnta (_:nat64) : option unit = Some ()
val eval_Prefetchnta: nat64 -> option unit let eval_Prefetchnta (_: nat64) : option unit =
false
null
false
Some ()
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.nat64", "FStar.Pervasives.Native.Some", "Prims.unit", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm) let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2) val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm) let eval_AESNI_enc (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2) val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2) else None val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2) val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last let eval_AESNI_dec (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src) else None val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec let eval_AESNI_dec_last (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src) else None val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last let eval_AESNI_imc (src:quad32) : option quad32 = if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 = if aesni_enabled then Some (Mkfour (Vale.AES.AES_s.sub_word src.lo1) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm) (Vale.AES.AES_s.sub_word src.hi3) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm)) else None val ins_AESNI_keygen_assist (imm:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm) let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 = if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None val ins_SHA256_rnds2 : instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2 let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 = if sha_enabled then Some (sha256_msg1_spec src1 src2) else None val ins_SHA256_msg1 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg1 let eval_SHA256_msg2 (src1 src2:quad32) : option quad32 = if sha_enabled then Some (sha256_msg2_spec src1 src2) else None val ins_SHA256_msg2 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg2 let eval_Ghost : option unit = Some () val ins_Ghost : instr_dep [] [] PreserveFlags eval_Ghost let eval_Comment : option unit = Some () val ins_Comment (_:string) : instr_dep [] [] PreserveFlags eval_Comment let eval_LargeComment : option unit = Some () val ins_LargeComment (_:string) : instr_dep [] [] PreserveFlags eval_LargeComment let eval_Newline : option unit = Some () val ins_Newline : instr_dep [] [] PreserveFlags eval_Newline let eval_Space : option unit = Some () val ins_Space (_:nat) : instr_dep [] [] PreserveFlags eval_Space
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Prefetchnta: nat64 -> option unit
[]
Vale.X64.Instructions_s.eval_Prefetchnta
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option Prims.unit
{ "end_col": 54, "end_line": 385, "start_col": 47, "start_line": 385 }
Prims.Tot
val check_avx (#a: Type0) (x: option a) : option a
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None
val check_avx (#a: Type0) (x: option a) : option a let check_avx (#a: Type0) (x: option a) : option a =
false
null
false
if avx_enabled then x else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "FStar.Pervasives.Native.option", "Vale.X64.CPU_Features_s.avx_enabled", "Prims.bool", "FStar.Pervasives.Native.None" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv
false
false
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val check_avx (#a: Type0) (x: option a) : option a
[]
Vale.X64.Instructions_s.check_avx
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: FStar.Pervasives.Native.option a -> FStar.Pervasives.Native.option a
{ "end_col": 33, "end_line": 99, "start_col": 2, "start_line": 99 }
Prims.Tot
val eval_Ghost:option unit
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Ghost : option unit = Some ()
val eval_Ghost:option unit let eval_Ghost:option unit =
false
null
false
Some ()
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "FStar.Pervasives.Native.Some", "Prims.unit" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm) let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2) val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm) let eval_AESNI_enc (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2) val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2) else None val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2) val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last let eval_AESNI_dec (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src) else None val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec let eval_AESNI_dec_last (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src) else None val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last let eval_AESNI_imc (src:quad32) : option quad32 = if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 = if aesni_enabled then Some (Mkfour (Vale.AES.AES_s.sub_word src.lo1) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm) (Vale.AES.AES_s.sub_word src.hi3) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm)) else None val ins_AESNI_keygen_assist (imm:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm) let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 = if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None val ins_SHA256_rnds2 : instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2 let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 = if sha_enabled then Some (sha256_msg1_spec src1 src2) else None val ins_SHA256_msg1 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg1 let eval_SHA256_msg2 (src1 src2:quad32) : option quad32 = if sha_enabled then Some (sha256_msg2_spec src1 src2) else None val ins_SHA256_msg2 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg2
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Ghost:option unit
[]
Vale.X64.Instructions_s.eval_Ghost
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.Pervasives.Native.option Prims.unit
{ "end_col": 38, "end_line": 370, "start_col": 31, "start_line": 370 }
Prims.Tot
val eval_VAESNI_enc (src1 src2: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2)
val eval_VAESNI_enc (src1 src2: quad32) : option quad32 let eval_VAESNI_enc (src1 src2: quad32) : option quad32 =
false
null
false
check_avx (eval_AESNI_enc src1 src2)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_avx", "Vale.X64.Instructions_s.eval_AESNI_enc", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm) let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2) val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm) let eval_AESNI_enc (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_VAESNI_enc (src1 src2: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_VAESNI_enc
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 93, "end_line": 318, "start_col": 57, "start_line": 318 }
Prims.Tot
val eval_Palignr_raw (amount: nat8) (src1 src2: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None
val eval_Palignr_raw (amount: nat8) (src1 src2: quad32) : option quad32 let eval_Palignr_raw (amount: nat8) (src1 src2: quad32) : option quad32 =
false
null
false
if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat8", "Vale.X64.Machine_s.quad32", "Prims.op_Equality", "Prims.int", "FStar.Pervasives.Native.Some", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Palignr_raw (amount: nat8) (src1 src2: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_Palignr_raw
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
amount: Vale.Def.Types_s.nat8 -> src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 11, "end_line": 158, "start_col": 2, "start_line": 154 }
Prims.Tot
val eval_SHA256_msg2 (src1 src2: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_SHA256_msg2 (src1 src2:quad32) : option quad32 = if sha_enabled then Some (sha256_msg2_spec src1 src2) else None
val eval_SHA256_msg2 (src1 src2: quad32) : option quad32 let eval_SHA256_msg2 (src1 src2: quad32) : option quad32 =
false
null
false
if sha_enabled then Some (sha256_msg2_spec src1 src2) else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "Vale.X64.CPU_Features_s.sha_enabled", "FStar.Pervasives.Native.Some", "Vale.X64.CryptoInstructions_s.sha256_msg2_spec", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm) let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2) val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm) let eval_AESNI_enc (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2) val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2) else None val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2) val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last let eval_AESNI_dec (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src) else None val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec let eval_AESNI_dec_last (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src) else None val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last let eval_AESNI_imc (src:quad32) : option quad32 = if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 = if aesni_enabled then Some (Mkfour (Vale.AES.AES_s.sub_word src.lo1) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm) (Vale.AES.AES_s.sub_word src.hi3) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm)) else None val ins_AESNI_keygen_assist (imm:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm) let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 = if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None val ins_SHA256_rnds2 : instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2 let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 = if sha_enabled then Some (sha256_msg1_spec src1 src2) else None val ins_SHA256_msg1 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg1
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_SHA256_msg2 (src1 src2: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_SHA256_msg2
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 65, "end_line": 367, "start_col": 2, "start_line": 367 }
Prims.Tot
val eval_AddCarry64 (old_carry: bool) (dst src: nat64) : option (bool & nat64)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64)
val eval_AddCarry64 (old_carry: bool) (dst src: nat64) : option (bool & nat64) let eval_AddCarry64 (old_carry: bool) (dst src: nat64) : option (bool & nat64) =
false
null
false
let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Prims.bool", "Vale.X64.Machine_s.nat64", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Prims.op_GreaterThanOrEqual", "Vale.X64.Machine_s.pow2_64", "Prims.op_Modulus", "Prims.int", "Prims.op_Addition", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_AddCarry64 (old_carry: bool) (dst src: nat64) : option (bool & nat64)
[]
Vale.X64.Instructions_s.eval_AddCarry64
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
old_carry: Prims.bool -> dst: Vale.X64.Machine_s.nat64 -> src: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option (Prims.bool * Vale.X64.Machine_s.nat64)
{ "end_col": 38, "end_line": 34, "start_col": 78, "start_line": 32 }
Prims.Tot
val eval_Mul64 (rax src: nat64) : option (nat64 & nat64)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val eval_Mul64 (rax src: nat64) : option (nat64 & nat64) let eval_Mul64 (rax src: nat64) : option (nat64 & nat64) =
false
null
false
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.nat64", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "FStar.UInt.mul_div", "FStar.UInt.mul_mod", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Mul64 (rax src: nat64) : option (nat64 & nat64)
[]
Vale.X64.Instructions_s.eval_Mul64
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
rax: Vale.X64.Machine_s.nat64 -> src: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option (Vale.X64.Machine_s.nat64 * Vale.X64.Machine_s.nat64)
{ "end_col": 71, "end_line": 53, "start_col": 2, "start_line": 53 }
Prims.Tot
val eval_Paddd_raw (src1 src2: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32))
val eval_Paddd_raw (src1 src2: quad32) : option quad32 let eval_Paddd_raw (src1 src2: quad32) : option quad32 =
false
null
false
Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32))
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "FStar.Pervasives.Native.Some", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Prims.op_Modulus", "Prims.op_Addition", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.X64.Machine_s.pow2_32", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Paddd_raw (src1 src2: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_Paddd_raw
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 38, "end_line": 127, "start_col": 2, "start_line": 123 }
Prims.Tot
val eval_Adcx64_Adox64 (old_flag: bool) (dst src: nat64) : option (bool & nat64)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val eval_Adcx64_Adox64 (old_flag: bool) (dst src: nat64) : option (bool & nat64) let eval_Adcx64_Adox64 (old_flag: bool) (dst src: nat64) : option (bool & nat64) =
false
null
false
let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Prims.bool", "Vale.X64.Machine_s.nat64", "Vale.X64.CPU_Features_s.adx_enabled", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Prims.op_GreaterThanOrEqual", "Vale.X64.Machine_s.pow2_64", "Prims.op_Modulus", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "Prims.int", "Prims.op_Addition" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Adcx64_Adox64 (old_flag: bool) (dst src: nat64) : option (bool & nat64)
[]
Vale.X64.Instructions_s.eval_Adcx64_Adox64
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
old_flag: Prims.bool -> dst: Vale.X64.Machine_s.nat64 -> src: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option (Prims.bool * Vale.X64.Machine_s.nat64)
{ "end_col": 68, "end_line": 39, "start_col": 80, "start_line": 37 }
Prims.Tot
val eval_Mulx64 (rdx src: nat64) : option (nat64 & nat64)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None
val eval_Mulx64 (rdx src: nat64) : option (nat64 & nat64) let eval_Mulx64 (rdx src: nat64) : option (nat64 & nat64) =
false
null
false
let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.nat64", "Vale.X64.CPU_Features_s.bmi2_enabled", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "FStar.UInt.uint_t", "FStar.UInt.mul_mod", "FStar.UInt.mul_div" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Mulx64 (rdx src: nat64) : option (nat64 & nat64)
[]
Vale.X64.Instructions_s.eval_Mulx64
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
rdx: Vale.X64.Machine_s.nat64 -> src: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option (Vale.X64.Machine_s.nat64 * Vale.X64.Machine_s.nat64)
{ "end_col": 46, "end_line": 59, "start_col": 58, "start_line": 56 }
Prims.Tot
val eval_IMul64 (dst src: nat64) : option nat64
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src)
val eval_IMul64 (dst src: nat64) : option nat64 let eval_IMul64 (dst src: nat64) : option nat64 =
false
null
false
Some (FStar.UInt.mul_mod #64 dst src)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.nat64", "FStar.Pervasives.Native.Some", "FStar.UInt.mul_mod", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_IMul64 (dst src: nat64) : option nat64
[]
Vale.X64.Instructions_s.eval_IMul64
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Machine_s.nat64 -> src: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.nat64
{ "end_col": 39, "end_line": 63, "start_col": 2, "start_line": 63 }
Prims.Tot
val eval_Sbb64 (old_carry: bool) (dst src: nat64) : option (bool & nat64)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64)
val eval_Sbb64 (old_carry: bool) (dst src: nat64) : option (bool & nat64) let eval_Sbb64 (old_carry: bool) (dst src: nat64) : option (bool & nat64) =
false
null
false
let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Prims.bool", "Vale.X64.Machine_s.nat64", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Prims.op_LessThan", "Prims.op_Modulus", "Vale.X64.Machine_s.pow2_64", "Prims.int", "Prims.op_Subtraction", "Prims.op_Addition", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Sbb64 (old_carry: bool) (dst src: nat64) : option (bool & nat64)
[]
Vale.X64.Instructions_s.eval_Sbb64
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
old_carry: Prims.bool -> dst: Vale.X64.Machine_s.nat64 -> src: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option (Prims.bool * Vale.X64.Machine_s.nat64)
{ "end_col": 33, "end_line": 49, "start_col": 73, "start_line": 47 }
Prims.Tot
val eval_Add64 (dst src: nat64) : option (bool & nat64)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val eval_Add64 (dst src: nat64) : option (bool & nat64) let eval_Add64 (dst src: nat64) : option (bool & nat64) =
false
null
false
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.nat64", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "Prims.bool", "FStar.Pervasives.Native.Mktuple2", "Prims.op_GreaterThanOrEqual", "Vale.X64.Machine_s.pow2_64", "Prims.op_Modulus", "Prims.int", "Prims.op_Addition", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Add64 (dst src: nat64) : option (bool & nat64)
[]
Vale.X64.Instructions_s.eval_Add64
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Machine_s.nat64 -> src: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option (Prims.bool * Vale.X64.Machine_s.nat64)
{ "end_col": 61, "end_line": 26, "start_col": 56, "start_line": 25 }
Prims.Tot
val eval_Sub64 (dst src: nat64) : option (bool & nat64)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64)
val eval_Sub64 (dst src: nat64) : option (bool & nat64) let eval_Sub64 (dst src: nat64) : option (bool & nat64) =
false
null
false
let diff = dst - src in Some (diff < 0, diff % pow2_64)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.nat64", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "Prims.bool", "FStar.Pervasives.Native.Mktuple2", "Prims.op_LessThan", "Prims.op_Modulus", "Vale.X64.Machine_s.pow2_64", "Prims.int", "Prims.op_Subtraction", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Sub64 (dst src: nat64) : option (bool & nat64)
[]
Vale.X64.Instructions_s.eval_Sub64
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Machine_s.nat64 -> src: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option (Prims.bool * Vale.X64.Machine_s.nat64)
{ "end_col": 57, "end_line": 44, "start_col": 56, "start_line": 43 }
Prims.Tot
val eval_Pcmpeqd (dst src: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3))))
val eval_Pcmpeqd (dst src: quad32) : option quad32 let eval_Pcmpeqd (dst src: quad32) : option quad32 =
false
null
false
check_sse2 (let eq_result (b: bool) : nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3))))
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_sse2", "FStar.Pervasives.Native.Some", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Prims.op_Equality", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Prims.bool", "Vale.Def.Words_s.nat32", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Pcmpeqd (dst src: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_Pcmpeqd
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Machine_s.quad32 -> src: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 37, "end_line": 259, "start_col": 52, "start_line": 253 }
Prims.Tot
val eval_AddLea64 (src1 src2: nat64) : option nat64
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val eval_AddLea64 (src1 src2: nat64) : option nat64 let eval_AddLea64 (src1 src2: nat64) : option nat64 =
false
null
false
Some ((src1 + src2) % pow2_64)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.X64.Machine_s.nat64", "FStar.Pervasives.Native.Some", "Prims.op_Modulus", "Prims.op_Addition", "Vale.X64.Machine_s.pow2_64", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_AddLea64 (src1 src2: nat64) : option nat64
[]
Vale.X64.Instructions_s.eval_AddLea64
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src1: Vale.X64.Machine_s.nat64 -> src2: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.nat64
{ "end_col": 83, "end_line": 29, "start_col": 53, "start_line": 29 }
Prims.Tot
val eval_Psrldq (amt: int) (dst: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None)
val eval_Psrldq (amt: int) (dst: quad32) : option quad32 let eval_Psrldq (amt: int) (dst: quad32) : option quad32 =
false
null
false
check_sse2 (if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None)
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Prims.int", "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_sse2", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "FStar.Pervasives.Native.Some", "Vale.Def.Types_s.le_bytes_to_quad32", "FStar.Seq.Base.append", "Vale.Def.Types_s.nat8", "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat8", "FStar.Seq.Base.slice", "FStar.Seq.Base.length", "FStar.Seq.Base.create", "Vale.Def.Types_s.le_quad32_to_bytes", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Psrldq (amt: int) (dst: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_Psrldq
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
amt: Prims.int -> dst: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 12, "end_line": 149, "start_col": 57, "start_line": 143 }
Prims.Tot
val eval_AESNI_keygen_assist (imm: nat8) (src: quad32) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 = if aesni_enabled then Some (Mkfour (Vale.AES.AES_s.sub_word src.lo1) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm) (Vale.AES.AES_s.sub_word src.hi3) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm)) else None
val eval_AESNI_keygen_assist (imm: nat8) (src: quad32) : option quad32 let eval_AESNI_keygen_assist (imm: nat8) (src: quad32) : option quad32 =
false
null
false
if aesni_enabled then Some (Mkfour (Vale.AES.AES_s.sub_word src.lo1) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm) (Vale.AES.AES_s.sub_word src.hi3) (ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm)) else None
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat8", "Vale.X64.Machine_s.quad32", "Vale.X64.CPU_Features_s.aesni_enabled", "FStar.Pervasives.Native.Some", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Vale.AES.AES_common_s.sub_word", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Types_s.ixor", "Vale.Def.Words_s.pow2_32", "Vale.AES.AES_s.rot_word_LE", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index) let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the two very special cases we need if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2) else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1) else None let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src) val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 = // We only spec the one very special case we need if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = let Mkfour a0 a1 a2 a3 = src1 in let Mkfour b0 b1 b2 b3 = src2 in let f x0 x1 y0 y1 = let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y) in if pclmulqdq_enabled then match imm with | 0 -> Some (f a0 a1 b0 b1) | 1 -> Some (f a2 a3 b0 b1) | 16 -> Some (f a0 a1 b2 b3) | 17 -> Some (f a2 a3 b2 b3) | _ -> None else None val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm) let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Pclmulqdq imm src1 src2) val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm) let eval_AESNI_enc (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2) else None val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2) val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2) else None val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2) val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last let eval_AESNI_dec (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src) else None val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec let eval_AESNI_dec_last (dst src:quad32) : option quad32 = if aesni_enabled then Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src) else None val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last let eval_AESNI_imc (src:quad32) : option quad32 = if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_AESNI_keygen_assist (imm: nat8) (src: quad32) : option quad32
[]
Vale.X64.Instructions_s.eval_AESNI_keygen_assist
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
imm: Vale.Def.Types_s.nat8 -> src: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 11, "end_line": 353, "start_col": 2, "start_line": 347 }
Prims.Tot
val eval_Pinsrd (index: nat8) (dst: quad32) (src: nat64) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val eval_Pinsrd (index: nat8) (dst: quad32) (src: nat64) : option quad32 let eval_Pinsrd (index: nat8) (dst: quad32) (src: nat64) : option quad32 =
false
null
false
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat8", "Vale.X64.Machine_s.quad32", "Vale.X64.Machine_s.nat64", "Vale.X64.Instructions_s.check_sse4_1", "FStar.Pervasives.Native.Some", "Vale.Def.Types_s.insert_nat32", "Prims.op_Modulus", "Vale.X64.Machine_s.pow2_32", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Pinsrd (index: nat8) (dst: quad32) (src: nat64) : option quad32
[]
Vale.X64.Instructions_s.eval_Pinsrd
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
index: Vale.Def.Types_s.nat8 -> dst: Vale.X64.Machine_s.quad32 -> src: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 68, "end_line": 268, "start_col": 2, "start_line": 268 }
Prims.Tot
val eval_Pinsrq (index: nat8) (dst: quad32) (src: nat64) : option quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val eval_Pinsrq (index: nat8) (dst: quad32) (src: nat64) : option quad32 let eval_Pinsrq (index: nat8) (dst: quad32) (src: nat64) : option quad32 =
false
null
false
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat8", "Vale.X64.Machine_s.quad32", "Vale.X64.Machine_s.nat64", "Vale.X64.Instructions_s.check_sse4_1", "FStar.Pervasives.Native.Some", "Vale.Def.Types_s.insert_nat64_def", "Prims.op_Modulus", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2)))) val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 = check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Pinsrq (index: nat8) (dst: quad32) (src: nat64) : option quad32
[]
Vale.X64.Instructions_s.eval_Pinsrq
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
index: Vale.Def.Types_s.nat8 -> dst: Vale.X64.Machine_s.quad32 -> src: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32
{ "end_col": 60, "end_line": 272, "start_col": 2, "start_line": 272 }
Prims.Tot
val eval_Pextrq (index: nat8) (src: quad32) : option nat64
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CryptoInstructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 ( let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2))))
val eval_Pextrq (index: nat8) (src: quad32) : option nat64 let eval_Pextrq (index: nat8) (src: quad32) : option nat64 =
false
null
false
check_sse4_1 (let src_two = four_to_two_two src in Some (two_to_nat 32 (two_select src_two (index % 2))))
{ "checked_file": "Vale.X64.Instructions_s.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CryptoInstructions_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Instructions_s.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat8", "Vale.X64.Machine_s.quad32", "Vale.X64.Instructions_s.check_sse4_1", "Vale.X64.Machine_s.nat64", "FStar.Pervasives.Native.Some", "Vale.Def.Words.Two_s.two_to_nat", "Vale.Def.Words.Two_s.two_select", "Vale.Def.Words_s.two", "Vale.Def.Types_s.nat32", "Prims.op_Modulus", "Vale.Def.Words_s.nat32", "Vale.Def.Words.Four_s.four_to_two_two", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Instructions_s open FStar.Mul open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Machine_s open Vale.X64.Instruction_s open Vale.X64.CPU_Features_s open Vale.X64.CryptoInstructions_s open FStar.Seq.Base let eval_Mov64 (src:nat64) : option nat64 = Some src val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64 let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64 let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst) val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64 let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst) val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64 let eval_Add64 (dst src:nat64) : option (bool & nat64) = let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64) val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64 let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64) val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64 let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_carry then 1 else 0) in Some (sum >= pow2_64, sum % pow2_64) val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64 let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) = let sum = dst + src + (if old_flag then 1 else 0) in if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64 let eval_Sub64 (dst src:nat64) : option (bool & nat64) = let diff = dst - src in Some (diff < 0, diff % pow2_64) val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64 let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) = let diff = dst - (src + (if old_carry then 1 else 0)) in Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags) val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64 let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) = Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src) val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64 let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) = let hi = FStar.UInt.mul_div #64 rdx src in let lo = FStar.UInt.mul_mod #64 rdx src in if bmi2_enabled then Some (hi, lo) else None val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64 let eval_IMul64 (dst src:nat64) : option nat64 = Some (FStar.UInt.mul_mod #64 dst src) val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64 let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src) val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64 let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) = Some (Vale.Def.Types_s.ixor dst src, (false, false)) val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64 let eval_Shr64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64 let eval_Shl64 (dst amt:nat64) : option nat64 = if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64 let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) = Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx))) val ins_Cpuid : instr_dep [inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)] [] PreserveFlags eval_Cpuid // The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled. // We underspecify XGETBV here to only support fetching XCR0, which // is supported on any processor supporting the XGETBV instruction let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) = if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None val ins_Xgetbv : instr_dep [out (one64Reg rRax); out (one64Reg rRdx)] [one64Reg rRcx] PreserveFlags eval_Xgetbv let check_avx (#a:Type0) (x:option a) : option a = if avx_enabled then x else None let check_sse2 (#a:Type0) (x:option a) : option a = if sse2_enabled then x else None let check_ssse3 (#a:Type0) (x:option a) : option a = if ssse3_enabled then x else None let check_sse4_1 (#a:Type0) (x:option a) : option a = if sse4_1_enabled then x else None let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src) val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src)) val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2)) val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src)) val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand let eval_Paddd_raw (src1 src2:quad32) : option quad32 = Some (Mkfour ((src1.lo0 + src2.lo0) % pow2_32) ((src1.lo1 + src2.lo1) % pow2_32) ((src1.hi2 + src2.hi2) % pow2_32) ((src1.hi3 + src2.hi3) % pow2_32)) let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2) val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2) val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd let eval_Pslld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None) val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt) let eval_Psrld (amt:int) (dst:quad32) : option quad32 = check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None) val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 ( if 0 <= amt && amt < 16 then let src_bytes = le_quad32_to_bytes dst in let zero_pad = Seq.create amt 0 in let remaining_bytes = slice src_bytes amt (length src_bytes) in Some (le_bytes_to_quad32 (append zero_pad remaining_bytes)) else None) val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt) let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if amount = 4 then Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0) else if amount = 8 then Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1) else None let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Palignr_raw amount src1 src2) val ins_Palignr (amount:nat8) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount) let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 = check_avx (eval_Palignr_raw amount src1 src2) val ins_VPalignr (amount:nat8) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount) let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 = if 0 <= permutation && permutation < 4 then Some (Mkfour (if permutation % 2 = 0 then src1.lo0 else src1.hi2) (if permutation % 2 = 0 then src1.lo1 else src1.hi3) (if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2) (if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3)) else None let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_sse2 (eval_Shufpd_raw permutation src1 src2) val ins_Shufpd (permutation:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation) let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 = check_avx (eval_Shufpd_raw permutation src1 src2) val ins_VShufpd (permutation:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation) let is_full_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x04050607 && q.hi3 = 0x00010203 let is_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x00010203 && q.lo1 = 0x04050607 && q.hi2 = 0x08090A0B && q.hi3 = 0x0C0D0E0F let is_high_dup_reversal_mask (q:quad32) : bool = q.lo0 = 0x0C0D0E0F && q.lo1 = 0x08090A0B && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let is_lower_upper_byte_reversal_mask (q:quad32) : bool = q.lo0 = 0x04050607 && q.lo1 = 0x00010203 && q.hi2 = 0x0C0D0E0F && q.hi3 = 0x08090A0B let eval_Pshufb_raw (src1 src2:quad32) : option quad32 = // We only spec a restricted version sufficient for a handful of standard patterns if is_full_byte_reversal_mask src2 then Some (reverse_bytes_quad32 src1) else if is_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3)) else if is_high_dup_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else if is_lower_upper_byte_reversal_mask src2 then Some (Mkfour (reverse_bytes_nat32 src1.lo1) (reverse_bytes_nat32 src1.lo0) (reverse_bytes_nat32 src1.hi3) (reverse_bytes_nat32 src1.hi2)) else None let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2) val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2) val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 ( let bits:bits_of_byte = byte_to_twobits permutation in Some (Mkfour (select_word src bits.lo0) (select_word src bits.lo1) (select_word src bits.hi2) (select_word src bits.hi3))) val ins_Pshufd (permutation:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 ( let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in Some (Mkfour (eq_result (src.lo0 = dst.lo0)) (eq_result (src.lo1 = dst.lo1)) (eq_result (src.hi2 = dst.hi2)) (eq_result (src.hi3 = dst.hi3)))) val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
false
true
Vale.X64.Instructions_s.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_Pextrq (index: nat8) (src: quad32) : option nat64
[]
Vale.X64.Instructions_s.eval_Pextrq
{ "file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
index: Vale.Def.Types_s.nat8 -> src: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.nat64
{ "end_col": 56, "end_line": 264, "start_col": 59, "start_line": 262 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.SecretBox", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_publickey = 32
let size_publickey =
false
null
false
32
{ "checked_file": "Spec.Box.fst.checked", "dependencies": [ "Spec.SecretBox.fst.checked", "Spec.Salsa20.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Box.fst" }
[ "total" ]
[]
[]
module Spec.Box open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.SecretBox #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
false
true
Spec.Box.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size_publickey : Prims.int
[]
Spec.Box.size_publickey
{ "file_name": "specs/Spec.Box.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.int
{ "end_col": 23, "end_line": 13, "start_col": 21, "start_line": 13 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.SecretBox", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_secretkey = 32
let size_secretkey =
false
null
false
32
{ "checked_file": "Spec.Box.fst.checked", "dependencies": [ "Spec.SecretBox.fst.checked", "Spec.Salsa20.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Box.fst" }
[ "total" ]
[]
[]
module Spec.Box open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.SecretBox #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" (* Constants *)
false
true
Spec.Box.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size_secretkey : Prims.int
[]
Spec.Box.size_secretkey
{ "file_name": "specs/Spec.Box.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.int
{ "end_col": 23, "end_line": 14, "start_col": 21, "start_line": 14 }
Prims.Tot
val ecdh (pk: publickey) (sk: secretkey) : option secretkey
[ { "abbrev": false, "full_module": "Spec.SecretBox", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ecdh (pk:publickey) (sk:secretkey) : option secretkey = let shared = Spec.Curve25519.scalarmult sk pk in if not (lbytes_eq shared (create 32 (u8 0))) then Some shared else None
val ecdh (pk: publickey) (sk: secretkey) : option secretkey let ecdh (pk: publickey) (sk: secretkey) : option secretkey =
false
null
false
let shared = Spec.Curve25519.scalarmult sk pk in if not (lbytes_eq shared (create 32 (u8 0))) then Some shared else None
{ "checked_file": "Spec.Box.fst.checked", "dependencies": [ "Spec.SecretBox.fst.checked", "Spec.Salsa20.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Box.fst" }
[ "total" ]
[ "Spec.Box.publickey", "Spec.Box.secretkey", "Prims.op_Negation", "Lib.ByteSequence.lbytes_eq", "Lib.Sequence.create", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.u8", "FStar.Pervasives.Native.Some", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "Spec.Curve25519.serialized_point", "Spec.Curve25519.scalarmult" ]
[]
module Spec.Box open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.SecretBox #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" (* Constants *) let size_publickey = 32 (* in bytes *) let size_secretkey = 32 (* in bytes *) type publickey = lbytes size_publickey type secretkey = lbytes size_secretkey
false
true
Spec.Box.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ecdh (pk: publickey) (sk: secretkey) : option secretkey
[]
Spec.Box.ecdh
{ "file_name": "specs/Spec.Box.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pk: Spec.Box.publickey -> sk: Spec.Box.secretkey -> FStar.Pervasives.Native.option Spec.Box.secretkey
{ "end_col": 11, "end_line": 24, "start_col": 59, "start_line": 20 }
Prims.Tot
val box_beforenm (pk: publickey) (sk: secretkey) : option key
[ { "abbrev": false, "full_module": "Spec.SecretBox", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let box_beforenm (pk:publickey) (sk:secretkey) : option key = let shared = ecdh pk sk in match shared with | Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0))) | None -> None
val box_beforenm (pk: publickey) (sk: secretkey) : option key let box_beforenm (pk: publickey) (sk: secretkey) : option key =
false
null
false
let shared = ecdh pk sk in match shared with | Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0))) | None -> None
{ "checked_file": "Spec.Box.fst.checked", "dependencies": [ "Spec.SecretBox.fst.checked", "Spec.Salsa20.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Box.fst" }
[ "total" ]
[ "Spec.Box.publickey", "Spec.Box.secretkey", "FStar.Pervasives.Native.Some", "Spec.SecretBox.key", "Spec.Salsa20.hsalsa20", "Lib.Sequence.create", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.u8", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "Spec.Box.ecdh" ]
[]
module Spec.Box open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.SecretBox #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" (* Constants *) let size_publickey = 32 (* in bytes *) let size_secretkey = 32 (* in bytes *) type publickey = lbytes size_publickey type secretkey = lbytes size_secretkey let ecdh (pk:publickey) (sk:secretkey) : option secretkey = let shared = Spec.Curve25519.scalarmult sk pk in if not (lbytes_eq shared (create 32 (u8 0))) then Some shared else None
false
true
Spec.Box.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val box_beforenm (pk: publickey) (sk: secretkey) : option key
[]
Spec.Box.box_beforenm
{ "file_name": "specs/Spec.Box.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pk: Spec.Box.publickey -> sk: Spec.Box.secretkey -> FStar.Pervasives.Native.option Spec.SecretBox.key
{ "end_col": 16, "end_line": 31, "start_col": 61, "start_line": 27 }
Prims.Tot
val box_detached_afternm (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : tag & c: bytes{length c = length m}
[ { "abbrev": false, "full_module": "Spec.SecretBox", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} = secretbox_detached k n m
val box_detached_afternm (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : tag & c: bytes{length c = length m} let box_detached_afternm (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : tag & c: bytes{length c = length m} =
false
null
false
secretbox_detached k n m
{ "checked_file": "Spec.Box.fst.checked", "dependencies": [ "Spec.SecretBox.fst.checked", "Spec.Salsa20.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Box.fst" }
[ "total" ]
[ "Spec.SecretBox.key", "Spec.SecretBox.nonce", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Division", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.SecretBox.size_block", "Lib.IntTypes.max_size_t", "Spec.SecretBox.secretbox_detached", "FStar.Pervasives.Native.tuple2", "Spec.SecretBox.tag", "Prims.op_Equality", "Prims.nat" ]
[]
module Spec.Box open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.SecretBox #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" (* Constants *) let size_publickey = 32 (* in bytes *) let size_secretkey = 32 (* in bytes *) type publickey = lbytes size_publickey type secretkey = lbytes size_secretkey let ecdh (pk:publickey) (sk:secretkey) : option secretkey = let shared = Spec.Curve25519.scalarmult sk pk in if not (lbytes_eq shared (create 32 (u8 0))) then Some shared else None let box_beforenm (pk:publickey) (sk:secretkey) : option key = let shared = ecdh pk sk in match shared with | Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0))) | None -> None
false
false
Spec.Box.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val box_detached_afternm (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : tag & c: bytes{length c = length m}
[]
Spec.Box.box_detached_afternm
{ "file_name": "specs/Spec.Box.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.SecretBox.key -> n: Spec.SecretBox.nonce -> m: Lib.ByteSequence.bytes {Lib.Sequence.length m / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t} -> Spec.SecretBox.tag * c: Lib.ByteSequence.bytes{Lib.Sequence.length c = Lib.Sequence.length m}
{ "end_col": 26, "end_line": 35, "start_col": 2, "start_line": 35 }
Prims.Tot
val box_open_detached_afternm (k: key) (n: nonce) (t: tag) (c: bytes{length c / size_block <= max_size_t}) : option (m: bytes{length m = length c})
[ { "abbrev": false, "full_module": "Spec.SecretBox", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let box_open_detached_afternm (k:key) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) = secretbox_open_detached k n t c
val box_open_detached_afternm (k: key) (n: nonce) (t: tag) (c: bytes{length c / size_block <= max_size_t}) : option (m: bytes{length m = length c}) let box_open_detached_afternm (k: key) (n: nonce) (t: tag) (c: bytes{length c / size_block <= max_size_t}) : option (m: bytes{length m = length c}) =
false
null
false
secretbox_open_detached k n t c
{ "checked_file": "Spec.Box.fst.checked", "dependencies": [ "Spec.SecretBox.fst.checked", "Spec.Salsa20.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Box.fst" }
[ "total" ]
[ "Spec.SecretBox.key", "Spec.SecretBox.nonce", "Spec.SecretBox.tag", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Division", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.SecretBox.size_block", "Lib.IntTypes.max_size_t", "Spec.SecretBox.secretbox_open_detached", "FStar.Pervasives.Native.option", "Prims.op_Equality", "Prims.nat" ]
[]
module Spec.Box open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.SecretBox #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" (* Constants *) let size_publickey = 32 (* in bytes *) let size_secretkey = 32 (* in bytes *) type publickey = lbytes size_publickey type secretkey = lbytes size_secretkey let ecdh (pk:publickey) (sk:secretkey) : option secretkey = let shared = Spec.Curve25519.scalarmult sk pk in if not (lbytes_eq shared (create 32 (u8 0))) then Some shared else None let box_beforenm (pk:publickey) (sk:secretkey) : option key = let shared = ecdh pk sk in match shared with | Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0))) | None -> None let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} = secretbox_detached k n m let box_detached (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (tag & c:bytes{length c = length m}) = let k = box_beforenm pk sk in match k with | Some k -> Some (box_detached_afternm k n m) | None -> None
false
false
Spec.Box.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val box_open_detached_afternm (k: key) (n: nonce) (t: tag) (c: bytes{length c / size_block <= max_size_t}) : option (m: bytes{length m = length c})
[]
Spec.Box.box_open_detached_afternm
{ "file_name": "specs/Spec.Box.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.SecretBox.key -> n: Spec.SecretBox.nonce -> t: Spec.SecretBox.tag -> c: Lib.ByteSequence.bytes {Lib.Sequence.length c / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t} -> FStar.Pervasives.Native.option (m: Lib.ByteSequence.bytes{Lib.Sequence.length m = Lib.Sequence.length c})
{ "end_col": 33, "end_line": 46, "start_col": 2, "start_line": 46 }
Prims.Tot
val box_easy_afternm (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : c: bytes{length c = size_tag + length m}
[ { "abbrev": false, "full_module": "Spec.SecretBox", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let box_easy_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : c:bytes{length c = size_tag + length m} = let (tg, c) = box_detached_afternm k n m in Seq.append tg c
val box_easy_afternm (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : c: bytes{length c = size_tag + length m} let box_easy_afternm (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : c: bytes{length c = size_tag + length m} =
false
null
false
let tg, c = box_detached_afternm k n m in Seq.append tg c
{ "checked_file": "Spec.Box.fst.checked", "dependencies": [ "Spec.SecretBox.fst.checked", "Spec.Salsa20.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Box.fst" }
[ "total" ]
[ "Spec.SecretBox.key", "Spec.SecretBox.nonce", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Division", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.SecretBox.size_block", "Lib.IntTypes.max_size_t", "Spec.SecretBox.tag", "Prims.op_Equality", "Prims.nat", "FStar.Seq.Base.append", "Prims.int", "Prims.op_Addition", "Spec.SecretBox.size_tag", "FStar.Pervasives.Native.tuple2", "Lib.Sequence.seq", "Lib.IntTypes.int_t", "Spec.Box.box_detached_afternm" ]
[]
module Spec.Box open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.SecretBox #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" (* Constants *) let size_publickey = 32 (* in bytes *) let size_secretkey = 32 (* in bytes *) type publickey = lbytes size_publickey type secretkey = lbytes size_secretkey let ecdh (pk:publickey) (sk:secretkey) : option secretkey = let shared = Spec.Curve25519.scalarmult sk pk in if not (lbytes_eq shared (create 32 (u8 0))) then Some shared else None let box_beforenm (pk:publickey) (sk:secretkey) : option key = let shared = ecdh pk sk in match shared with | Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0))) | None -> None let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} = secretbox_detached k n m let box_detached (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (tag & c:bytes{length c = length m}) = let k = box_beforenm pk sk in match k with | Some k -> Some (box_detached_afternm k n m) | None -> None let box_open_detached_afternm (k:key) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) = secretbox_open_detached k n t c let box_open_detached (pk:publickey) (sk:secretkey) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) = let k = box_beforenm pk sk in match k with | Some k -> box_open_detached_afternm k n t c | None -> None
false
false
Spec.Box.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val box_easy_afternm (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : c: bytes{length c = size_tag + length m}
[]
Spec.Box.box_easy_afternm
{ "file_name": "specs/Spec.Box.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.SecretBox.key -> n: Spec.SecretBox.nonce -> m: Lib.ByteSequence.bytes {Lib.Sequence.length m / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t} -> c: Lib.ByteSequence.bytes{Lib.Sequence.length c = Spec.SecretBox.size_tag + Lib.Sequence.length m}
{ "end_col": 17, "end_line": 58, "start_col": 129, "start_line": 56 }
Prims.Tot
val box_open_detached (pk: publickey) (sk: secretkey) (n: nonce) (t: tag) (c: bytes{length c / size_block <= max_size_t}) : option (m: bytes{length m = length c})
[ { "abbrev": false, "full_module": "Spec.SecretBox", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let box_open_detached (pk:publickey) (sk:secretkey) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) = let k = box_beforenm pk sk in match k with | Some k -> box_open_detached_afternm k n t c | None -> None
val box_open_detached (pk: publickey) (sk: secretkey) (n: nonce) (t: tag) (c: bytes{length c / size_block <= max_size_t}) : option (m: bytes{length m = length c}) let box_open_detached (pk: publickey) (sk: secretkey) (n: nonce) (t: tag) (c: bytes{length c / size_block <= max_size_t}) : option (m: bytes{length m = length c}) =
false
null
false
let k = box_beforenm pk sk in match k with | Some k -> box_open_detached_afternm k n t c | None -> None
{ "checked_file": "Spec.Box.fst.checked", "dependencies": [ "Spec.SecretBox.fst.checked", "Spec.Salsa20.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Box.fst" }
[ "total" ]
[ "Spec.Box.publickey", "Spec.Box.secretkey", "Spec.SecretBox.nonce", "Spec.SecretBox.tag", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Division", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.SecretBox.size_block", "Lib.IntTypes.max_size_t", "Spec.SecretBox.key", "Spec.Box.box_open_detached_afternm", "FStar.Pervasives.Native.None", "Prims.op_Equality", "Prims.nat", "FStar.Pervasives.Native.option", "Spec.Box.box_beforenm" ]
[]
module Spec.Box open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.SecretBox #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" (* Constants *) let size_publickey = 32 (* in bytes *) let size_secretkey = 32 (* in bytes *) type publickey = lbytes size_publickey type secretkey = lbytes size_secretkey let ecdh (pk:publickey) (sk:secretkey) : option secretkey = let shared = Spec.Curve25519.scalarmult sk pk in if not (lbytes_eq shared (create 32 (u8 0))) then Some shared else None let box_beforenm (pk:publickey) (sk:secretkey) : option key = let shared = ecdh pk sk in match shared with | Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0))) | None -> None let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} = secretbox_detached k n m let box_detached (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (tag & c:bytes{length c = length m}) = let k = box_beforenm pk sk in match k with | Some k -> Some (box_detached_afternm k n m) | None -> None let box_open_detached_afternm (k:key) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) = secretbox_open_detached k n t c
false
false
Spec.Box.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val box_open_detached (pk: publickey) (sk: secretkey) (n: nonce) (t: tag) (c: bytes{length c / size_block <= max_size_t}) : option (m: bytes{length m = length c})
[]
Spec.Box.box_open_detached
{ "file_name": "specs/Spec.Box.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pk: Spec.Box.publickey -> sk: Spec.Box.secretkey -> n: Spec.SecretBox.nonce -> t: Spec.SecretBox.tag -> c: Lib.ByteSequence.bytes {Lib.Sequence.length c / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t} -> FStar.Pervasives.Native.option (m: Lib.ByteSequence.bytes{Lib.Sequence.length m = Lib.Sequence.length c})
{ "end_col": 16, "end_line": 53, "start_col": 158, "start_line": 49 }
Prims.Tot
val box_detached (sk: secretkey) (pk: publickey) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : option (tag & c: bytes{length c = length m})
[ { "abbrev": false, "full_module": "Spec.SecretBox", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let box_detached (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (tag & c:bytes{length c = length m}) = let k = box_beforenm pk sk in match k with | Some k -> Some (box_detached_afternm k n m) | None -> None
val box_detached (sk: secretkey) (pk: publickey) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : option (tag & c: bytes{length c = length m}) let box_detached (sk: secretkey) (pk: publickey) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : option (tag & c: bytes{length c = length m}) =
false
null
false
let k = box_beforenm pk sk in match k with | Some k -> Some (box_detached_afternm k n m) | None -> None
{ "checked_file": "Spec.Box.fst.checked", "dependencies": [ "Spec.SecretBox.fst.checked", "Spec.Salsa20.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Box.fst" }
[ "total" ]
[ "Spec.Box.secretkey", "Spec.Box.publickey", "Spec.SecretBox.nonce", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Division", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.SecretBox.size_block", "Lib.IntTypes.max_size_t", "Spec.SecretBox.key", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "Spec.SecretBox.tag", "Prims.op_Equality", "Prims.nat", "Spec.Box.box_detached_afternm", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "Spec.Box.box_beforenm" ]
[]
module Spec.Box open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.SecretBox #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" (* Constants *) let size_publickey = 32 (* in bytes *) let size_secretkey = 32 (* in bytes *) type publickey = lbytes size_publickey type secretkey = lbytes size_secretkey let ecdh (pk:publickey) (sk:secretkey) : option secretkey = let shared = Spec.Curve25519.scalarmult sk pk in if not (lbytes_eq shared (create 32 (u8 0))) then Some shared else None let box_beforenm (pk:publickey) (sk:secretkey) : option key = let shared = ecdh pk sk in match shared with | Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0))) | None -> None let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} = secretbox_detached k n m
false
false
Spec.Box.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val box_detached (sk: secretkey) (pk: publickey) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : option (tag & c: bytes{length c = length m})
[]
Spec.Box.box_detached
{ "file_name": "specs/Spec.Box.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
sk: Spec.Box.secretkey -> pk: Spec.Box.publickey -> n: Spec.SecretBox.nonce -> m: Lib.ByteSequence.bytes {Lib.Sequence.length m / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t} -> FStar.Pervasives.Native.option (Spec.SecretBox.tag * c: Lib.ByteSequence.bytes{Lib.Sequence.length c = Lib.Sequence.length m})
{ "end_col": 16, "end_line": 42, "start_col": 151, "start_line": 38 }
Prims.Tot
val box_easy (sk: secretkey) (pk: publickey) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : option (c: bytes{length c = size_tag + length m})
[ { "abbrev": false, "full_module": "Spec.SecretBox", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let box_easy (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (c:bytes{length c = size_tag + length m}) = let r = box_detached sk pk n m in match r with | Some (tg, c) -> Some (Seq.append tg c) | None -> None
val box_easy (sk: secretkey) (pk: publickey) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : option (c: bytes{length c = size_tag + length m}) let box_easy (sk: secretkey) (pk: publickey) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : option (c: bytes{length c = size_tag + length m}) =
false
null
false
let r = box_detached sk pk n m in match r with | Some (tg, c) -> Some (Seq.append tg c) | None -> None
{ "checked_file": "Spec.Box.fst.checked", "dependencies": [ "Spec.SecretBox.fst.checked", "Spec.Salsa20.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Box.fst" }
[ "total" ]
[ "Spec.Box.secretkey", "Spec.Box.publickey", "Spec.SecretBox.nonce", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Division", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.SecretBox.size_block", "Lib.IntTypes.max_size_t", "Spec.SecretBox.tag", "Prims.op_Equality", "Prims.nat", "FStar.Pervasives.Native.Some", "Prims.int", "Prims.op_Addition", "Spec.SecretBox.size_tag", "FStar.Seq.Base.append", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "Lib.Sequence.seq", "Lib.IntTypes.int_t", "Spec.Box.box_detached" ]
[]
module Spec.Box open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.SecretBox #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" (* Constants *) let size_publickey = 32 (* in bytes *) let size_secretkey = 32 (* in bytes *) type publickey = lbytes size_publickey type secretkey = lbytes size_secretkey let ecdh (pk:publickey) (sk:secretkey) : option secretkey = let shared = Spec.Curve25519.scalarmult sk pk in if not (lbytes_eq shared (create 32 (u8 0))) then Some shared else None let box_beforenm (pk:publickey) (sk:secretkey) : option key = let shared = ecdh pk sk in match shared with | Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0))) | None -> None let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} = secretbox_detached k n m let box_detached (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (tag & c:bytes{length c = length m}) = let k = box_beforenm pk sk in match k with | Some k -> Some (box_detached_afternm k n m) | None -> None let box_open_detached_afternm (k:key) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) = secretbox_open_detached k n t c let box_open_detached (pk:publickey) (sk:secretkey) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) = let k = box_beforenm pk sk in match k with | Some k -> box_open_detached_afternm k n t c | None -> None let box_easy_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : c:bytes{length c = size_tag + length m} = let (tg, c) = box_detached_afternm k n m in Seq.append tg c
false
false
Spec.Box.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val box_easy (sk: secretkey) (pk: publickey) (n: nonce) (m: bytes{length m / size_block <= max_size_t}) : option (c: bytes{length c = size_tag + length m})
[]
Spec.Box.box_easy
{ "file_name": "specs/Spec.Box.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
sk: Spec.Box.secretkey -> pk: Spec.Box.publickey -> n: Spec.SecretBox.nonce -> m: Lib.ByteSequence.bytes {Lib.Sequence.length m / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t} -> FStar.Pervasives.Native.option (c: Lib.ByteSequence.bytes {Lib.Sequence.length c = Spec.SecretBox.size_tag + Lib.Sequence.length m})
{ "end_col": 16, "end_line": 65, "start_col": 152, "start_line": 61 }
Prims.Tot
val box_open_easy_afternm (k: key) (n: nonce) (c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t}) : option (m: bytes{length m = length c - size_tag})
[ { "abbrev": false, "full_module": "Spec.SecretBox", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let box_open_easy_afternm (k:key) (n:nonce) (c:bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t}) : option (m:bytes{length m = length c - size_tag}) = let tg = Seq.slice c 0 size_tag in let e = Seq.slice c size_tag (length c) in box_open_detached_afternm k n tg e
val box_open_easy_afternm (k: key) (n: nonce) (c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t}) : option (m: bytes{length m = length c - size_tag}) let box_open_easy_afternm (k: key) (n: nonce) (c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t}) : option (m: bytes{length m = length c - size_tag}) =
false
null
false
let tg = Seq.slice c 0 size_tag in let e = Seq.slice c size_tag (length c) in box_open_detached_afternm k n tg e
{ "checked_file": "Spec.Box.fst.checked", "dependencies": [ "Spec.SecretBox.fst.checked", "Spec.Salsa20.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Box.fst" }
[ "total" ]
[ "Spec.SecretBox.key", "Spec.SecretBox.nonce", "Lib.ByteSequence.bytes", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.SecretBox.size_tag", "Prims.op_LessThanOrEqual", "Prims.op_Division", "Prims.op_Subtraction", "Spec.SecretBox.size_block", "Lib.IntTypes.max_size_t", "Spec.Box.box_open_detached_afternm", "FStar.Seq.Base.seq", "Lib.IntTypes.int_t", "FStar.Seq.Base.slice", "FStar.Pervasives.Native.option", "Prims.op_Equality", "Prims.int" ]
[]
module Spec.Box open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.SecretBox #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" (* Constants *) let size_publickey = 32 (* in bytes *) let size_secretkey = 32 (* in bytes *) type publickey = lbytes size_publickey type secretkey = lbytes size_secretkey let ecdh (pk:publickey) (sk:secretkey) : option secretkey = let shared = Spec.Curve25519.scalarmult sk pk in if not (lbytes_eq shared (create 32 (u8 0))) then Some shared else None let box_beforenm (pk:publickey) (sk:secretkey) : option key = let shared = ecdh pk sk in match shared with | Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0))) | None -> None let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} = secretbox_detached k n m let box_detached (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (tag & c:bytes{length c = length m}) = let k = box_beforenm pk sk in match k with | Some k -> Some (box_detached_afternm k n m) | None -> None let box_open_detached_afternm (k:key) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) = secretbox_open_detached k n t c let box_open_detached (pk:publickey) (sk:secretkey) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) = let k = box_beforenm pk sk in match k with | Some k -> box_open_detached_afternm k n t c | None -> None let box_easy_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : c:bytes{length c = size_tag + length m} = let (tg, c) = box_detached_afternm k n m in Seq.append tg c let box_easy (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (c:bytes{length c = size_tag + length m}) = let r = box_detached sk pk n m in match r with | Some (tg, c) -> Some (Seq.append tg c) | None -> None
false
false
Spec.Box.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val box_open_easy_afternm (k: key) (n: nonce) (c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t}) : option (m: bytes{length m = length c - size_tag})
[]
Spec.Box.box_open_easy_afternm
{ "file_name": "specs/Spec.Box.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.SecretBox.key -> n: Spec.SecretBox.nonce -> c: Lib.ByteSequence.bytes { Lib.Sequence.length c >= Spec.SecretBox.size_tag /\ (Lib.Sequence.length c - Spec.SecretBox.size_tag) / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t } -> FStar.Pervasives.Native.option (m: Lib.ByteSequence.bytes {Lib.Sequence.length m = Lib.Sequence.length c - Spec.SecretBox.size_tag})
{ "end_col": 36, "end_line": 71, "start_col": 180, "start_line": 68 }
Prims.Tot
val box_open_easy (pk: secretkey) (sk: publickey) (n: nonce) (c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t}) : option (m: bytes{length m = length c - size_tag})
[ { "abbrev": false, "full_module": "Spec.SecretBox", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let box_open_easy (pk:secretkey) (sk:publickey) (n:nonce) (c:bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t}) : option (m:bytes{length m = length c - size_tag}) = let tg = Seq.slice c 0 size_tag in let e = Seq.slice c size_tag (length c) in box_open_detached pk sk n tg e
val box_open_easy (pk: secretkey) (sk: publickey) (n: nonce) (c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t}) : option (m: bytes{length m = length c - size_tag}) let box_open_easy (pk: secretkey) (sk: publickey) (n: nonce) (c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t}) : option (m: bytes{length m = length c - size_tag}) =
false
null
false
let tg = Seq.slice c 0 size_tag in let e = Seq.slice c size_tag (length c) in box_open_detached pk sk n tg e
{ "checked_file": "Spec.Box.fst.checked", "dependencies": [ "Spec.SecretBox.fst.checked", "Spec.Salsa20.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Box.fst" }
[ "total" ]
[ "Spec.Box.secretkey", "Spec.Box.publickey", "Spec.SecretBox.nonce", "Lib.ByteSequence.bytes", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.SecretBox.size_tag", "Prims.op_LessThanOrEqual", "Prims.op_Division", "Prims.op_Subtraction", "Spec.SecretBox.size_block", "Lib.IntTypes.max_size_t", "Spec.Box.box_open_detached", "FStar.Seq.Base.seq", "Lib.IntTypes.int_t", "FStar.Seq.Base.slice", "FStar.Pervasives.Native.option", "Prims.op_Equality", "Prims.int" ]
[]
module Spec.Box open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.SecretBox #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" (* Constants *) let size_publickey = 32 (* in bytes *) let size_secretkey = 32 (* in bytes *) type publickey = lbytes size_publickey type secretkey = lbytes size_secretkey let ecdh (pk:publickey) (sk:secretkey) : option secretkey = let shared = Spec.Curve25519.scalarmult sk pk in if not (lbytes_eq shared (create 32 (u8 0))) then Some shared else None let box_beforenm (pk:publickey) (sk:secretkey) : option key = let shared = ecdh pk sk in match shared with | Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0))) | None -> None let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} = secretbox_detached k n m let box_detached (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (tag & c:bytes{length c = length m}) = let k = box_beforenm pk sk in match k with | Some k -> Some (box_detached_afternm k n m) | None -> None let box_open_detached_afternm (k:key) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) = secretbox_open_detached k n t c let box_open_detached (pk:publickey) (sk:secretkey) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) = let k = box_beforenm pk sk in match k with | Some k -> box_open_detached_afternm k n t c | None -> None let box_easy_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : c:bytes{length c = size_tag + length m} = let (tg, c) = box_detached_afternm k n m in Seq.append tg c let box_easy (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (c:bytes{length c = size_tag + length m}) = let r = box_detached sk pk n m in match r with | Some (tg, c) -> Some (Seq.append tg c) | None -> None let box_open_easy_afternm (k:key) (n:nonce) (c:bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t}) : option (m:bytes{length m = length c - size_tag}) = let tg = Seq.slice c 0 size_tag in let e = Seq.slice c size_tag (length c) in box_open_detached_afternm k n tg e
false
false
Spec.Box.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val box_open_easy (pk: secretkey) (sk: publickey) (n: nonce) (c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t}) : option (m: bytes{length m = length c - size_tag})
[]
Spec.Box.box_open_easy
{ "file_name": "specs/Spec.Box.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pk: Spec.Box.secretkey -> sk: Spec.Box.publickey -> n: Spec.SecretBox.nonce -> c: Lib.ByteSequence.bytes { Lib.Sequence.length c >= Spec.SecretBox.size_tag /\ (Lib.Sequence.length c - Spec.SecretBox.size_tag) / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t } -> FStar.Pervasives.Native.option (m: Lib.ByteSequence.bytes {Lib.Sequence.length m = Lib.Sequence.length c - Spec.SecretBox.size_tag})
{ "end_col": 32, "end_line": 77, "start_col": 194, "start_line": 74 }
Prims.Tot
val serialize32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (sz: nat{sz < 4294967296}) : Tot (serializer32 (serialize_fldata_strong s sz))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": 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 serialize32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_fldata_strong s sz)) = (fun (input: parse_fldata_strong_t s sz) -> s32 input)
val serialize32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (sz: nat{sz < 4294967296}) : Tot (serializer32 (serialize_fldata_strong s sz)) let serialize32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (sz: nat{sz < 4294967296}) : Tot (serializer32 (serialize_fldata_strong s sz)) =
false
null
false
(fun (input: parse_fldata_strong_t s sz) -> s32 input)
{ "checked_file": "LowParse.SLow.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.partial_serializer32", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "LowParse.Spec.FLData.parse_fldata_strong_t", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata_strong", "LowParse.Spec.FLData.serialize_fldata_strong", "LowParse.SLow.Base.serializer32" ]
[]
module LowParse.SLow.FLData include LowParse.Spec.FLData include LowParse.SLow.Combinators module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 inline_for_extraction let parse32_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (parser32 (parse_fldata p sz)) = (fun (input: bytes32) -> (( if U32.lt (B32.len input) sz32 then None else match p32 (B32.b32slice input 0ul sz32) with | Some (v, consumed) -> if consumed = sz32 then begin Some (v, consumed) end else None | None -> None ) <: (res: option (t * U32.t) { parser32_correct (parse_fldata p sz) input res } ))) inline_for_extraction let parse32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (parser32 (parse_fldata_strong s sz)) = (fun (input: bytes32) -> (( match parse32_fldata p32 sz sz32 input with | Some (v, consumed) -> assert ( parse_fldata_strong_correct s sz (B32.reveal input) (U32.v consumed) v; Seq.length (s v) == sz ); Some ((v <: parse_fldata_strong_t s sz), consumed) | None -> None ) <: (res: option (parse_fldata_strong_t s sz * U32.t) { parser32_correct (parse_fldata_strong s sz) input res } ))) inline_for_extraction let serialize32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (sz: nat { sz < 4294967296 } )
false
false
LowParse.SLow.FLData.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 serialize32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (sz: nat{sz < 4294967296}) : Tot (serializer32 (serialize_fldata_strong s sz))
[]
LowParse.SLow.FLData.serialize32_fldata_strong
{ "file_name": "src/lowparse/LowParse.SLow.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s32: LowParse.SLow.Base.partial_serializer32 s -> sz: Prims.nat{sz < 4294967296} -> LowParse.SLow.Base.serializer32 (LowParse.Spec.FLData.serialize_fldata_strong s sz)
{ "end_col": 56, "end_line": 62, "start_col": 2, "start_line": 62 }
Prims.Tot
val size32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (size32 (serialize_fldata_strong s sz))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": 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 size32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (size32 (serialize_fldata_strong s sz)) = size32_constant (serialize_fldata_strong s sz) sz32 ()
val size32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (size32 (serialize_fldata_strong s sz)) let size32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (size32 (serialize_fldata_strong s sz)) =
false
null
false
size32_constant (serialize_fldata_strong s sz) sz32 ()
{ "checked_file": "LowParse.SLow.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "LowParse.SLow.Base.size32_constant", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata_strong_t", "LowParse.Spec.FLData.parse_fldata_strong", "LowParse.Spec.FLData.serialize_fldata_strong", "LowParse.SLow.Base.size32" ]
[]
module LowParse.SLow.FLData include LowParse.Spec.FLData include LowParse.SLow.Combinators module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 inline_for_extraction let parse32_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (parser32 (parse_fldata p sz)) = (fun (input: bytes32) -> (( if U32.lt (B32.len input) sz32 then None else match p32 (B32.b32slice input 0ul sz32) with | Some (v, consumed) -> if consumed = sz32 then begin Some (v, consumed) end else None | None -> None ) <: (res: option (t * U32.t) { parser32_correct (parse_fldata p sz) input res } ))) inline_for_extraction let parse32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (parser32 (parse_fldata_strong s sz)) = (fun (input: bytes32) -> (( match parse32_fldata p32 sz sz32 input with | Some (v, consumed) -> assert ( parse_fldata_strong_correct s sz (B32.reveal input) (U32.v consumed) v; Seq.length (s v) == sz ); Some ((v <: parse_fldata_strong_t s sz), consumed) | None -> None ) <: (res: option (parse_fldata_strong_t s sz * U32.t) { parser32_correct (parse_fldata_strong s sz) input res } ))) inline_for_extraction let serialize32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_fldata_strong s sz)) = (fun (input: parse_fldata_strong_t s sz) -> s32 input) inline_for_extraction let size32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } )
false
false
LowParse.SLow.FLData.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 size32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (size32 (serialize_fldata_strong s sz))
[]
LowParse.SLow.FLData.size32_fldata_strong
{ "file_name": "src/lowparse/LowParse.SLow.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.Base.serializer p -> sz: Prims.nat -> sz32: FStar.UInt32.t{FStar.UInt32.v sz32 == sz} -> LowParse.SLow.Base.size32 (LowParse.Spec.FLData.serialize_fldata_strong s sz)
{ "end_col": 56, "end_line": 73, "start_col": 2, "start_line": 73 }
Prims.Tot
val parse32_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (parser32 (parse_fldata p sz))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": 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 parse32_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (parser32 (parse_fldata p sz)) = (fun (input: bytes32) -> (( if U32.lt (B32.len input) sz32 then None else match p32 (B32.b32slice input 0ul sz32) with | Some (v, consumed) -> if consumed = sz32 then begin Some (v, consumed) end else None | None -> None ) <: (res: option (t * U32.t) { parser32_correct (parse_fldata p sz) input res } )))
val parse32_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (parser32 (parse_fldata p sz)) let parse32_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (parser32 (parse_fldata p sz)) =
false
null
false
(fun (input: bytes32) -> ((if U32.lt (B32.len input) sz32 then None else match p32 (B32.b32slice input 0ul sz32) with | Some (v, consumed) -> if consumed = sz32 then Some (v, consumed) else None | None -> None) <: (res: option (t * U32.t) {parser32_correct (parse_fldata p sz) input res})))
{ "checked_file": "LowParse.SLow.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "LowParse.SLow.Base.bytes32", "FStar.UInt32.lt", "FStar.Bytes.len", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.tuple2", "Prims.bool", "LowParse.Bytes32.b32slice", "FStar.UInt32.__uint_to_t", "Prims.op_Equality", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.option", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata" ]
[]
module LowParse.SLow.FLData include LowParse.Spec.FLData include LowParse.SLow.Combinators module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 inline_for_extraction let parse32_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } )
false
false
LowParse.SLow.FLData.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 parse32_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (parser32 (parse_fldata p sz))
[]
LowParse.SLow.FLData.parse32_fldata
{ "file_name": "src/lowparse/LowParse.SLow.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p32: LowParse.SLow.Base.parser32 p -> sz: Prims.nat -> sz32: FStar.UInt32.t{FStar.UInt32.v sz32 == sz} -> LowParse.SLow.Base.parser32 (LowParse.Spec.FLData.parse_fldata p sz)
{ "end_col": 86, "end_line": 29, "start_col": 2, "start_line": 17 }
Prims.Tot
val parse32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (parser32 (parse_fldata_strong s sz))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": 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 parse32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (parser32 (parse_fldata_strong s sz)) = (fun (input: bytes32) -> (( match parse32_fldata p32 sz sz32 input with | Some (v, consumed) -> assert ( parse_fldata_strong_correct s sz (B32.reveal input) (U32.v consumed) v; Seq.length (s v) == sz ); Some ((v <: parse_fldata_strong_t s sz), consumed) | None -> None ) <: (res: option (parse_fldata_strong_t s sz * U32.t) { parser32_correct (parse_fldata_strong s sz) input res } )))
val parse32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (parser32 (parse_fldata_strong s sz)) let parse32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (parser32 (parse_fldata_strong s sz)) =
false
null
false
(fun (input: bytes32) -> ((match parse32_fldata p32 sz sz32 input with | Some (v, consumed) -> assert (parse_fldata_strong_correct s sz (B32.reveal input) (U32.v consumed) v; Seq.length (s v) == sz); Some ((v <: parse_fldata_strong_t s sz), consumed) | None -> None) <: (res: option (parse_fldata_strong_t s sz * U32.t) {parser32_correct (parse_fldata_strong s sz) input res})))
{ "checked_file": "LowParse.SLow.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.parser32", "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "LowParse.SLow.Base.bytes32", "LowParse.SLow.FLData.parse32_fldata", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.FLData.parse_fldata_strong_t", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "Prims._assert", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "LowParse.Spec.FLData.parse_fldata_strong_correct", "FStar.Bytes.reveal", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata_strong" ]
[]
module LowParse.SLow.FLData include LowParse.Spec.FLData include LowParse.SLow.Combinators module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 inline_for_extraction let parse32_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (parser32 (parse_fldata p sz)) = (fun (input: bytes32) -> (( if U32.lt (B32.len input) sz32 then None else match p32 (B32.b32slice input 0ul sz32) with | Some (v, consumed) -> if consumed = sz32 then begin Some (v, consumed) end else None | None -> None ) <: (res: option (t * U32.t) { parser32_correct (parse_fldata p sz) input res } ))) inline_for_extraction let parse32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } )
false
false
LowParse.SLow.FLData.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 parse32_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (parser32 (parse_fldata_strong s sz))
[]
LowParse.SLow.FLData.parse32_fldata_strong
{ "file_name": "src/lowparse/LowParse.SLow.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.Base.serializer p -> p32: LowParse.SLow.Base.parser32 p -> sz: Prims.nat -> sz32: FStar.UInt32.t{FStar.UInt32.v sz32 == sz} -> LowParse.SLow.Base.parser32 (LowParse.Spec.FLData.parse_fldata_strong s sz)
{ "end_col": 118, "end_line": 51, "start_col": 2, "start_line": 41 }
Prims.Tot
val pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: a) : vprop
[ { "abbrev": false, "full_module": "FStar.Real", "short_module": null }, { "abbrev": true, "full_module": "Steel.Effect.Atomic", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.GhostPCMReference", "short_module": "PR" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "M" }, { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "Q" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Preorder", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.GhostPCMReference", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let pts_to (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a) : vprop = to_vprop (pts_to_sl r f v)
val pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: a) : vprop let pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: a) : vprop =
false
null
false
to_vprop (pts_to_sl r f v)
{ "checked_file": "Steel.GhostMonotonicHigherReference.fsti.checked", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.GhostMonotonicHigherReference.fsti" }
[ "total" ]
[ "FStar.Preorder.preorder", "Steel.GhostMonotonicHigherReference.ref", "Steel.FractionalPermission.perm", "Steel.Effect.Common.to_vprop", "Steel.GhostMonotonicHigherReference.pts_to_sl", "Steel.Effect.Common.vprop" ]
[]
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.GhostMonotonicHigherReference open FStar.PCM open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module Preorder = FStar.Preorder /// A library for Steel references that are monotonic with respect to a user-specified preorder. /// This library builds on top of Steel.HigherReference, and is specialized to values at universe 1. /// An abstract datatype for monotonic references [@@erasable] val ref (a:Type u#1) (p:Preorder.preorder a) : Type u#0 /// The standard points to separation logic predicate val pts_to_sl (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector [@@ __steel_reduce__]
false
false
Steel.GhostMonotonicHigherReference.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 pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: a) : vprop
[]
Steel.GhostMonotonicHigherReference.pts_to
{ "file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.GhostMonotonicHigherReference.ref a p -> f: Steel.FractionalPermission.perm -> v: a -> Steel.Effect.Common.vprop
{ "end_col": 28, "end_line": 44, "start_col": 2, "start_line": 44 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Real", "short_module": null }, { "abbrev": true, "full_module": "Steel.Effect.Atomic", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.GhostPCMReference", "short_module": "PR" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "M" }, { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "Q" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Preorder", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.GhostPCMReference", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let property (a:Type) = a -> prop
let property (a: Type) =
false
null
false
a -> prop
{ "checked_file": "Steel.GhostMonotonicHigherReference.fsti.checked", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.GhostMonotonicHigherReference.fsti" }
[ "total" ]
[ "Prims.prop" ]
[]
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.GhostMonotonicHigherReference open FStar.PCM open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module Preorder = FStar.Preorder /// A library for Steel references that are monotonic with respect to a user-specified preorder. /// This library builds on top of Steel.HigherReference, and is specialized to values at universe 1. /// An abstract datatype for monotonic references [@@erasable] val ref (a:Type u#1) (p:Preorder.preorder a) : Type u#0 /// The standard points to separation logic predicate val pts_to_sl (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector [@@ __steel_reduce__] unfold let pts_to (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a) : vprop = to_vprop (pts_to_sl r f v) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc (#opened: _) (#a:Type) (p:Preorder.preorder a) (v:a) : SteelGhostT (ref a p) opened emp (fun r -> pts_to r full_perm v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write (#opened: _) (#a:Type) (#p:Preorder.preorder a) (#v:a) (r:ref a p) (x:a) : SteelGhost unit opened (pts_to r full_perm v) (fun v -> pts_to r full_perm x) (requires fun _ -> p v x /\ True) (ensures fun _ _ _ -> True) /// A wrapper around a predicate that depends on a value of type [a]
false
true
Steel.GhostMonotonicHigherReference.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 property : a: Type -> Type
[]
Steel.GhostMonotonicHigherReference.property
{ "file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Type -> Type
{ "end_col": 13, "end_line": 61, "start_col": 4, "start_line": 61 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Real", "short_module": null }, { "abbrev": true, "full_module": "Steel.Effect.Atomic", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.GhostPCMReference", "short_module": "PR" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "M" }, { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "Q" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Preorder", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.GhostPCMReference", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let stable_property (#a:Type) (p:Preorder.preorder a) = fact:property a { Preorder.stable fact p }
let stable_property (#a: Type) (p: Preorder.preorder a) =
false
null
false
fact: property a {Preorder.stable fact p}
{ "checked_file": "Steel.GhostMonotonicHigherReference.fsti.checked", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.GhostMonotonicHigherReference.fsti" }
[ "total" ]
[ "FStar.Preorder.preorder", "Steel.GhostMonotonicHigherReference.property", "FStar.Preorder.stable" ]
[]
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.GhostMonotonicHigherReference open FStar.PCM open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module Preorder = FStar.Preorder /// A library for Steel references that are monotonic with respect to a user-specified preorder. /// This library builds on top of Steel.HigherReference, and is specialized to values at universe 1. /// An abstract datatype for monotonic references [@@erasable] val ref (a:Type u#1) (p:Preorder.preorder a) : Type u#0 /// The standard points to separation logic predicate val pts_to_sl (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector [@@ __steel_reduce__] unfold let pts_to (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a) : vprop = to_vprop (pts_to_sl r f v) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc (#opened: _) (#a:Type) (p:Preorder.preorder a) (v:a) : SteelGhostT (ref a p) opened emp (fun r -> pts_to r full_perm v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write (#opened: _) (#a:Type) (#p:Preorder.preorder a) (#v:a) (r:ref a p) (x:a) : SteelGhost unit opened (pts_to r full_perm v) (fun v -> pts_to r full_perm x) (requires fun _ -> p v x /\ True) (ensures fun _ _ _ -> True) /// A wrapper around a predicate that depends on a value of type [a] let property (a:Type) = a -> prop /// A wrapper around a property [fact] that has been witnessed to be true and stable /// with respect to preorder [p] val witnessed (#a:Type u#1) (#p:Preorder.preorder a) (r:ref a p) (fact:property a) : Type0 /// The type of properties depending on values of type [a], and that /// are stable with respect to the preorder [p]
false
false
Steel.GhostMonotonicHigherReference.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 stable_property : p: FStar.Preorder.preorder a -> Type
[]
Steel.GhostMonotonicHigherReference.stable_property
{ "file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: FStar.Preorder.preorder a -> Type
{ "end_col": 46, "end_line": 71, "start_col": 4, "start_line": 71 }
Prims.GTot
val deref_data (#a: _) (h: HS.mem) (c: B.pointer (cell a)) : GTot a
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a = (B.deref h c).data
val deref_data (#a: _) (h: HS.mem) (c: B.pointer (cell a)) : GTot a let deref_data #a (h: HS.mem) (c: B.pointer (cell a)) : GTot a =
false
null
false
(B.deref h c).data
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[ "sometrivial" ]
[ "FStar.Monotonic.HyperStack.mem", "LowStar.Buffer.pointer", "LowStar.Lib.LinkedList.cell", "LowStar.Lib.LinkedList.__proj__Mkcell__item__data", "LowStar.Monotonic.Buffer.deref", "LowStar.Buffer.trivial_preorder" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let invariant #a h l n = cells_live_freeable h l n /\ cells_pairwise_disjoint h l n /// Normally this would be automatic and writing a custom lemma for that stuff /// would be needed only when writing an fsti, however, as stated earlier, /// recursion makes everything more difficult and this absolutely needs to be in /// scope otherwise the modifies-clause theory cannot deduce disjointness of /// fresh allocations w.r.t. the footprint. let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [ SMTPat (invariant h l n) ] = if B.g_is_null l then () else let next = (B.deref h l).next in invariant_loc_in_footprint h next (L.tl n) /// Another absolutely essential lemma, for which interestingly the pattern /// "invariant h1 l n" does not work, but well_formed does... I guess that's /// alright. let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma (requires ( well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1 )) (ensures ( well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n )) (decreases n) [ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ] = if B.g_is_null l then () else frame (B.deref h0 l).next (L.tl n) r h0 h1 /// Lemmas for working with linked lists /// ------------------------------------ /// /// Since it's a recursive data structure, a lot of the automated reasoning from /// LowStar.Buffer doesn't work since it requires inductions. Some helpful /// properties are therefore proved here. let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a): Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] = if B.g_is_null c then () else let { next=next } = B.get h c 0 in length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2)) /// The footprint is based on loc_addr_of_buffer so that we can write a free /// operation that operates on the footprint. However, this invalidates most of /// the helper lemmas for disjointness that were present in the previous /// iteration of this module, named LinkedList4.fst. It's ok, we bake /// disjointness directly onto the invariant and it works just as well. /// Connection between ``cells`` and ``v`` /// -------------------------------------- /// Redefining some helpers. #push-options "--ifuel 1" let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) = match xs with | [] -> [] | x :: xs -> f x :: gmap f xs /// "As we all know", right folds are the easiest to work with because they /// follow the natural structure of recursion (left-folds are evil). let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b (requires True) (ensures fun _ -> True) (decreases xs) = match xs with | [] -> acc | x :: xs -> f (gfold_right f xs acc) x #pop-options /// Connecting ``v`` and ``cells``. /// /// See ``tests/Wireguard.fst`` for why going through gmap is important and how /// to structure your definitions (should you need to reason about ``cells``) in /// a way that will make your life easier.
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 deref_data (#a: _) (h: HS.mem) (c: B.pointer (cell a)) : GTot a
[]
LowStar.Lib.LinkedList.deref_data
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
h: FStar.Monotonic.HyperStack.mem -> c: LowStar.Buffer.pointer (LowStar.Lib.LinkedList.cell a) -> Prims.GTot a
{ "end_col": 20, "end_line": 273, "start_col": 2, "start_line": 273 }
Prims.Ghost
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n)
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let invariant #a h l n = cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let invariant #a h l n =
false
null
false
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[ "" ]
[ "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.LinkedList.t", "Prims.list", "Prims.l_and", "LowStar.Lib.LinkedList.cells_live_freeable", "LowStar.Lib.LinkedList.cells_pairwise_disjoint" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n)
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n)
[]
LowStar.Lib.LinkedList.invariant
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
h: FStar.Monotonic.HyperStack.mem -> l: LowStar.Lib.LinkedList.t a -> n: Prims.list a -> Prims.Ghost Type0
{ "end_col": 60, "end_line": 177, "start_col": 2, "start_line": 177 }
Prims.Ghost
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n)
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n =
false
null
false
if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n)
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[ "" ]
[ "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.LinkedList.t", "Prims.list", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Lib.LinkedList.cell", "LowStar.Buffer.trivial_preorder", "Prims.l_True", "Prims.bool", "Prims.l_and", "LowStar.Monotonic.Buffer.live", "LowStar.Monotonic.Buffer.freeable", "LowStar.Lib.LinkedList.cells_live_freeable", "FStar.List.Tot.Base.tl", "LowStar.Buffer.pointer_or_null", "LowStar.Lib.LinkedList.__proj__Mkcell__item__next", "LowStar.Monotonic.Buffer.deref" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n)
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n)
[ "recursion" ]
LowStar.Lib.LinkedList.cells_live_freeable
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
h: FStar.Monotonic.HyperStack.mem -> l: LowStar.Lib.LinkedList.t a -> n: Prims.list a -> Prims.Ghost Type0
{ "end_col": 39, "end_line": 170, "start_col": 2, "start_line": 165 }
Prims.Ghost
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n)
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n)
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n =
false
null
false
if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n)
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[ "" ]
[ "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.LinkedList.t", "Prims.list", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Lib.LinkedList.cell", "LowStar.Buffer.trivial_preorder", "Prims.l_True", "Prims.bool", "Prims.l_and", "LowStar.Monotonic.Buffer.loc_disjoint", "LowStar.Monotonic.Buffer.loc_addr_of_buffer", "LowStar.Lib.LinkedList.footprint", "FStar.List.Tot.Base.tl", "LowStar.Lib.LinkedList.cells_pairwise_disjoint", "LowStar.Buffer.pointer_or_null", "LowStar.Lib.LinkedList.__proj__Mkcell__item__next", "LowStar.Monotonic.Buffer.deref" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n)
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n)
[ "recursion" ]
LowStar.Lib.LinkedList.cells_pairwise_disjoint
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
h: FStar.Monotonic.HyperStack.mem -> l: LowStar.Lib.LinkedList.t a -> n: Prims.list a -> Prims.Ghost Type0
{ "end_col": 43, "end_line": 157, "start_col": 2, "start_line": 152 }
Prims.GTot
val well_formed (#a: _) (h: HS.mem) (c: t a) (l: list a) : GTot Type0 (decreases l)
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) ))
val well_formed (#a: _) (h: HS.mem) (c: t a) (l: list a) : GTot Type0 (decreases l) let rec well_formed #a (h: HS.mem) (c: t a) (l: list a) : GTot Type0 (decreases l) =
false
null
false
B.live h c /\ (match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ (let { data = data ; next = next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q)))
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[ "sometrivial", "" ]
[ "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.LinkedList.t", "Prims.list", "Prims.l_and", "LowStar.Monotonic.Buffer.live", "LowStar.Lib.LinkedList.cell", "LowStar.Buffer.trivial_preorder", "Prims.b2t", "LowStar.Monotonic.Buffer.g_is_null", "Prims.eq2", "Prims.int", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.pointer_or_null", "LowStar.Lib.LinkedList.well_formed", "Prims.logical", "LowStar.Monotonic.Buffer.get" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 well_formed (#a: _) (h: HS.mem) (c: t a) (l: list a) : GTot Type0 (decreases l)
[ "recursion" ]
LowStar.Lib.LinkedList.well_formed
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
h: FStar.Monotonic.HyperStack.mem -> c: LowStar.Lib.LinkedList.t a -> l: Prims.list a -> Prims.GTot Type0
{ "end_col": 4, "end_line": 71, "start_col": 2, "start_line": 62 }
Prims.Ghost
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n)
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n =
false
null
false
if B.g_is_null l then B.loc_none else let { next = next } = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[ "" ]
[ "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.LinkedList.t", "Prims.list", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Lib.LinkedList.cell", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.loc_none", "Prims.bool", "LowStar.Buffer.pointer_or_null", "LowStar.Monotonic.Buffer.loc_union", "LowStar.Monotonic.Buffer.loc_addr_of_buffer", "LowStar.Monotonic.Buffer.loc", "LowStar.Lib.LinkedList.footprint", "FStar.List.Tot.Base.tl", "LowStar.Monotonic.Buffer.get" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n)
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n)
[ "recursion" ]
LowStar.Lib.LinkedList.footprint
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
h: FStar.Monotonic.HyperStack.mem -> l: LowStar.Lib.LinkedList.t a -> n: Prims.list a -> Prims.Ghost LowStar.Monotonic.Buffer.loc
{ "end_col": 45, "end_line": 141, "start_col": 2, "start_line": 136 }
Prims.GTot
val gmap (#a #b: _) (f: (a -> GTot b)) (xs: list a) : GTot (list b)
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) = match xs with | [] -> [] | x :: xs -> f x :: gmap f xs
val gmap (#a #b: _) (f: (a -> GTot b)) (xs: list a) : GTot (list b) let rec gmap #a #b (f: (a -> GTot b)) (xs: list a) : GTot (list b) =
false
null
false
match xs with | [] -> [] | x :: xs -> f x :: gmap f xs
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[ "sometrivial" ]
[ "Prims.list", "Prims.Nil", "Prims.Cons", "LowStar.Lib.LinkedList.gmap" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let invariant #a h l n = cells_live_freeable h l n /\ cells_pairwise_disjoint h l n /// Normally this would be automatic and writing a custom lemma for that stuff /// would be needed only when writing an fsti, however, as stated earlier, /// recursion makes everything more difficult and this absolutely needs to be in /// scope otherwise the modifies-clause theory cannot deduce disjointness of /// fresh allocations w.r.t. the footprint. let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [ SMTPat (invariant h l n) ] = if B.g_is_null l then () else let next = (B.deref h l).next in invariant_loc_in_footprint h next (L.tl n) /// Another absolutely essential lemma, for which interestingly the pattern /// "invariant h1 l n" does not work, but well_formed does... I guess that's /// alright. let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma (requires ( well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1 )) (ensures ( well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n )) (decreases n) [ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ] = if B.g_is_null l then () else frame (B.deref h0 l).next (L.tl n) r h0 h1 /// Lemmas for working with linked lists /// ------------------------------------ /// /// Since it's a recursive data structure, a lot of the automated reasoning from /// LowStar.Buffer doesn't work since it requires inductions. Some helpful /// properties are therefore proved here. let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a): Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] = if B.g_is_null c then () else let { next=next } = B.get h c 0 in length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2)) /// The footprint is based on loc_addr_of_buffer so that we can write a free /// operation that operates on the footprint. However, this invalidates most of /// the helper lemmas for disjointness that were present in the previous /// iteration of this module, named LinkedList4.fst. It's ok, we bake /// disjointness directly onto the invariant and it works just as well. /// Connection between ``cells`` and ``v`` /// -------------------------------------- /// Redefining some helpers. #push-options "--ifuel 1"
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 gmap (#a #b: _) (f: (a -> GTot b)) (xs: list a) : GTot (list b)
[ "recursion" ]
LowStar.Lib.LinkedList.gmap
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
f: (_: a -> Prims.GTot b) -> xs: Prims.list a -> Prims.GTot (Prims.list b)
{ "end_col": 31, "end_line": 253, "start_col": 2, "start_line": 251 }
Prims.Ghost
val cells (#a: _) (h: HS.mem) (c: t a) (l: list a) : Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l)
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l)
val cells (#a: _) (h: HS.mem) (c: t a) (l: list a) : Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) let rec cells #a (h: HS.mem) (c: t a) (l: list a) : Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) =
false
null
false
if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l)
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[ "" ]
[ "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.LinkedList.t", "Prims.list", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Lib.LinkedList.cell", "LowStar.Buffer.trivial_preorder", "Prims.Nil", "LowStar.Buffer.pointer", "Prims.bool", "Prims.Cons", "LowStar.Lib.LinkedList.cells", "LowStar.Lib.LinkedList.__proj__Mkcell__item__next", "LowStar.Monotonic.Buffer.deref", "FStar.List.Tot.Base.tl", "LowStar.Lib.LinkedList.well_formed", "Prims.l_True" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l)
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 cells (#a: _) (h: HS.mem) (c: t a) (l: list a) : Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l)
[ "recursion" ]
LowStar.Lib.LinkedList.cells
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
h: FStar.Monotonic.HyperStack.mem -> c: LowStar.Lib.LinkedList.t a -> l: Prims.list a -> Prims.Ghost (Prims.list (LowStar.Buffer.pointer (LowStar.Lib.LinkedList.cell a)))
{ "end_col": 51, "end_line": 93, "start_col": 2, "start_line": 90 }
Prims.Ghost
val gfold_right (#a #b: _) (f: (b -> a -> GTot b)) (xs: list a) (acc: b) : Ghost b (requires True) (ensures fun _ -> True) (decreases xs)
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b (requires True) (ensures fun _ -> True) (decreases xs) = match xs with | [] -> acc | x :: xs -> f (gfold_right f xs acc) x
val gfold_right (#a #b: _) (f: (b -> a -> GTot b)) (xs: list a) (acc: b) : Ghost b (requires True) (ensures fun _ -> True) (decreases xs) let rec gfold_right #a #b (f: (b -> a -> GTot b)) (xs: list a) (acc: b) : Ghost b (requires True) (ensures fun _ -> True) (decreases xs) =
false
null
false
match xs with | [] -> acc | x :: xs -> f (gfold_right f xs acc) x
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[ "" ]
[ "Prims.list", "LowStar.Lib.LinkedList.gfold_right", "Prims.l_True" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let invariant #a h l n = cells_live_freeable h l n /\ cells_pairwise_disjoint h l n /// Normally this would be automatic and writing a custom lemma for that stuff /// would be needed only when writing an fsti, however, as stated earlier, /// recursion makes everything more difficult and this absolutely needs to be in /// scope otherwise the modifies-clause theory cannot deduce disjointness of /// fresh allocations w.r.t. the footprint. let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [ SMTPat (invariant h l n) ] = if B.g_is_null l then () else let next = (B.deref h l).next in invariant_loc_in_footprint h next (L.tl n) /// Another absolutely essential lemma, for which interestingly the pattern /// "invariant h1 l n" does not work, but well_formed does... I guess that's /// alright. let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma (requires ( well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1 )) (ensures ( well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n )) (decreases n) [ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ] = if B.g_is_null l then () else frame (B.deref h0 l).next (L.tl n) r h0 h1 /// Lemmas for working with linked lists /// ------------------------------------ /// /// Since it's a recursive data structure, a lot of the automated reasoning from /// LowStar.Buffer doesn't work since it requires inductions. Some helpful /// properties are therefore proved here. let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a): Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] = if B.g_is_null c then () else let { next=next } = B.get h c 0 in length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2)) /// The footprint is based on loc_addr_of_buffer so that we can write a free /// operation that operates on the footprint. However, this invalidates most of /// the helper lemmas for disjointness that were present in the previous /// iteration of this module, named LinkedList4.fst. It's ok, we bake /// disjointness directly onto the invariant and it works just as well. /// Connection between ``cells`` and ``v`` /// -------------------------------------- /// Redefining some helpers. #push-options "--ifuel 1" let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) = match xs with | [] -> [] | x :: xs -> f x :: gmap f xs /// "As we all know", right folds are the easiest to work with because they /// follow the natural structure of recursion (left-folds are evil). let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b (requires True) (ensures fun _ -> True) (decreases xs)
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 gfold_right (#a #b: _) (f: (b -> a -> GTot b)) (xs: list a) (acc: b) : Ghost b (requires True) (ensures fun _ -> True) (decreases xs)
[ "recursion" ]
LowStar.Lib.LinkedList.gfold_right
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
f: (_: b -> _: a -> Prims.GTot b) -> xs: Prims.list a -> acc: b -> Prims.Ghost b
{ "end_col": 41, "end_line": 264, "start_col": 2, "start_line": 262 }
FStar.Pervasives.Lemma
val length_functional (#a: _) (h: HS.mem) (c: t a) (l1 l2: list a) : Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [SMTPat (well_formed h c l1); SMTPat (well_formed h c l2)]
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a): Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] = if B.g_is_null c then () else let { next=next } = B.get h c 0 in length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2))
val length_functional (#a: _) (h: HS.mem) (c: t a) (l1 l2: list a) : Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [SMTPat (well_formed h c l1); SMTPat (well_formed h c l2)] let rec length_functional #a (h: HS.mem) (c: t a) (l1: list a) (l2: list a) : Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [SMTPat (well_formed h c l1); SMTPat (well_formed h c l2)] =
false
null
true
if B.g_is_null c then () else let { next = next } = B.get h c 0 in length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2))
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[ "lemma", "" ]
[ "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.LinkedList.t", "Prims.list", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Lib.LinkedList.cell", "LowStar.Buffer.trivial_preorder", "Prims.bool", "LowStar.Buffer.pointer_or_null", "LowStar.Lib.LinkedList.length_functional", "FStar.List.Tot.Base.tl", "Prims.unit", "LowStar.Monotonic.Buffer.get", "Prims.l_and", "LowStar.Lib.LinkedList.well_formed", "Prims.squash", "Prims.eq2", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let invariant #a h l n = cells_live_freeable h l n /\ cells_pairwise_disjoint h l n /// Normally this would be automatic and writing a custom lemma for that stuff /// would be needed only when writing an fsti, however, as stated earlier, /// recursion makes everything more difficult and this absolutely needs to be in /// scope otherwise the modifies-clause theory cannot deduce disjointness of /// fresh allocations w.r.t. the footprint. let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [ SMTPat (invariant h l n) ] = if B.g_is_null l then () else let next = (B.deref h l).next in invariant_loc_in_footprint h next (L.tl n) /// Another absolutely essential lemma, for which interestingly the pattern /// "invariant h1 l n" does not work, but well_formed does... I guess that's /// alright. let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma (requires ( well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1 )) (ensures ( well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n )) (decreases n) [ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ] = if B.g_is_null l then () else frame (B.deref h0 l).next (L.tl n) r h0 h1 /// Lemmas for working with linked lists /// ------------------------------------ /// /// Since it's a recursive data structure, a lot of the automated reasoning from /// LowStar.Buffer doesn't work since it requires inductions. Some helpful /// properties are therefore proved here. let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a): Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1))
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 length_functional (#a: _) (h: HS.mem) (c: t a) (l1 l2: list a) : Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [SMTPat (well_formed h c l1); SMTPat (well_formed h c l2)]
[ "recursion" ]
LowStar.Lib.LinkedList.length_functional
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
h: FStar.Monotonic.HyperStack.mem -> c: LowStar.Lib.LinkedList.t a -> l1: Prims.list a -> l2: Prims.list a -> FStar.Pervasives.Lemma (requires LowStar.Lib.LinkedList.well_formed h c l1 /\ LowStar.Lib.LinkedList.well_formed h c l2) (ensures l1 == l2) (decreases FStar.Ghost.reveal (FStar.Ghost.hide l1)) [ SMTPat (LowStar.Lib.LinkedList.well_formed h c l1); SMTPat (LowStar.Lib.LinkedList.well_formed h c l2) ]
{ "end_col": 66, "end_line": 237, "start_col": 2, "start_line": 233 }
FStar.Pervasives.Lemma
val same_cells_same_pointer (#a: _) (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a) : Lemma (requires (well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures (ll0 == ll1)) [SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1)]
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim ()
val same_cells_same_pointer (#a: _) (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a) : Lemma (requires (well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures (ll0 == ll1)) [SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1)] let same_cells_same_pointer #a (h0: HS.mem) (h1: HS.mem) (ll0: t a) (ll1: t a) (l0: list a) (l1: list a) : Lemma (requires (well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures (ll0 == ll1)) [SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1)] =
false
null
true
if B.g_is_null ll0 && B.g_is_null ll1 then (B.null_unique ll0; B.null_unique ll1) else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then () else false_elim ()
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[ "lemma" ]
[ "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.LinkedList.t", "Prims.list", "Prims.op_AmpAmp", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Lib.LinkedList.cell", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.null_unique", "Prims.unit", "Prims.bool", "Prims.op_Negation", "FStar.Pervasives.false_elim", "Prims.l_and", "LowStar.Lib.LinkedList.well_formed", "Prims.eq2", "LowStar.Buffer.pointer", "LowStar.Lib.LinkedList.cells", "Prims.squash", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 same_cells_same_pointer (#a: _) (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a) : Lemma (requires (well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures (ll0 == ll1)) [SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1)]
[]
LowStar.Lib.LinkedList.same_cells_same_pointer
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> ll0: LowStar.Lib.LinkedList.t a -> ll1: LowStar.Lib.LinkedList.t a -> l0: Prims.list a -> l1: Prims.list a -> FStar.Pervasives.Lemma (requires LowStar.Lib.LinkedList.well_formed h0 ll0 l0 /\ LowStar.Lib.LinkedList.well_formed h1 ll1 l1 /\ LowStar.Lib.LinkedList.cells h0 ll0 l0 == LowStar.Lib.LinkedList.cells h1 ll1 l1) (ensures ll0 == ll1) [ SMTPat (LowStar.Lib.LinkedList.cells h0 ll0 l0); SMTPat (LowStar.Lib.LinkedList.cells h1 ll1 l1) ]
{ "end_col": 17, "end_line": 120, "start_col": 2, "start_line": 114 }
FStar.Pervasives.Lemma
val invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a) : Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [SMTPat (invariant h l n)]
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [ SMTPat (invariant h l n) ] = if B.g_is_null l then () else let next = (B.deref h l).next in invariant_loc_in_footprint h next (L.tl n)
val invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a) : Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [SMTPat (invariant h l n)] let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a) : Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [SMTPat (invariant h l n)] =
false
null
true
if B.g_is_null l then () else let next = (B.deref h l).next in invariant_loc_in_footprint h next (L.tl n)
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[ "lemma", "" ]
[ "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.LinkedList.t", "Prims.list", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Lib.LinkedList.cell", "LowStar.Buffer.trivial_preorder", "Prims.bool", "LowStar.Lib.LinkedList.invariant_loc_in_footprint", "FStar.List.Tot.Base.tl", "LowStar.Buffer.pointer_or_null", "LowStar.Lib.LinkedList.__proj__Mkcell__item__next", "LowStar.Monotonic.Buffer.deref", "Prims.unit", "LowStar.Lib.LinkedList.well_formed", "Prims.squash", "LowStar.Monotonic.Buffer.loc_in", "LowStar.Lib.LinkedList.footprint", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "LowStar.Lib.LinkedList.invariant", "Prims.Nil" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let invariant #a h l n = cells_live_freeable h l n /\ cells_pairwise_disjoint h l n /// Normally this would be automatic and writing a custom lemma for that stuff /// would be needed only when writing an fsti, however, as stated earlier, /// recursion makes everything more difficult and this absolutely needs to be in /// scope otherwise the modifies-clause theory cannot deduce disjointness of /// fresh allocations w.r.t. the footprint. let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [ SMTPat (invariant h l n) ]
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a) : Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [SMTPat (invariant h l n)]
[ "recursion" ]
LowStar.Lib.LinkedList.invariant_loc_in_footprint
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
h: FStar.Monotonic.HyperStack.mem -> l: LowStar.Lib.LinkedList.t a -> n: Prims.list a -> FStar.Pervasives.Lemma (requires LowStar.Lib.LinkedList.well_formed h l n) (ensures LowStar.Monotonic.Buffer.loc_in (LowStar.Lib.LinkedList.footprint h l n) h) (decreases n) [SMTPat (LowStar.Lib.LinkedList.invariant h l n)]
{ "end_col": 46, "end_line": 194, "start_col": 2, "start_line": 190 }
FStar.HyperStack.ST.Stack
val length (#a: Type) (gn: G.erased (list a)) (l: t a): Stack UInt32.t (requires (fun h -> well_formed h l gn)) (ensures (fun h0 n h1 -> h0 == h1 /\ U32.v n = L.length (G.reveal gn) ))
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec length #a gn l = if B.is_null l then 0ul else let open U32 in let c = !* l in let next = c.next in let n = length (G.hide (L.tail (G.reveal gn))) next in if n = 0xfffffffful then begin LowStar.Failure.failwith "Integer overflow in LowStar.LinkedList.length" end else n +^ 1ul
val length (#a: Type) (gn: G.erased (list a)) (l: t a): Stack UInt32.t (requires (fun h -> well_formed h l gn)) (ensures (fun h0 n h1 -> h0 == h1 /\ U32.v n = L.length (G.reveal gn) )) let rec length #a gn l =
true
null
false
if B.is_null l then 0ul else let open U32 in let c = !*l in let next = c.next in let n = length (G.hide (L.tail (G.reveal gn))) next in if n = 0xfffffffful then LowStar.Failure.failwith "Integer overflow in LowStar.LinkedList.length" else n +^ 1ul
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[]
[ "FStar.Ghost.erased", "Prims.list", "LowStar.Lib.LinkedList.t", "FStar.UInt32.__uint_to_t", "FStar.UInt32.t", "Prims.bool", "Prims.op_Equality", "LowStar.Failure.failwith", "FStar.UInt32.op_Plus_Hat", "LowStar.Lib.LinkedList.length", "FStar.Ghost.hide", "FStar.List.Tot.Base.tail", "FStar.Ghost.reveal", "LowStar.Buffer.pointer_or_null", "LowStar.Lib.LinkedList.cell", "LowStar.Lib.LinkedList.__proj__Mkcell__item__next", "LowStar.BufferOps.op_Bang_Star", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.is_null" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let invariant #a h l n = cells_live_freeable h l n /\ cells_pairwise_disjoint h l n /// Normally this would be automatic and writing a custom lemma for that stuff /// would be needed only when writing an fsti, however, as stated earlier, /// recursion makes everything more difficult and this absolutely needs to be in /// scope otherwise the modifies-clause theory cannot deduce disjointness of /// fresh allocations w.r.t. the footprint. let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [ SMTPat (invariant h l n) ] = if B.g_is_null l then () else let next = (B.deref h l).next in invariant_loc_in_footprint h next (L.tl n) /// Another absolutely essential lemma, for which interestingly the pattern /// "invariant h1 l n" does not work, but well_formed does... I guess that's /// alright. let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma (requires ( well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1 )) (ensures ( well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n )) (decreases n) [ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ] = if B.g_is_null l then () else frame (B.deref h0 l).next (L.tl n) r h0 h1 /// Lemmas for working with linked lists /// ------------------------------------ /// /// Since it's a recursive data structure, a lot of the automated reasoning from /// LowStar.Buffer doesn't work since it requires inductions. Some helpful /// properties are therefore proved here. let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a): Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] = if B.g_is_null c then () else let { next=next } = B.get h c 0 in length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2)) /// The footprint is based on loc_addr_of_buffer so that we can write a free /// operation that operates on the footprint. However, this invalidates most of /// the helper lemmas for disjointness that were present in the previous /// iteration of this module, named LinkedList4.fst. It's ok, we bake /// disjointness directly onto the invariant and it works just as well. /// Connection between ``cells`` and ``v`` /// -------------------------------------- /// Redefining some helpers. #push-options "--ifuel 1" let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) = match xs with | [] -> [] | x :: xs -> f x :: gmap f xs /// "As we all know", right folds are the easiest to work with because they /// follow the natural structure of recursion (left-folds are evil). let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b (requires True) (ensures fun _ -> True) (decreases xs) = match xs with | [] -> acc | x :: xs -> f (gfold_right f xs acc) x #pop-options /// Connecting ``v`` and ``cells``. /// /// See ``tests/Wireguard.fst`` for why going through gmap is important and how /// to structure your definitions (should you need to reason about ``cells``) in /// a way that will make your life easier. let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a = (B.deref h c).data #push-options "--fuel 1 --ifuel 1" let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l /\ invariant h ll l) (ensures gmap (deref_data h) (cells h ll l) == l) (decreases l) [ SMTPat (well_formed h ll l) ] = if B.g_is_null ll then () else deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l) #pop-options /// Connecting ``footprint`` and ``cells``. /// /// This allows conveniently switching to a low-level representation of the /// footprint in case clients want to do some ultra-precise reasoning about /// what's happening with the list spine. However, the fact that all /// operations from this module specify things in terms of ``cells`` along with /// ``same_cells_same_pointer`` should cover most common cases. (This predates /// the introduction of ``same_cells_same_pointer``.) /// /// So, no SMTPat here. Note, I also used the same trick as above with /// higher-order combinators to isolate the use of the argument ``h`` to a /// single sub-term rather than having it passed down the recursive calls. #push-options "--fuel 2 --ifuel 2" let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l) (ensures footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none)) (decreases l) = if B.g_is_null ll then () else footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l) #pop-options /// Stateful operations /// ------------------- /// /// One thing to note: we pass the region `r` explicitly, which is certainly not /// very convenient, but that's alright, another layer of abstraction will take /// care of adding existentials and extra machinery to make this more pleasant /// to use. /// /// All of the operations below are low-level (in the sense that they rely on /// the predicate). I expect clients to use exclusively the variants of these /// functions present in LL2. val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) -> ST unit (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.(loc_disjoint (loc_buffer pl) (loc_region_only true r)) )) (ensures (fun h0 _ h1 -> let n' = G.hide (x :: G.reveal n) in let l = B.deref h1 pl in // Style note: I don't repeat ``B.live pl`` in the post-condition since // ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``. B.modifies (B.loc_buffer pl) h0 h1 /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\ Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\ B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1) )) let push #a r n pl x = (**) let h0 = ST.get () in let l = !* pl in let c = { data = x; next = l } in let pc: B.pointer (cell a) = B.malloc r c 1ul in (**) let h1 = ST.get () in (**) B.(modifies_only_not_unused_in loc_none h0 h1); (**) assert B.(loc_disjoint (loc_buffer pc) (footprint h0 l n)); pl *= pc; (**) let h2 = ST.get () in (**) let n' = G.hide (x :: G.reveal n) in (**) B.(modifies_trans loc_none h0 h1 (loc_buffer pl) h2); (**) assert (well_formed h2 (B.deref h2 pl) n'); (**) assert (invariant h2 (B.deref h2 pl) n'); (**) assert ((B.deref h2 (B.deref h2 pl)).next == l); () val pop: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> ST a (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.loc_disjoint (B.loc_buffer pl) (footprint h l n) /\ Cons? n )) (ensures (fun h0 x h1 -> let l = B.deref h1 pl in let n' = L.tl n in x == L.hd n /\ // Introducing a super precise modifies clause (e.g. loc_addr_of_buffer // (B.deref h0 pl)) here is not useful and prevents trigger-based // reasoning, while also requiring clients to unroll footprint. There's a // tension here between revealing that ``pop`` does nothing stupid (e.g. // re-allocating all the list cells) and providing an abstract enough // predicate to work with. B.(modifies (loc_buffer pl `loc_union` footprint h0 (B.deref h0 pl) n) h0 h1) /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n')) /\ List.Tot.tail (cells h0 (B.deref h0 pl) n) == cells h1 l n')) let pop #a r n pl = let l = !* pl in let r = (!*l).data in let next = (!*l).next in (**) let h1 = ST.get () in (**) assert (cells h1 l n == l :: cells h1 next (List.Tot.tl n)); (**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 l n)); (**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 next (List.Tot.tl n))); pl *= next; B.free l; r val free_: (#a: Type) -> (#n: G.erased (list a)) -> (l: t a) -> ST unit (requires (fun h -> well_formed h l n /\ invariant h l n )) (ensures (fun h0 _ h1 -> B.(modifies (footprint h0 l n) h0 h1))) let rec free_ #a #n l = if B.is_null l then () else begin let tl: G.erased (list a) = G.hide (L.tl (G.reveal n)) in free_ #_ #tl (!*l).next; B.free l end val free: (#a: Type) -> (#n: G.erased (list a)) -> (pl: B.pointer (t a)) -> ST unit (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ B.loc_disjoint (B.loc_buffer pl) (footprint h l n) )) (ensures (fun h0 _ h1 -> let l = B.deref h1 pl in well_formed h1 l [] /\ invariant h1 l [] /\ footprint h1 l [] == B.loc_none /\ cells h1 l [] == [] /\ B.(modifies (footprint h0 (B.deref h0 pl) n `loc_union` loc_buffer pl) h0 h1))) let free #a #n pl = free_ #_ #n !*pl; pl *= B.null val length (#a: Type) (gn: G.erased (list a)) (l: t a): Stack UInt32.t (requires (fun h -> well_formed h l gn)) (ensures (fun h0 n h1 -> h0 == h1 /\ U32.v n = L.length (G.reveal gn) ))
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 length (#a: Type) (gn: G.erased (list a)) (l: t a): Stack UInt32.t (requires (fun h -> well_formed h l gn)) (ensures (fun h0 n h1 -> h0 == h1 /\ U32.v n = L.length (G.reveal gn) ))
[ "recursion" ]
LowStar.Lib.LinkedList.length
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
gn: FStar.Ghost.erased (Prims.list a) -> l: LowStar.Lib.LinkedList.t a -> FStar.HyperStack.ST.Stack FStar.UInt32.t
{ "end_col": 14, "end_line": 471, "start_col": 2, "start_line": 461 }
FStar.HyperStack.ST.ST
val free_: (#a: Type) -> (#n: G.erased (list a)) -> (l: t a) -> ST unit (requires (fun h -> well_formed h l n /\ invariant h l n )) (ensures (fun h0 _ h1 -> B.(modifies (footprint h0 l n) h0 h1)))
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec free_ #a #n l = if B.is_null l then () else begin let tl: G.erased (list a) = G.hide (L.tl (G.reveal n)) in free_ #_ #tl (!*l).next; B.free l end
val free_: (#a: Type) -> (#n: G.erased (list a)) -> (l: t a) -> ST unit (requires (fun h -> well_formed h l n /\ invariant h l n )) (ensures (fun h0 _ h1 -> B.(modifies (footprint h0 l n) h0 h1))) let rec free_ #a #n l =
true
null
false
if B.is_null l then () else let tl:G.erased (list a) = G.hide (L.tl (G.reveal n)) in free_ #_ #tl (!*l).next; B.free l
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[]
[ "FStar.Ghost.erased", "Prims.list", "LowStar.Lib.LinkedList.t", "Prims.unit", "Prims.bool", "LowStar.Monotonic.Buffer.free", "LowStar.Lib.LinkedList.cell", "LowStar.Buffer.trivial_preorder", "LowStar.Lib.LinkedList.free_", "LowStar.Lib.LinkedList.__proj__Mkcell__item__next", "LowStar.BufferOps.op_Bang_Star", "FStar.Ghost.hide", "FStar.List.Tot.Base.tl", "FStar.Ghost.reveal", "LowStar.Monotonic.Buffer.is_null" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let invariant #a h l n = cells_live_freeable h l n /\ cells_pairwise_disjoint h l n /// Normally this would be automatic and writing a custom lemma for that stuff /// would be needed only when writing an fsti, however, as stated earlier, /// recursion makes everything more difficult and this absolutely needs to be in /// scope otherwise the modifies-clause theory cannot deduce disjointness of /// fresh allocations w.r.t. the footprint. let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [ SMTPat (invariant h l n) ] = if B.g_is_null l then () else let next = (B.deref h l).next in invariant_loc_in_footprint h next (L.tl n) /// Another absolutely essential lemma, for which interestingly the pattern /// "invariant h1 l n" does not work, but well_formed does... I guess that's /// alright. let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma (requires ( well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1 )) (ensures ( well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n )) (decreases n) [ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ] = if B.g_is_null l then () else frame (B.deref h0 l).next (L.tl n) r h0 h1 /// Lemmas for working with linked lists /// ------------------------------------ /// /// Since it's a recursive data structure, a lot of the automated reasoning from /// LowStar.Buffer doesn't work since it requires inductions. Some helpful /// properties are therefore proved here. let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a): Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] = if B.g_is_null c then () else let { next=next } = B.get h c 0 in length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2)) /// The footprint is based on loc_addr_of_buffer so that we can write a free /// operation that operates on the footprint. However, this invalidates most of /// the helper lemmas for disjointness that were present in the previous /// iteration of this module, named LinkedList4.fst. It's ok, we bake /// disjointness directly onto the invariant and it works just as well. /// Connection between ``cells`` and ``v`` /// -------------------------------------- /// Redefining some helpers. #push-options "--ifuel 1" let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) = match xs with | [] -> [] | x :: xs -> f x :: gmap f xs /// "As we all know", right folds are the easiest to work with because they /// follow the natural structure of recursion (left-folds are evil). let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b (requires True) (ensures fun _ -> True) (decreases xs) = match xs with | [] -> acc | x :: xs -> f (gfold_right f xs acc) x #pop-options /// Connecting ``v`` and ``cells``. /// /// See ``tests/Wireguard.fst`` for why going through gmap is important and how /// to structure your definitions (should you need to reason about ``cells``) in /// a way that will make your life easier. let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a = (B.deref h c).data #push-options "--fuel 1 --ifuel 1" let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l /\ invariant h ll l) (ensures gmap (deref_data h) (cells h ll l) == l) (decreases l) [ SMTPat (well_formed h ll l) ] = if B.g_is_null ll then () else deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l) #pop-options /// Connecting ``footprint`` and ``cells``. /// /// This allows conveniently switching to a low-level representation of the /// footprint in case clients want to do some ultra-precise reasoning about /// what's happening with the list spine. However, the fact that all /// operations from this module specify things in terms of ``cells`` along with /// ``same_cells_same_pointer`` should cover most common cases. (This predates /// the introduction of ``same_cells_same_pointer``.) /// /// So, no SMTPat here. Note, I also used the same trick as above with /// higher-order combinators to isolate the use of the argument ``h`` to a /// single sub-term rather than having it passed down the recursive calls. #push-options "--fuel 2 --ifuel 2" let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l) (ensures footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none)) (decreases l) = if B.g_is_null ll then () else footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l) #pop-options /// Stateful operations /// ------------------- /// /// One thing to note: we pass the region `r` explicitly, which is certainly not /// very convenient, but that's alright, another layer of abstraction will take /// care of adding existentials and extra machinery to make this more pleasant /// to use. /// /// All of the operations below are low-level (in the sense that they rely on /// the predicate). I expect clients to use exclusively the variants of these /// functions present in LL2. val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) -> ST unit (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.(loc_disjoint (loc_buffer pl) (loc_region_only true r)) )) (ensures (fun h0 _ h1 -> let n' = G.hide (x :: G.reveal n) in let l = B.deref h1 pl in // Style note: I don't repeat ``B.live pl`` in the post-condition since // ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``. B.modifies (B.loc_buffer pl) h0 h1 /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\ Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\ B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1) )) let push #a r n pl x = (**) let h0 = ST.get () in let l = !* pl in let c = { data = x; next = l } in let pc: B.pointer (cell a) = B.malloc r c 1ul in (**) let h1 = ST.get () in (**) B.(modifies_only_not_unused_in loc_none h0 h1); (**) assert B.(loc_disjoint (loc_buffer pc) (footprint h0 l n)); pl *= pc; (**) let h2 = ST.get () in (**) let n' = G.hide (x :: G.reveal n) in (**) B.(modifies_trans loc_none h0 h1 (loc_buffer pl) h2); (**) assert (well_formed h2 (B.deref h2 pl) n'); (**) assert (invariant h2 (B.deref h2 pl) n'); (**) assert ((B.deref h2 (B.deref h2 pl)).next == l); () val pop: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> ST a (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.loc_disjoint (B.loc_buffer pl) (footprint h l n) /\ Cons? n )) (ensures (fun h0 x h1 -> let l = B.deref h1 pl in let n' = L.tl n in x == L.hd n /\ // Introducing a super precise modifies clause (e.g. loc_addr_of_buffer // (B.deref h0 pl)) here is not useful and prevents trigger-based // reasoning, while also requiring clients to unroll footprint. There's a // tension here between revealing that ``pop`` does nothing stupid (e.g. // re-allocating all the list cells) and providing an abstract enough // predicate to work with. B.(modifies (loc_buffer pl `loc_union` footprint h0 (B.deref h0 pl) n) h0 h1) /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n')) /\ List.Tot.tail (cells h0 (B.deref h0 pl) n) == cells h1 l n')) let pop #a r n pl = let l = !* pl in let r = (!*l).data in let next = (!*l).next in (**) let h1 = ST.get () in (**) assert (cells h1 l n == l :: cells h1 next (List.Tot.tl n)); (**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 l n)); (**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 next (List.Tot.tl n))); pl *= next; B.free l; r val free_: (#a: Type) -> (#n: G.erased (list a)) -> (l: t a) -> ST unit (requires (fun h -> well_formed h l n /\ invariant h l n )) (ensures (fun h0 _ h1 -> B.(modifies (footprint h0 l n) h0 h1)))
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 free_: (#a: Type) -> (#n: G.erased (list a)) -> (l: t a) -> ST unit (requires (fun h -> well_formed h l n /\ invariant h l n )) (ensures (fun h0 _ h1 -> B.(modifies (footprint h0 l n) h0 h1)))
[ "recursion" ]
LowStar.Lib.LinkedList.free_
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
l: LowStar.Lib.LinkedList.t a -> FStar.HyperStack.ST.ST Prims.unit
{ "end_col": 5, "end_line": 430, "start_col": 2, "start_line": 424 }
FStar.Pervasives.Lemma
val deref_cells_is_v (#a: _) (h: HS.mem) (ll: t a) (l: list a) : Lemma (requires well_formed h ll l /\ invariant h ll l) (ensures gmap (deref_data h) (cells h ll l) == l) (decreases l) [SMTPat (well_formed h ll l)]
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l /\ invariant h ll l) (ensures gmap (deref_data h) (cells h ll l) == l) (decreases l) [ SMTPat (well_formed h ll l) ] = if B.g_is_null ll then () else deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l)
val deref_cells_is_v (#a: _) (h: HS.mem) (ll: t a) (l: list a) : Lemma (requires well_formed h ll l /\ invariant h ll l) (ensures gmap (deref_data h) (cells h ll l) == l) (decreases l) [SMTPat (well_formed h ll l)] let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a) : Lemma (requires well_formed h ll l /\ invariant h ll l) (ensures gmap (deref_data h) (cells h ll l) == l) (decreases l) [SMTPat (well_formed h ll l)] =
false
null
true
if B.g_is_null ll then () else deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l)
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[ "lemma", "" ]
[ "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.LinkedList.t", "Prims.list", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Lib.LinkedList.cell", "LowStar.Buffer.trivial_preorder", "Prims.bool", "LowStar.Lib.LinkedList.deref_cells_is_v", "LowStar.Lib.LinkedList.__proj__Mkcell__item__next", "LowStar.Monotonic.Buffer.deref", "FStar.List.Tot.Base.tl", "Prims.unit", "Prims.l_and", "LowStar.Lib.LinkedList.well_formed", "LowStar.Lib.LinkedList.invariant", "Prims.squash", "Prims.eq2", "LowStar.Lib.LinkedList.gmap", "LowStar.Buffer.pointer", "LowStar.Lib.LinkedList.deref_data", "LowStar.Lib.LinkedList.cells", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let invariant #a h l n = cells_live_freeable h l n /\ cells_pairwise_disjoint h l n /// Normally this would be automatic and writing a custom lemma for that stuff /// would be needed only when writing an fsti, however, as stated earlier, /// recursion makes everything more difficult and this absolutely needs to be in /// scope otherwise the modifies-clause theory cannot deduce disjointness of /// fresh allocations w.r.t. the footprint. let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [ SMTPat (invariant h l n) ] = if B.g_is_null l then () else let next = (B.deref h l).next in invariant_loc_in_footprint h next (L.tl n) /// Another absolutely essential lemma, for which interestingly the pattern /// "invariant h1 l n" does not work, but well_formed does... I guess that's /// alright. let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma (requires ( well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1 )) (ensures ( well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n )) (decreases n) [ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ] = if B.g_is_null l then () else frame (B.deref h0 l).next (L.tl n) r h0 h1 /// Lemmas for working with linked lists /// ------------------------------------ /// /// Since it's a recursive data structure, a lot of the automated reasoning from /// LowStar.Buffer doesn't work since it requires inductions. Some helpful /// properties are therefore proved here. let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a): Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] = if B.g_is_null c then () else let { next=next } = B.get h c 0 in length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2)) /// The footprint is based on loc_addr_of_buffer so that we can write a free /// operation that operates on the footprint. However, this invalidates most of /// the helper lemmas for disjointness that were present in the previous /// iteration of this module, named LinkedList4.fst. It's ok, we bake /// disjointness directly onto the invariant and it works just as well. /// Connection between ``cells`` and ``v`` /// -------------------------------------- /// Redefining some helpers. #push-options "--ifuel 1" let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) = match xs with | [] -> [] | x :: xs -> f x :: gmap f xs /// "As we all know", right folds are the easiest to work with because they /// follow the natural structure of recursion (left-folds are evil). let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b (requires True) (ensures fun _ -> True) (decreases xs) = match xs with | [] -> acc | x :: xs -> f (gfold_right f xs acc) x #pop-options /// Connecting ``v`` and ``cells``. /// /// See ``tests/Wireguard.fst`` for why going through gmap is important and how /// to structure your definitions (should you need to reason about ``cells``) in /// a way that will make your life easier. let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a = (B.deref h c).data #push-options "--fuel 1 --ifuel 1" let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l /\ invariant h ll l) (ensures gmap (deref_data h) (cells h ll l) == l) (decreases l) [ SMTPat (well_formed h ll l) ]
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 deref_cells_is_v (#a: _) (h: HS.mem) (ll: t a) (l: list a) : Lemma (requires well_formed h ll l /\ invariant h ll l) (ensures gmap (deref_data h) (cells h ll l) == l) (decreases l) [SMTPat (well_formed h ll l)]
[ "recursion" ]
LowStar.Lib.LinkedList.deref_cells_is_v
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
h: FStar.Monotonic.HyperStack.mem -> ll: LowStar.Lib.LinkedList.t a -> l: Prims.list a -> FStar.Pervasives.Lemma (requires LowStar.Lib.LinkedList.well_formed h ll l /\ LowStar.Lib.LinkedList.invariant h ll l ) (ensures LowStar.Lib.LinkedList.gmap (LowStar.Lib.LinkedList.deref_data h) (LowStar.Lib.LinkedList.cells h ll l) == l) (decreases l) [SMTPat (LowStar.Lib.LinkedList.well_formed h ll l)]
{ "end_col": 58, "end_line": 288, "start_col": 2, "start_line": 285 }
FStar.Pervasives.Lemma
val footprint_via_cells_is_footprint (#a: _) (h: HS.mem) (ll: t a) (l: list a) : Lemma (requires well_formed h ll l) (ensures footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none)) (decreases l)
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l) (ensures footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none)) (decreases l) = if B.g_is_null ll then () else footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l)
val footprint_via_cells_is_footprint (#a: _) (h: HS.mem) (ll: t a) (l: list a) : Lemma (requires well_formed h ll l) (ensures footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none)) (decreases l) let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a) : Lemma (requires well_formed h ll l) (ensures footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none)) (decreases l) =
false
null
true
if B.g_is_null ll then () else footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l)
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[ "lemma", "" ]
[ "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.LinkedList.t", "Prims.list", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Lib.LinkedList.cell", "LowStar.Buffer.trivial_preorder", "Prims.bool", "LowStar.Lib.LinkedList.footprint_via_cells_is_footprint", "LowStar.Lib.LinkedList.__proj__Mkcell__item__next", "LowStar.Monotonic.Buffer.deref", "FStar.List.Tot.Base.tl", "Prims.unit", "LowStar.Lib.LinkedList.well_formed", "Prims.squash", "Prims.eq2", "LowStar.Monotonic.Buffer.loc", "LowStar.Lib.LinkedList.footprint", "LowStar.Lib.LinkedList.gfold_right", "LowStar.Monotonic.Buffer.loc_union", "LowStar.Lib.LinkedList.gmap", "LowStar.Buffer.pointer", "LowStar.Monotonic.Buffer.loc_addr_of_buffer", "LowStar.Lib.LinkedList.cells", "LowStar.Monotonic.Buffer.loc_none", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let invariant #a h l n = cells_live_freeable h l n /\ cells_pairwise_disjoint h l n /// Normally this would be automatic and writing a custom lemma for that stuff /// would be needed only when writing an fsti, however, as stated earlier, /// recursion makes everything more difficult and this absolutely needs to be in /// scope otherwise the modifies-clause theory cannot deduce disjointness of /// fresh allocations w.r.t. the footprint. let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [ SMTPat (invariant h l n) ] = if B.g_is_null l then () else let next = (B.deref h l).next in invariant_loc_in_footprint h next (L.tl n) /// Another absolutely essential lemma, for which interestingly the pattern /// "invariant h1 l n" does not work, but well_formed does... I guess that's /// alright. let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma (requires ( well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1 )) (ensures ( well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n )) (decreases n) [ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ] = if B.g_is_null l then () else frame (B.deref h0 l).next (L.tl n) r h0 h1 /// Lemmas for working with linked lists /// ------------------------------------ /// /// Since it's a recursive data structure, a lot of the automated reasoning from /// LowStar.Buffer doesn't work since it requires inductions. Some helpful /// properties are therefore proved here. let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a): Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] = if B.g_is_null c then () else let { next=next } = B.get h c 0 in length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2)) /// The footprint is based on loc_addr_of_buffer so that we can write a free /// operation that operates on the footprint. However, this invalidates most of /// the helper lemmas for disjointness that were present in the previous /// iteration of this module, named LinkedList4.fst. It's ok, we bake /// disjointness directly onto the invariant and it works just as well. /// Connection between ``cells`` and ``v`` /// -------------------------------------- /// Redefining some helpers. #push-options "--ifuel 1" let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) = match xs with | [] -> [] | x :: xs -> f x :: gmap f xs /// "As we all know", right folds are the easiest to work with because they /// follow the natural structure of recursion (left-folds are evil). let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b (requires True) (ensures fun _ -> True) (decreases xs) = match xs with | [] -> acc | x :: xs -> f (gfold_right f xs acc) x #pop-options /// Connecting ``v`` and ``cells``. /// /// See ``tests/Wireguard.fst`` for why going through gmap is important and how /// to structure your definitions (should you need to reason about ``cells``) in /// a way that will make your life easier. let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a = (B.deref h c).data #push-options "--fuel 1 --ifuel 1" let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l /\ invariant h ll l) (ensures gmap (deref_data h) (cells h ll l) == l) (decreases l) [ SMTPat (well_formed h ll l) ] = if B.g_is_null ll then () else deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l) #pop-options /// Connecting ``footprint`` and ``cells``. /// /// This allows conveniently switching to a low-level representation of the /// footprint in case clients want to do some ultra-precise reasoning about /// what's happening with the list spine. However, the fact that all /// operations from this module specify things in terms of ``cells`` along with /// ``same_cells_same_pointer`` should cover most common cases. (This predates /// the introduction of ``same_cells_same_pointer``.) /// /// So, no SMTPat here. Note, I also used the same trick as above with /// higher-order combinators to isolate the use of the argument ``h`` to a /// single sub-term rather than having it passed down the recursive calls. #push-options "--fuel 2 --ifuel 2" let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l) (ensures footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none)) (decreases l)
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 2, "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 footprint_via_cells_is_footprint (#a: _) (h: HS.mem) (ll: t a) (l: list a) : Lemma (requires well_formed h ll l) (ensures footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none)) (decreases l)
[ "recursion" ]
LowStar.Lib.LinkedList.footprint_via_cells_is_footprint
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
h: FStar.Monotonic.HyperStack.mem -> ll: LowStar.Lib.LinkedList.t a -> l: Prims.list a -> FStar.Pervasives.Lemma (requires LowStar.Lib.LinkedList.well_formed h ll l) (ensures LowStar.Lib.LinkedList.footprint h ll l == LowStar.Lib.LinkedList.gfold_right LowStar.Monotonic.Buffer.loc_union (LowStar.Lib.LinkedList.gmap LowStar.Monotonic.Buffer.loc_addr_of_buffer (LowStar.Lib.LinkedList.cells h ll l)) LowStar.Monotonic.Buffer.loc_none) (decreases l)
{ "end_col": 74, "end_line": 313, "start_col": 2, "start_line": 310 }
FStar.Pervasives.Lemma
val frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem) : Lemma (requires (well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1)) (ensures (well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n)) (decreases n) [SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1)]
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma (requires ( well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1 )) (ensures ( well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n )) (decreases n) [ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ] = if B.g_is_null l then () else frame (B.deref h0 l).next (L.tl n) r h0 h1
val frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem) : Lemma (requires (well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1)) (ensures (well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n)) (decreases n) [SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1)] let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem) : Lemma (requires (well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1)) (ensures (well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n)) (decreases n) [SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1)] =
false
null
true
if B.g_is_null l then () else frame (B.deref h0 l).next (L.tl n) r h0 h1
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[ "lemma", "" ]
[ "LowStar.Lib.LinkedList.t", "Prims.list", "LowStar.Monotonic.Buffer.loc", "FStar.Monotonic.HyperStack.mem", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Lib.LinkedList.cell", "LowStar.Buffer.trivial_preorder", "Prims.bool", "LowStar.Lib.LinkedList.frame", "LowStar.Lib.LinkedList.__proj__Mkcell__item__next", "LowStar.Monotonic.Buffer.deref", "FStar.List.Tot.Base.tl", "Prims.unit", "Prims.l_and", "LowStar.Lib.LinkedList.well_formed", "LowStar.Lib.LinkedList.invariant", "LowStar.Monotonic.Buffer.loc_disjoint", "LowStar.Lib.LinkedList.footprint", "LowStar.Monotonic.Buffer.modifies", "Prims.squash", "Prims.eq2", "LowStar.Buffer.pointer", "LowStar.Lib.LinkedList.cells", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let invariant #a h l n = cells_live_freeable h l n /\ cells_pairwise_disjoint h l n /// Normally this would be automatic and writing a custom lemma for that stuff /// would be needed only when writing an fsti, however, as stated earlier, /// recursion makes everything more difficult and this absolutely needs to be in /// scope otherwise the modifies-clause theory cannot deduce disjointness of /// fresh allocations w.r.t. the footprint. let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [ SMTPat (invariant h l n) ] = if B.g_is_null l then () else let next = (B.deref h l).next in invariant_loc_in_footprint h next (L.tl n) /// Another absolutely essential lemma, for which interestingly the pattern /// "invariant h1 l n" does not work, but well_formed does... I guess that's /// alright. let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma (requires ( well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1 )) (ensures ( well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n )) (decreases n) [ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ]
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem) : Lemma (requires (well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1)) (ensures (well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n)) (decreases n) [SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1)]
[ "recursion" ]
LowStar.Lib.LinkedList.frame
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
l: LowStar.Lib.LinkedList.t a -> n: Prims.list a -> r: LowStar.Monotonic.Buffer.loc -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires LowStar.Lib.LinkedList.well_formed h0 l n /\ LowStar.Lib.LinkedList.invariant h0 l n /\ LowStar.Monotonic.Buffer.loc_disjoint r (LowStar.Lib.LinkedList.footprint h0 l n) /\ LowStar.Monotonic.Buffer.modifies r h0 h1) (ensures LowStar.Lib.LinkedList.well_formed h1 l n /\ LowStar.Lib.LinkedList.footprint h1 l n == LowStar.Lib.LinkedList.footprint h0 l n /\ LowStar.Lib.LinkedList.cells h1 l n == LowStar.Lib.LinkedList.cells h0 l n /\ LowStar.Lib.LinkedList.invariant h1 l n) (decreases n) [ SMTPat (LowStar.Lib.LinkedList.well_formed h1 l n); SMTPat (LowStar.Monotonic.Buffer.modifies r h0 h1) ]
{ "end_col": 46, "end_line": 218, "start_col": 2, "start_line": 215 }
FStar.HyperStack.ST.ST
val free: (#a: Type) -> (#n: G.erased (list a)) -> (pl: B.pointer (t a)) -> ST unit (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ B.loc_disjoint (B.loc_buffer pl) (footprint h l n) )) (ensures (fun h0 _ h1 -> let l = B.deref h1 pl in well_formed h1 l [] /\ invariant h1 l [] /\ footprint h1 l [] == B.loc_none /\ cells h1 l [] == [] /\ B.(modifies (footprint h0 (B.deref h0 pl) n `loc_union` loc_buffer pl) h0 h1)))
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let free #a #n pl = free_ #_ #n !*pl; pl *= B.null
val free: (#a: Type) -> (#n: G.erased (list a)) -> (pl: B.pointer (t a)) -> ST unit (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ B.loc_disjoint (B.loc_buffer pl) (footprint h l n) )) (ensures (fun h0 _ h1 -> let l = B.deref h1 pl in well_formed h1 l [] /\ invariant h1 l [] /\ footprint h1 l [] == B.loc_none /\ cells h1 l [] == [] /\ B.(modifies (footprint h0 (B.deref h0 pl) n `loc_union` loc_buffer pl) h0 h1))) let free #a #n pl =
true
null
false
free_ #_ #n !*pl; pl *= B.null
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[]
[ "FStar.Ghost.erased", "Prims.list", "LowStar.Buffer.pointer", "LowStar.Lib.LinkedList.t", "LowStar.BufferOps.op_Star_Equals", "LowStar.Buffer.trivial_preorder", "LowStar.Buffer.null", "LowStar.Lib.LinkedList.cell", "Prims.unit", "LowStar.Lib.LinkedList.free_", "LowStar.BufferOps.op_Bang_Star" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let invariant #a h l n = cells_live_freeable h l n /\ cells_pairwise_disjoint h l n /// Normally this would be automatic and writing a custom lemma for that stuff /// would be needed only when writing an fsti, however, as stated earlier, /// recursion makes everything more difficult and this absolutely needs to be in /// scope otherwise the modifies-clause theory cannot deduce disjointness of /// fresh allocations w.r.t. the footprint. let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [ SMTPat (invariant h l n) ] = if B.g_is_null l then () else let next = (B.deref h l).next in invariant_loc_in_footprint h next (L.tl n) /// Another absolutely essential lemma, for which interestingly the pattern /// "invariant h1 l n" does not work, but well_formed does... I guess that's /// alright. let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma (requires ( well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1 )) (ensures ( well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n )) (decreases n) [ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ] = if B.g_is_null l then () else frame (B.deref h0 l).next (L.tl n) r h0 h1 /// Lemmas for working with linked lists /// ------------------------------------ /// /// Since it's a recursive data structure, a lot of the automated reasoning from /// LowStar.Buffer doesn't work since it requires inductions. Some helpful /// properties are therefore proved here. let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a): Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] = if B.g_is_null c then () else let { next=next } = B.get h c 0 in length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2)) /// The footprint is based on loc_addr_of_buffer so that we can write a free /// operation that operates on the footprint. However, this invalidates most of /// the helper lemmas for disjointness that were present in the previous /// iteration of this module, named LinkedList4.fst. It's ok, we bake /// disjointness directly onto the invariant and it works just as well. /// Connection between ``cells`` and ``v`` /// -------------------------------------- /// Redefining some helpers. #push-options "--ifuel 1" let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) = match xs with | [] -> [] | x :: xs -> f x :: gmap f xs /// "As we all know", right folds are the easiest to work with because they /// follow the natural structure of recursion (left-folds are evil). let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b (requires True) (ensures fun _ -> True) (decreases xs) = match xs with | [] -> acc | x :: xs -> f (gfold_right f xs acc) x #pop-options /// Connecting ``v`` and ``cells``. /// /// See ``tests/Wireguard.fst`` for why going through gmap is important and how /// to structure your definitions (should you need to reason about ``cells``) in /// a way that will make your life easier. let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a = (B.deref h c).data #push-options "--fuel 1 --ifuel 1" let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l /\ invariant h ll l) (ensures gmap (deref_data h) (cells h ll l) == l) (decreases l) [ SMTPat (well_formed h ll l) ] = if B.g_is_null ll then () else deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l) #pop-options /// Connecting ``footprint`` and ``cells``. /// /// This allows conveniently switching to a low-level representation of the /// footprint in case clients want to do some ultra-precise reasoning about /// what's happening with the list spine. However, the fact that all /// operations from this module specify things in terms of ``cells`` along with /// ``same_cells_same_pointer`` should cover most common cases. (This predates /// the introduction of ``same_cells_same_pointer``.) /// /// So, no SMTPat here. Note, I also used the same trick as above with /// higher-order combinators to isolate the use of the argument ``h`` to a /// single sub-term rather than having it passed down the recursive calls. #push-options "--fuel 2 --ifuel 2" let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l) (ensures footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none)) (decreases l) = if B.g_is_null ll then () else footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l) #pop-options /// Stateful operations /// ------------------- /// /// One thing to note: we pass the region `r` explicitly, which is certainly not /// very convenient, but that's alright, another layer of abstraction will take /// care of adding existentials and extra machinery to make this more pleasant /// to use. /// /// All of the operations below are low-level (in the sense that they rely on /// the predicate). I expect clients to use exclusively the variants of these /// functions present in LL2. val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) -> ST unit (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.(loc_disjoint (loc_buffer pl) (loc_region_only true r)) )) (ensures (fun h0 _ h1 -> let n' = G.hide (x :: G.reveal n) in let l = B.deref h1 pl in // Style note: I don't repeat ``B.live pl`` in the post-condition since // ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``. B.modifies (B.loc_buffer pl) h0 h1 /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\ Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\ B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1) )) let push #a r n pl x = (**) let h0 = ST.get () in let l = !* pl in let c = { data = x; next = l } in let pc: B.pointer (cell a) = B.malloc r c 1ul in (**) let h1 = ST.get () in (**) B.(modifies_only_not_unused_in loc_none h0 h1); (**) assert B.(loc_disjoint (loc_buffer pc) (footprint h0 l n)); pl *= pc; (**) let h2 = ST.get () in (**) let n' = G.hide (x :: G.reveal n) in (**) B.(modifies_trans loc_none h0 h1 (loc_buffer pl) h2); (**) assert (well_formed h2 (B.deref h2 pl) n'); (**) assert (invariant h2 (B.deref h2 pl) n'); (**) assert ((B.deref h2 (B.deref h2 pl)).next == l); () val pop: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> ST a (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.loc_disjoint (B.loc_buffer pl) (footprint h l n) /\ Cons? n )) (ensures (fun h0 x h1 -> let l = B.deref h1 pl in let n' = L.tl n in x == L.hd n /\ // Introducing a super precise modifies clause (e.g. loc_addr_of_buffer // (B.deref h0 pl)) here is not useful and prevents trigger-based // reasoning, while also requiring clients to unroll footprint. There's a // tension here between revealing that ``pop`` does nothing stupid (e.g. // re-allocating all the list cells) and providing an abstract enough // predicate to work with. B.(modifies (loc_buffer pl `loc_union` footprint h0 (B.deref h0 pl) n) h0 h1) /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n')) /\ List.Tot.tail (cells h0 (B.deref h0 pl) n) == cells h1 l n')) let pop #a r n pl = let l = !* pl in let r = (!*l).data in let next = (!*l).next in (**) let h1 = ST.get () in (**) assert (cells h1 l n == l :: cells h1 next (List.Tot.tl n)); (**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 l n)); (**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 next (List.Tot.tl n))); pl *= next; B.free l; r val free_: (#a: Type) -> (#n: G.erased (list a)) -> (l: t a) -> ST unit (requires (fun h -> well_formed h l n /\ invariant h l n )) (ensures (fun h0 _ h1 -> B.(modifies (footprint h0 l n) h0 h1))) let rec free_ #a #n l = if B.is_null l then () else begin let tl: G.erased (list a) = G.hide (L.tl (G.reveal n)) in free_ #_ #tl (!*l).next; B.free l end val free: (#a: Type) -> (#n: G.erased (list a)) -> (pl: B.pointer (t a)) -> ST unit (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ B.loc_disjoint (B.loc_buffer pl) (footprint h l n) )) (ensures (fun h0 _ h1 -> let l = B.deref h1 pl in well_formed h1 l [] /\ invariant h1 l [] /\ footprint h1 l [] == B.loc_none /\ cells h1 l [] == [] /\ B.(modifies (footprint h0 (B.deref h0 pl) n `loc_union` loc_buffer pl) h0 h1)))
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 free: (#a: Type) -> (#n: G.erased (list a)) -> (pl: B.pointer (t a)) -> ST unit (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ B.loc_disjoint (B.loc_buffer pl) (footprint h l n) )) (ensures (fun h0 _ h1 -> let l = B.deref h1 pl in well_formed h1 l [] /\ invariant h1 l [] /\ footprint h1 l [] == B.loc_none /\ cells h1 l [] == [] /\ B.(modifies (footprint h0 (B.deref h0 pl) n `loc_union` loc_buffer pl) h0 h1)))
[]
LowStar.Lib.LinkedList.free
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
pl: LowStar.Buffer.pointer (LowStar.Lib.LinkedList.t a) -> FStar.HyperStack.ST.ST Prims.unit
{ "end_col": 14, "end_line": 451, "start_col": 2, "start_line": 450 }
FStar.HyperStack.ST.ST
val pop: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> ST a (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.loc_disjoint (B.loc_buffer pl) (footprint h l n) /\ Cons? n )) (ensures (fun h0 x h1 -> let l = B.deref h1 pl in let n' = L.tl n in x == L.hd n /\ // Introducing a super precise modifies clause (e.g. loc_addr_of_buffer // (B.deref h0 pl)) here is not useful and prevents trigger-based // reasoning, while also requiring clients to unroll footprint. There's a // tension here between revealing that ``pop`` does nothing stupid (e.g. // re-allocating all the list cells) and providing an abstract enough // predicate to work with. B.(modifies (loc_buffer pl `loc_union` footprint h0 (B.deref h0 pl) n) h0 h1) /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n')) /\ List.Tot.tail (cells h0 (B.deref h0 pl) n) == cells h1 l n'))
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let pop #a r n pl = let l = !* pl in let r = (!*l).data in let next = (!*l).next in (**) let h1 = ST.get () in (**) assert (cells h1 l n == l :: cells h1 next (List.Tot.tl n)); (**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 l n)); (**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 next (List.Tot.tl n))); pl *= next; B.free l; r
val pop: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> ST a (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.loc_disjoint (B.loc_buffer pl) (footprint h l n) /\ Cons? n )) (ensures (fun h0 x h1 -> let l = B.deref h1 pl in let n' = L.tl n in x == L.hd n /\ // Introducing a super precise modifies clause (e.g. loc_addr_of_buffer // (B.deref h0 pl)) here is not useful and prevents trigger-based // reasoning, while also requiring clients to unroll footprint. There's a // tension here between revealing that ``pop`` does nothing stupid (e.g. // re-allocating all the list cells) and providing an abstract enough // predicate to work with. B.(modifies (loc_buffer pl `loc_union` footprint h0 (B.deref h0 pl) n) h0 h1) /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n')) /\ List.Tot.tail (cells h0 (B.deref h0 pl) n) == cells h1 l n')) let pop #a r n pl =
true
null
false
let l = !*pl in let r = (!*l).data in let next = (!*l).next in let h1 = ST.get () in assert (cells h1 l n == l :: cells h1 next (List.Tot.tl n)); assert B.(loc_disjoint (loc_buffer pl) (footprint h1 l n)); assert B.(loc_disjoint (loc_buffer pl) (footprint h1 next (List.Tot.tl n))); pl *= next; B.free l; r
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.Ghost.erased", "Prims.list", "LowStar.Buffer.pointer", "LowStar.Lib.LinkedList.t", "Prims.unit", "LowStar.Monotonic.Buffer.free", "LowStar.Lib.LinkedList.cell", "LowStar.Buffer.trivial_preorder", "LowStar.BufferOps.op_Star_Equals", "Prims._assert", "LowStar.Monotonic.Buffer.loc_disjoint", "LowStar.Monotonic.Buffer.loc_buffer", "LowStar.Lib.LinkedList.footprint", "FStar.List.Tot.Base.tl", "FStar.Ghost.reveal", "Prims.eq2", "LowStar.Lib.LinkedList.cells", "Prims.Cons", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.Buffer.pointer_or_null", "LowStar.Lib.LinkedList.__proj__Mkcell__item__next", "LowStar.BufferOps.op_Bang_Star", "LowStar.Lib.LinkedList.__proj__Mkcell__item__data" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let invariant #a h l n = cells_live_freeable h l n /\ cells_pairwise_disjoint h l n /// Normally this would be automatic and writing a custom lemma for that stuff /// would be needed only when writing an fsti, however, as stated earlier, /// recursion makes everything more difficult and this absolutely needs to be in /// scope otherwise the modifies-clause theory cannot deduce disjointness of /// fresh allocations w.r.t. the footprint. let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [ SMTPat (invariant h l n) ] = if B.g_is_null l then () else let next = (B.deref h l).next in invariant_loc_in_footprint h next (L.tl n) /// Another absolutely essential lemma, for which interestingly the pattern /// "invariant h1 l n" does not work, but well_formed does... I guess that's /// alright. let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma (requires ( well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1 )) (ensures ( well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n )) (decreases n) [ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ] = if B.g_is_null l then () else frame (B.deref h0 l).next (L.tl n) r h0 h1 /// Lemmas for working with linked lists /// ------------------------------------ /// /// Since it's a recursive data structure, a lot of the automated reasoning from /// LowStar.Buffer doesn't work since it requires inductions. Some helpful /// properties are therefore proved here. let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a): Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] = if B.g_is_null c then () else let { next=next } = B.get h c 0 in length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2)) /// The footprint is based on loc_addr_of_buffer so that we can write a free /// operation that operates on the footprint. However, this invalidates most of /// the helper lemmas for disjointness that were present in the previous /// iteration of this module, named LinkedList4.fst. It's ok, we bake /// disjointness directly onto the invariant and it works just as well. /// Connection between ``cells`` and ``v`` /// -------------------------------------- /// Redefining some helpers. #push-options "--ifuel 1" let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) = match xs with | [] -> [] | x :: xs -> f x :: gmap f xs /// "As we all know", right folds are the easiest to work with because they /// follow the natural structure of recursion (left-folds are evil). let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b (requires True) (ensures fun _ -> True) (decreases xs) = match xs with | [] -> acc | x :: xs -> f (gfold_right f xs acc) x #pop-options /// Connecting ``v`` and ``cells``. /// /// See ``tests/Wireguard.fst`` for why going through gmap is important and how /// to structure your definitions (should you need to reason about ``cells``) in /// a way that will make your life easier. let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a = (B.deref h c).data #push-options "--fuel 1 --ifuel 1" let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l /\ invariant h ll l) (ensures gmap (deref_data h) (cells h ll l) == l) (decreases l) [ SMTPat (well_formed h ll l) ] = if B.g_is_null ll then () else deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l) #pop-options /// Connecting ``footprint`` and ``cells``. /// /// This allows conveniently switching to a low-level representation of the /// footprint in case clients want to do some ultra-precise reasoning about /// what's happening with the list spine. However, the fact that all /// operations from this module specify things in terms of ``cells`` along with /// ``same_cells_same_pointer`` should cover most common cases. (This predates /// the introduction of ``same_cells_same_pointer``.) /// /// So, no SMTPat here. Note, I also used the same trick as above with /// higher-order combinators to isolate the use of the argument ``h`` to a /// single sub-term rather than having it passed down the recursive calls. #push-options "--fuel 2 --ifuel 2" let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l) (ensures footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none)) (decreases l) = if B.g_is_null ll then () else footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l) #pop-options /// Stateful operations /// ------------------- /// /// One thing to note: we pass the region `r` explicitly, which is certainly not /// very convenient, but that's alright, another layer of abstraction will take /// care of adding existentials and extra machinery to make this more pleasant /// to use. /// /// All of the operations below are low-level (in the sense that they rely on /// the predicate). I expect clients to use exclusively the variants of these /// functions present in LL2. val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) -> ST unit (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.(loc_disjoint (loc_buffer pl) (loc_region_only true r)) )) (ensures (fun h0 _ h1 -> let n' = G.hide (x :: G.reveal n) in let l = B.deref h1 pl in // Style note: I don't repeat ``B.live pl`` in the post-condition since // ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``. B.modifies (B.loc_buffer pl) h0 h1 /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\ Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\ B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1) )) let push #a r n pl x = (**) let h0 = ST.get () in let l = !* pl in let c = { data = x; next = l } in let pc: B.pointer (cell a) = B.malloc r c 1ul in (**) let h1 = ST.get () in (**) B.(modifies_only_not_unused_in loc_none h0 h1); (**) assert B.(loc_disjoint (loc_buffer pc) (footprint h0 l n)); pl *= pc; (**) let h2 = ST.get () in (**) let n' = G.hide (x :: G.reveal n) in (**) B.(modifies_trans loc_none h0 h1 (loc_buffer pl) h2); (**) assert (well_formed h2 (B.deref h2 pl) n'); (**) assert (invariant h2 (B.deref h2 pl) n'); (**) assert ((B.deref h2 (B.deref h2 pl)).next == l); () val pop: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> ST a (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.loc_disjoint (B.loc_buffer pl) (footprint h l n) /\ Cons? n )) (ensures (fun h0 x h1 -> let l = B.deref h1 pl in let n' = L.tl n in x == L.hd n /\ // Introducing a super precise modifies clause (e.g. loc_addr_of_buffer // (B.deref h0 pl)) here is not useful and prevents trigger-based // reasoning, while also requiring clients to unroll footprint. There's a // tension here between revealing that ``pop`` does nothing stupid (e.g. // re-allocating all the list cells) and providing an abstract enough // predicate to work with. B.(modifies (loc_buffer pl `loc_union` footprint h0 (B.deref h0 pl) n) h0 h1) /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n')) /\ List.Tot.tail (cells h0 (B.deref h0 pl) n) == cells h1 l n'))
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 pop: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> ST a (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.loc_disjoint (B.loc_buffer pl) (footprint h l n) /\ Cons? n )) (ensures (fun h0 x h1 -> let l = B.deref h1 pl in let n' = L.tl n in x == L.hd n /\ // Introducing a super precise modifies clause (e.g. loc_addr_of_buffer // (B.deref h0 pl)) here is not useful and prevents trigger-based // reasoning, while also requiring clients to unroll footprint. There's a // tension here between revealing that ``pop`` does nothing stupid (e.g. // re-allocating all the list cells) and providing an abstract enough // predicate to work with. B.(modifies (loc_buffer pl `loc_union` footprint h0 (B.deref h0 pl) n) h0 h1) /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n')) /\ List.Tot.tail (cells h0 (B.deref h0 pl) n) == cells h1 l n'))
[]
LowStar.Lib.LinkedList.pop
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
r: FStar.Monotonic.HyperHeap.rid -> n: FStar.Ghost.erased (Prims.list a) -> pl: LowStar.Buffer.pointer (LowStar.Lib.LinkedList.t a) -> FStar.HyperStack.ST.ST a
{ "end_col": 3, "end_line": 412, "start_col": 19, "start_line": 401 }
FStar.HyperStack.ST.ST
val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) -> ST unit (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.(loc_disjoint (loc_buffer pl) (loc_region_only true r)) )) (ensures (fun h0 _ h1 -> let n' = G.hide (x :: G.reveal n) in let l = B.deref h1 pl in // Style note: I don't repeat ``B.live pl`` in the post-condition since // ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``. B.modifies (B.loc_buffer pl) h0 h1 /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\ Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\ B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1) ))
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let push #a r n pl x = (**) let h0 = ST.get () in let l = !* pl in let c = { data = x; next = l } in let pc: B.pointer (cell a) = B.malloc r c 1ul in (**) let h1 = ST.get () in (**) B.(modifies_only_not_unused_in loc_none h0 h1); (**) assert B.(loc_disjoint (loc_buffer pc) (footprint h0 l n)); pl *= pc; (**) let h2 = ST.get () in (**) let n' = G.hide (x :: G.reveal n) in (**) B.(modifies_trans loc_none h0 h1 (loc_buffer pl) h2); (**) assert (well_formed h2 (B.deref h2 pl) n'); (**) assert (invariant h2 (B.deref h2 pl) n'); (**) assert ((B.deref h2 (B.deref h2 pl)).next == l); ()
val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) -> ST unit (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.(loc_disjoint (loc_buffer pl) (loc_region_only true r)) )) (ensures (fun h0 _ h1 -> let n' = G.hide (x :: G.reveal n) in let l = B.deref h1 pl in // Style note: I don't repeat ``B.live pl`` in the post-condition since // ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``. B.modifies (B.loc_buffer pl) h0 h1 /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\ Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\ B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1) )) let push #a r n pl x =
true
null
false
let h0 = ST.get () in let l = !*pl in let c = { data = x; next = l } in let pc:B.pointer (cell a) = B.malloc r c 1ul in let h1 = ST.get () in (let open B in modifies_only_not_unused_in loc_none h0 h1); assert B.(loc_disjoint (loc_buffer pc) (footprint h0 l n)); pl *= pc; let h2 = ST.get () in let n' = G.hide (x :: G.reveal n) in (let open B in modifies_trans loc_none h0 h1 (loc_buffer pl) h2); assert (well_formed h2 (B.deref h2 pl) n'); assert (invariant h2 (B.deref h2 pl) n'); assert ((B.deref h2 (B.deref h2 pl)).next == l); ()
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.Ghost.erased", "Prims.list", "LowStar.Buffer.pointer", "LowStar.Lib.LinkedList.t", "Prims.unit", "Prims._assert", "Prims.eq2", "LowStar.Buffer.pointer_or_null", "LowStar.Lib.LinkedList.cell", "LowStar.Lib.LinkedList.__proj__Mkcell__item__next", "LowStar.Monotonic.Buffer.deref", "LowStar.Buffer.trivial_preorder", "LowStar.Lib.LinkedList.invariant", "FStar.Ghost.reveal", "LowStar.Lib.LinkedList.well_formed", "LowStar.Monotonic.Buffer.modifies_trans", "LowStar.Monotonic.Buffer.loc_none", "LowStar.Monotonic.Buffer.loc_buffer", "FStar.Ghost.hide", "Prims.Cons", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.BufferOps.op_Star_Equals", "LowStar.Monotonic.Buffer.loc_disjoint", "LowStar.Lib.LinkedList.footprint", "LowStar.Monotonic.Buffer.modifies_only_not_unused_in", "LowStar.Buffer.malloc", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.mbuffer", "Prims.l_and", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.UInt32.v", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.freeable", "LowStar.Lib.LinkedList.Mkcell", "LowStar.BufferOps.op_Bang_Star" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let invariant #a h l n = cells_live_freeable h l n /\ cells_pairwise_disjoint h l n /// Normally this would be automatic and writing a custom lemma for that stuff /// would be needed only when writing an fsti, however, as stated earlier, /// recursion makes everything more difficult and this absolutely needs to be in /// scope otherwise the modifies-clause theory cannot deduce disjointness of /// fresh allocations w.r.t. the footprint. let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [ SMTPat (invariant h l n) ] = if B.g_is_null l then () else let next = (B.deref h l).next in invariant_loc_in_footprint h next (L.tl n) /// Another absolutely essential lemma, for which interestingly the pattern /// "invariant h1 l n" does not work, but well_formed does... I guess that's /// alright. let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma (requires ( well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1 )) (ensures ( well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n )) (decreases n) [ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ] = if B.g_is_null l then () else frame (B.deref h0 l).next (L.tl n) r h0 h1 /// Lemmas for working with linked lists /// ------------------------------------ /// /// Since it's a recursive data structure, a lot of the automated reasoning from /// LowStar.Buffer doesn't work since it requires inductions. Some helpful /// properties are therefore proved here. let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a): Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] = if B.g_is_null c then () else let { next=next } = B.get h c 0 in length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2)) /// The footprint is based on loc_addr_of_buffer so that we can write a free /// operation that operates on the footprint. However, this invalidates most of /// the helper lemmas for disjointness that were present in the previous /// iteration of this module, named LinkedList4.fst. It's ok, we bake /// disjointness directly onto the invariant and it works just as well. /// Connection between ``cells`` and ``v`` /// -------------------------------------- /// Redefining some helpers. #push-options "--ifuel 1" let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) = match xs with | [] -> [] | x :: xs -> f x :: gmap f xs /// "As we all know", right folds are the easiest to work with because they /// follow the natural structure of recursion (left-folds are evil). let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b (requires True) (ensures fun _ -> True) (decreases xs) = match xs with | [] -> acc | x :: xs -> f (gfold_right f xs acc) x #pop-options /// Connecting ``v`` and ``cells``. /// /// See ``tests/Wireguard.fst`` for why going through gmap is important and how /// to structure your definitions (should you need to reason about ``cells``) in /// a way that will make your life easier. let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a = (B.deref h c).data #push-options "--fuel 1 --ifuel 1" let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l /\ invariant h ll l) (ensures gmap (deref_data h) (cells h ll l) == l) (decreases l) [ SMTPat (well_formed h ll l) ] = if B.g_is_null ll then () else deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l) #pop-options /// Connecting ``footprint`` and ``cells``. /// /// This allows conveniently switching to a low-level representation of the /// footprint in case clients want to do some ultra-precise reasoning about /// what's happening with the list spine. However, the fact that all /// operations from this module specify things in terms of ``cells`` along with /// ``same_cells_same_pointer`` should cover most common cases. (This predates /// the introduction of ``same_cells_same_pointer``.) /// /// So, no SMTPat here. Note, I also used the same trick as above with /// higher-order combinators to isolate the use of the argument ``h`` to a /// single sub-term rather than having it passed down the recursive calls. #push-options "--fuel 2 --ifuel 2" let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l) (ensures footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none)) (decreases l) = if B.g_is_null ll then () else footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l) #pop-options /// Stateful operations /// ------------------- /// /// One thing to note: we pass the region `r` explicitly, which is certainly not /// very convenient, but that's alright, another layer of abstraction will take /// care of adding existentials and extra machinery to make this more pleasant /// to use. /// /// All of the operations below are low-level (in the sense that they rely on /// the predicate). I expect clients to use exclusively the variants of these /// functions present in LL2. val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) -> ST unit (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.(loc_disjoint (loc_buffer pl) (loc_region_only true r)) )) (ensures (fun h0 _ h1 -> let n' = G.hide (x :: G.reveal n) in let l = B.deref h1 pl in // Style note: I don't repeat ``B.live pl`` in the post-condition since // ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``. B.modifies (B.loc_buffer pl) h0 h1 /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\ Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\ B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1) ))
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) -> ST unit (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.(loc_disjoint (loc_buffer pl) (loc_region_only true r)) )) (ensures (fun h0 _ h1 -> let n' = G.hide (x :: G.reveal n) in let l = B.deref h1 pl in // Style note: I don't repeat ``B.live pl`` in the post-condition since // ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``. B.modifies (B.loc_buffer pl) h0 h1 /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\ Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\ B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1) ))
[]
LowStar.Lib.LinkedList.push
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
r: FStar.Monotonic.HyperHeap.rid -> n: FStar.Ghost.erased (Prims.list a) -> pl: LowStar.Buffer.pointer (LowStar.Lib.LinkedList.t a) -> x: a -> FStar.HyperStack.ST.ST Prims.unit
{ "end_col": 4, "end_line": 371, "start_col": 22, "start_line": 353 }
FStar.HyperStack.ST.ST
val test: unit -> ST (Int32.t) (fun _ -> true) (fun _ _ _ -> true)
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test () = let l: B.pointer_or_null (t Int32.t) = B.malloc HS.root B.null 1ul in let l_region = new_region HS.root in push #Int32.t l_region (G.hide []) l 1l; push #Int32.t l_region (G.hide [1l]) l 0l; let r = pop #Int32.t l_region (G.hide [0l; 1l]) l in TestLib.checku32 (length (G.hide [1l]) !*l) 1ul; r
val test: unit -> ST (Int32.t) (fun _ -> true) (fun _ _ _ -> true) let test () =
true
null
false
let l:B.pointer_or_null (t Int32.t) = B.malloc HS.root B.null 1ul in let l_region = new_region HS.root in push #Int32.t l_region (G.hide []) l 1l; push #Int32.t l_region (G.hide [1l]) l 0l; let r = pop #Int32.t l_region (G.hide [0l; 1l]) l in TestLib.checku32 (length (G.hide [1l]) !*l) 1ul; r
{ "checked_file": "LowStar.Lib.LinkedList.fst.checked", "dependencies": [ "TestLib.fsti.checked", "prims.fst.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Lib.LinkedList.fst" }
[]
[ "Prims.unit", "FStar.Int32.t", "TestLib.checku32", "FStar.UInt32.__uint_to_t", "FStar.UInt32.t", "LowStar.Lib.LinkedList.length", "FStar.Ghost.hide", "Prims.list", "Prims.Cons", "FStar.Int32.__int_to_t", "Prims.Nil", "LowStar.Lib.LinkedList.t", "LowStar.BufferOps.op_Bang_Star", "LowStar.Buffer.trivial_preorder", "LowStar.Lib.LinkedList.pop", "LowStar.Lib.LinkedList.push", "FStar.Monotonic.HyperHeap.rid", "FStar.HyperStack.ST.new_region", "FStar.Monotonic.HyperHeap.root", "LowStar.Buffer.pointer_or_null", "LowStar.Buffer.malloc", "LowStar.Buffer.null", "LowStar.Lib.LinkedList.cell", "LowStar.Monotonic.Buffer.mbuffer", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.UInt32.v", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.freeable" ]
[]
module LowStar.Lib.LinkedList /// This module, oftentimes referred to as LL1 in other parts of the /// documentation, provides a low-level view over a linked list. Unless you /// intend on modifying the structure of the linked list (e.g. removing cells) /// or iterating over each cell, your are probably better off using LL2. /// /// This module is intentionally not relying on a tight abstraction, to i) permit /// direct-style iteration by clients and ii) allow stating some SMTPat lemmas /// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can /// happen automatically at the SMT level since LL2 does not have an fsti either). /// /// Some open questions relative to the design of this module: /// - should ``v`` be defined directly in terms of ``cells`` rather than have a /// recursive definition along with an equivalence lemma? /// - should ``footprint`` be defined directly in terms of ``cells`` rather than /// have a recursive definition along with an equivalence lemma? /// - is it worth the trouble defining a footprint? my intuition is that it's /// fine and allows some clients to do very precise reasoning -- other modules /// (e.g. AssocList), when establishing abstraction boundaries, can simplify /// things and get rid of the precise footprint reasoning in favor of a static /// region-based footprint /// /// Some remaining work items: /// - switch to C.Loops.while open LowStar.BufferOps module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST open FStar.HyperStack.ST /// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since /// everything does recursive list reasoning. #set-options "--__no_positivity --fuel 1 --ifuel 1" /// Definition of the Low* type /// --------------------------- noeq type t (a: Type0) = B.pointer_or_null (cell a) and cell (a: Type0) = { next: t a; data: a; } /// Unlike the canonical style that associates a ``v`` function to any stateful /// representation, we use a relation here. Writing a function is just /// impossible, since we can't prove termination of ``v`` owing to the fact that /// there may be an infinite number of cells in the heap. /// /// LL2 is the module that switches to the function style. /// /// Note: no need to use erased here for ``l`` since the function is already in ``GTot``. let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) = B.live h c /\ ( match l with | [] -> B.g_is_null c | a :: q -> B.length c == 1 /\ ( let { data=data; next=next } = B.get h c 0 in a == data /\ well_formed h next (G.hide q) )) /// Precise reasoning via the cells predicate /// ----------------------------------------- /// /// The modifies clauses are given either on the footprint of the list, or on a /// region that includes the footprint of the list (higher up the stack, e.g. /// LL2). This is good, but does not rule out "stupid" implementations that /// might re-allocate every single list cell when, say, doing a pop. /// /// For advanced usages which take pointers directly to individual list cells, /// it's important to rule out these cases. We thus define the ``cells`` /// predicate for that purpose. let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a))) (requires well_formed h c l) (ensures fun _ -> True) (decreases l) = if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) /// A missing bit of automated reasoning /// ------------------------------------ /// This should be absolutely trivial, yet, because there's no pattern on /// null_unique, we have to do the case analysis and the decomposition /// ourselves. This is quite tedious, as it usually takes a while (at least it /// did for me!) to realize that this property does not hold automatically. /// /// I'm setting an SMTPat on this lemma because it's absolutely impossible to /// get any work done without it. let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma (requires ( well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1)) (ensures ( ll0 == ll1)) [ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ] = if B.g_is_null ll0 && B.g_is_null ll1 then begin B.null_unique ll0; B.null_unique ll1 end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin () end else false_elim () /// Classic stateful reasoning lemmas /// --------------------------------- /// /// This essentially follows ``stateful``, the type class of a mutable piece of /// state defined using the modifies-theory of Low*v2 and equipped with the /// right lemmas to enable usage by clients. See /// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context. val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc (requires (well_formed h l n)) (ensures (fun refs -> True)) (decreases n) let rec footprint #a h l n = if B.g_is_null l then B.loc_none else let {next = next} = B.get h l 0 in let refs = footprint h next (G.hide (L.tl n)) in B.loc_union (B.loc_addr_of_buffer l) refs /// Departing from LinkedList4 here. I prefer to bolt these into the invariant /// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to /// deduce these. val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_pairwise_disjoint #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\ cells_pairwise_disjoint h next (L.tl n) val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let rec cells_live_freeable #_ h l n = if B.g_is_null l then True else let next = (B.deref h l).next in B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0 (requires well_formed h l n) (ensures fun _ -> True) (decreases n) let invariant #a h l n = cells_live_freeable h l n /\ cells_pairwise_disjoint h l n /// Normally this would be automatic and writing a custom lemma for that stuff /// would be needed only when writing an fsti, however, as stated earlier, /// recursion makes everything more difficult and this absolutely needs to be in /// scope otherwise the modifies-clause theory cannot deduce disjointness of /// fresh allocations w.r.t. the footprint. let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma (requires well_formed h l n) (ensures B.loc_in (footprint h l n) h) (decreases n) [ SMTPat (invariant h l n) ] = if B.g_is_null l then () else let next = (B.deref h l).next in invariant_loc_in_footprint h next (L.tl n) /// Another absolutely essential lemma, for which interestingly the pattern /// "invariant h1 l n" does not work, but well_formed does... I guess that's /// alright. let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma (requires ( well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\ B.modifies r h0 h1 )) (ensures ( well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\ invariant h1 l n )) (decreases n) [ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ] = if B.g_is_null l then () else frame (B.deref h0 l).next (L.tl n) r h0 h1 /// Lemmas for working with linked lists /// ------------------------------------ /// /// Since it's a recursive data structure, a lot of the automated reasoning from /// LowStar.Buffer doesn't work since it requires inductions. Some helpful /// properties are therefore proved here. let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a): Lemma (requires (well_formed h c l1 /\ well_formed h c l2)) (ensures (l1 == l2)) (decreases (G.reveal l1)) [ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] = if B.g_is_null c then () else let { next=next } = B.get h c 0 in length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2)) /// The footprint is based on loc_addr_of_buffer so that we can write a free /// operation that operates on the footprint. However, this invalidates most of /// the helper lemmas for disjointness that were present in the previous /// iteration of this module, named LinkedList4.fst. It's ok, we bake /// disjointness directly onto the invariant and it works just as well. /// Connection between ``cells`` and ``v`` /// -------------------------------------- /// Redefining some helpers. #push-options "--ifuel 1" let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) = match xs with | [] -> [] | x :: xs -> f x :: gmap f xs /// "As we all know", right folds are the easiest to work with because they /// follow the natural structure of recursion (left-folds are evil). let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b (requires True) (ensures fun _ -> True) (decreases xs) = match xs with | [] -> acc | x :: xs -> f (gfold_right f xs acc) x #pop-options /// Connecting ``v`` and ``cells``. /// /// See ``tests/Wireguard.fst`` for why going through gmap is important and how /// to structure your definitions (should you need to reason about ``cells``) in /// a way that will make your life easier. let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a = (B.deref h c).data #push-options "--fuel 1 --ifuel 1" let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l /\ invariant h ll l) (ensures gmap (deref_data h) (cells h ll l) == l) (decreases l) [ SMTPat (well_formed h ll l) ] = if B.g_is_null ll then () else deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l) #pop-options /// Connecting ``footprint`` and ``cells``. /// /// This allows conveniently switching to a low-level representation of the /// footprint in case clients want to do some ultra-precise reasoning about /// what's happening with the list spine. However, the fact that all /// operations from this module specify things in terms of ``cells`` along with /// ``same_cells_same_pointer`` should cover most common cases. (This predates /// the introduction of ``same_cells_same_pointer``.) /// /// So, no SMTPat here. Note, I also used the same trick as above with /// higher-order combinators to isolate the use of the argument ``h`` to a /// single sub-term rather than having it passed down the recursive calls. #push-options "--fuel 2 --ifuel 2" let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a): Lemma (requires well_formed h ll l) (ensures footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none)) (decreases l) = if B.g_is_null ll then () else footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l) #pop-options /// Stateful operations /// ------------------- /// /// One thing to note: we pass the region `r` explicitly, which is certainly not /// very convenient, but that's alright, another layer of abstraction will take /// care of adding existentials and extra machinery to make this more pleasant /// to use. /// /// All of the operations below are low-level (in the sense that they rely on /// the predicate). I expect clients to use exclusively the variants of these /// functions present in LL2. val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) -> ST unit (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.(loc_disjoint (loc_buffer pl) (loc_region_only true r)) )) (ensures (fun h0 _ h1 -> let n' = G.hide (x :: G.reveal n) in let l = B.deref h1 pl in // Style note: I don't repeat ``B.live pl`` in the post-condition since // ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``. B.modifies (B.loc_buffer pl) h0 h1 /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\ Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\ B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1) )) let push #a r n pl x = (**) let h0 = ST.get () in let l = !* pl in let c = { data = x; next = l } in let pc: B.pointer (cell a) = B.malloc r c 1ul in (**) let h1 = ST.get () in (**) B.(modifies_only_not_unused_in loc_none h0 h1); (**) assert B.(loc_disjoint (loc_buffer pc) (footprint h0 l n)); pl *= pc; (**) let h2 = ST.get () in (**) let n' = G.hide (x :: G.reveal n) in (**) B.(modifies_trans loc_none h0 h1 (loc_buffer pl) h2); (**) assert (well_formed h2 (B.deref h2 pl) n'); (**) assert (invariant h2 (B.deref h2 pl) n'); (**) assert ((B.deref h2 (B.deref h2 pl)).next == l); () val pop: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> ST a (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ ST.is_eternal_region r /\ B.(loc_includes (loc_region_only true r) (footprint h l n)) /\ B.loc_disjoint (B.loc_buffer pl) (footprint h l n) /\ Cons? n )) (ensures (fun h0 x h1 -> let l = B.deref h1 pl in let n' = L.tl n in x == L.hd n /\ // Introducing a super precise modifies clause (e.g. loc_addr_of_buffer // (B.deref h0 pl)) here is not useful and prevents trigger-based // reasoning, while also requiring clients to unroll footprint. There's a // tension here between revealing that ``pop`` does nothing stupid (e.g. // re-allocating all the list cells) and providing an abstract enough // predicate to work with. B.(modifies (loc_buffer pl `loc_union` footprint h0 (B.deref h0 pl) n) h0 h1) /\ well_formed h1 l n' /\ invariant h1 l n' /\ B.(loc_includes (loc_region_only true r) (footprint h1 l n')) /\ List.Tot.tail (cells h0 (B.deref h0 pl) n) == cells h1 l n')) let pop #a r n pl = let l = !* pl in let r = (!*l).data in let next = (!*l).next in (**) let h1 = ST.get () in (**) assert (cells h1 l n == l :: cells h1 next (List.Tot.tl n)); (**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 l n)); (**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 next (List.Tot.tl n))); pl *= next; B.free l; r val free_: (#a: Type) -> (#n: G.erased (list a)) -> (l: t a) -> ST unit (requires (fun h -> well_formed h l n /\ invariant h l n )) (ensures (fun h0 _ h1 -> B.(modifies (footprint h0 l n) h0 h1))) let rec free_ #a #n l = if B.is_null l then () else begin let tl: G.erased (list a) = G.hide (L.tl (G.reveal n)) in free_ #_ #tl (!*l).next; B.free l end val free: (#a: Type) -> (#n: G.erased (list a)) -> (pl: B.pointer (t a)) -> ST unit (requires (fun h -> let l = B.deref h pl in B.live h pl /\ well_formed h l n /\ invariant h l n /\ B.loc_disjoint (B.loc_buffer pl) (footprint h l n) )) (ensures (fun h0 _ h1 -> let l = B.deref h1 pl in well_formed h1 l [] /\ invariant h1 l [] /\ footprint h1 l [] == B.loc_none /\ cells h1 l [] == [] /\ B.(modifies (footprint h0 (B.deref h0 pl) n `loc_union` loc_buffer pl) h0 h1))) let free #a #n pl = free_ #_ #n !*pl; pl *= B.null val length (#a: Type) (gn: G.erased (list a)) (l: t a): Stack UInt32.t (requires (fun h -> well_formed h l gn)) (ensures (fun h0 n h1 -> h0 == h1 /\ U32.v n = L.length (G.reveal gn) )) let rec length #a gn l = if B.is_null l then 0ul else let open U32 in let c = !* l in let next = c.next in let n = length (G.hide (L.tail (G.reveal gn))) next in if n = 0xfffffffful then begin LowStar.Failure.failwith "Integer overflow in LowStar.LinkedList.length" end else n +^ 1ul /// Small test /// ---------- val test: unit -> ST (Int32.t) (fun _ -> true) (fun _ _ _ -> true)
false
false
LowStar.Lib.LinkedList.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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 test: unit -> ST (Int32.t) (fun _ -> true) (fun _ _ _ -> true)
[]
LowStar.Lib.LinkedList.test
{ "file_name": "krmllib/LowStar.Lib.LinkedList.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
_: Prims.unit -> FStar.HyperStack.ST.ST FStar.Int32.t
{ "end_col": 3, "end_line": 485, "start_col": 13, "start_line": 478 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.ModInv", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_check_mod_inv_prime_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h n /\ live h a /\ disjoint n a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_check_mod_inv_prime (as_seq h0 n) (as_seq h0 a))
let bn_check_mod_inv_prime_st (t: limb_t) (len: BN.meta_len t) =
false
null
false
n: lbignum t len -> a: lbignum t len -> Stack (limb t) (requires fun h -> live h n /\ live h a /\ disjoint n a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_check_mod_inv_prime (as_seq h0 n) (as_seq h0 a))
{ "checked_file": "Hacl.Bignum.ModInv.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.ModInv.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.ModInv.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Lib.Buffer.modifies0", "Prims.eq2", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.ModInv.bn_check_mod_inv_prime", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq" ]
[]
module Hacl.Bignum.ModInv open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module S = Hacl.Spec.Bignum.ModInv module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module SD = Hacl.Spec.Bignum.Definitions #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract
false
false
Hacl.Bignum.ModInv.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 bn_check_mod_inv_prime_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
[]
Hacl.Bignum.ModInv.bn_check_mod_inv_prime_st
{ "file_name": "code/bignum/Hacl.Bignum.ModInv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
{ "end_col": 62, "end_line": 29, "start_col": 4, "start_line": 24 }
Prims.Tot
val bn_check_mod_inv_prime: #t:limb_t -> len:BN.meta_len t -> bn_check_mod_inv_prime_st t len
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.ModInv", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_check_mod_inv_prime #t len n a = let m0 = BM.bn_check_modulus n in let m1 = BN.bn_is_zero_mask len a in let m2 = BN.bn_lt_mask len a n in m0 &. (lognot m1) &. m2
val bn_check_mod_inv_prime: #t:limb_t -> len:BN.meta_len t -> bn_check_mod_inv_prime_st t len let bn_check_mod_inv_prime #t len n a =
false
null
false
let m0 = BM.bn_check_modulus n in let m1 = BN.bn_is_zero_mask len a in let m2 = BN.bn_lt_mask len a n in m0 &. (lognot m1) &. m2
{ "checked_file": "Hacl.Bignum.ModInv.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.ModInv.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.ModInv.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.SEC", "Lib.IntTypes.lognot", "Hacl.Bignum.Definitions.limb", "Hacl.Bignum.bn_lt_mask", "Hacl.Bignum.bn_is_zero_mask", "Hacl.Bignum.Montgomery.bn_check_modulus" ]
[]
module Hacl.Bignum.ModInv open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module S = Hacl.Spec.Bignum.ModInv module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module SD = Hacl.Spec.Bignum.Definitions #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let bn_check_mod_inv_prime_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h n /\ live h a /\ disjoint n a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_check_mod_inv_prime (as_seq h0 n) (as_seq h0 a)) inline_for_extraction noextract
false
false
Hacl.Bignum.ModInv.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 bn_check_mod_inv_prime: #t:limb_t -> len:BN.meta_len t -> bn_check_mod_inv_prime_st t len
[]
Hacl.Bignum.ModInv.bn_check_mod_inv_prime
{ "file_name": "code/bignum/Hacl.Bignum.ModInv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len t -> Hacl.Bignum.ModInv.bn_check_mod_inv_prime_st t len
{ "end_col": 25, "end_line": 38, "start_col": 39, "start_line": 34 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.ModInv", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mod_inv_prime_st (t:limb_t) (len:BN.meta_len t) = nBits:size_t -> n:lbignum t len -> a:lbignum t len -> res:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h a /\ live h res /\ disjoint res n /\ disjoint res a /\ disjoint n a /\ v nBits / bits t < v len /\ pow2 (v nBits) < bn_v h n /\ S.bn_mod_inv_prime_pre (as_seq h n) (as_seq h a)) (ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\ bn_v h1 res * bn_v h0 a % bn_v h0 n = 1)
let bn_mod_inv_prime_st (t: limb_t) (len: BN.meta_len t) =
false
null
false
nBits: size_t -> n: lbignum t len -> a: lbignum t len -> res: lbignum t len -> Stack unit (requires fun h -> live h n /\ live h a /\ live h res /\ disjoint res n /\ disjoint res a /\ disjoint n a /\ v nBits / bits t < v len /\ pow2 (v nBits) < bn_v h n /\ S.bn_mod_inv_prime_pre (as_seq h n) (as_seq h a)) (ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\ bn_v h1 res * bn_v h0 a % bn_v h0 n = 1)
{ "checked_file": "Hacl.Bignum.ModInv.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.ModInv.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.ModInv.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.lbignum", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Division", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.bits", "Prims.pow2", "Hacl.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.ModInv.bn_mod_inv_prime_pre", "Lib.Buffer.as_seq", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "FStar.Mul.op_Star" ]
[]
module Hacl.Bignum.ModInv open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module S = Hacl.Spec.Bignum.ModInv module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module SD = Hacl.Spec.Bignum.Definitions #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let bn_check_mod_inv_prime_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h n /\ live h a /\ disjoint n a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_check_mod_inv_prime (as_seq h0 n) (as_seq h0 a)) inline_for_extraction noextract val bn_check_mod_inv_prime: #t:limb_t -> len:BN.meta_len t -> bn_check_mod_inv_prime_st t len let bn_check_mod_inv_prime #t len n a = let m0 = BM.bn_check_modulus n in let m1 = BN.bn_is_zero_mask len a in let m2 = BN.bn_lt_mask len a n in m0 &. (lognot m1) &. m2 inline_for_extraction noextract val bn_mod_inv_prime_n2: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> res:lbignum t len -> Stack unit (requires fun h -> 1 < bn_v h n /\ live h n /\ live h res /\ disjoint res n) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mod_inv_prime_n2 (as_seq h0 n)) let bn_mod_inv_prime_n2 #t len n res = let c = BN.bn_sub1 len n (uint #t #SEC 2) res in LowStar.Ignore.ignore c; () inline_for_extraction noextract let bn_mod_inv_prime_precomp_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t len -> res:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h a /\ live h res /\ disjoint res n /\ disjoint res a /\ disjoint n a /\ disjoint res r2 /\ disjoint a r2 /\ disjoint n r2 /\ S.bn_mod_inv_prime_pre (as_seq h n) (as_seq h a) /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n /\ (1 + bn_v h n * v mu) % pow2 (bits t) == 0) (ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\ bn_v h1 res * bn_v h0 a % bn_v h0 n = 1) inline_for_extraction noextract val mk_bn_mod_inv_prime_precomp: #t:limb_t -> len:BN.meta_len t -> bn_mod_exp_precomp:BE.bn_mod_exp_precomp_st t len -> bn_mod_inv_prime_precomp_st t len let mk_bn_mod_inv_prime_precomp #t len bn_mod_exp_precomp n mu r2 a res = let h0 = ST.get () in push_frame (); let n2 = create len (uint #t #SEC 0) in bn_mod_inv_prime_n2 #t len n n2; SD.bn_eval_bound (as_seq h0 n) (v len); bn_mod_exp_precomp n mu r2 a (size (bits t) *! len) n2 res; let h1 = ST.get () in assert (bn_v h1 res == Lib.NatMod.pow_mod #(bn_v h0 n) (bn_v h0 a) (bn_v h1 n2)); S.mod_inv_prime_lemma (bn_v h0 n) (bn_v h0 a); pop_frame () inline_for_extraction noextract
false
false
Hacl.Bignum.ModInv.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 bn_mod_inv_prime_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
[]
Hacl.Bignum.ModInv.bn_mod_inv_prime_st
{ "file_name": "code/bignum/Hacl.Bignum.ModInv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
{ "end_col": 44, "end_line": 114, "start_col": 4, "start_line": 102 }