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 va_codegen_success_Prefetchnta : v:va_operand_opr64 -> Tot va_pbool | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_codegen_success_Prefetchnta v =
(va_ttrue ()) | val va_codegen_success_Prefetchnta : v:va_operand_opr64 -> Tot va_pbool
let va_codegen_success_Prefetchnta v = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Decls.va_ttrue",
"Vale.X64.Decls.va_pbool"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"]
let va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Nat64Equal dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Nat64Equal (va_code_Nat64Equal dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_reg_opr64
src va_sM (va_update_operand_reg_opr64 dst va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_reg_opr64 src; va_mod_reg_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Comment
[@ "opaque_to_smt"]
let va_code_Comment c =
(mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_Comment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Comment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_Comment) (va_code_Comment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Comment c)
(S.AnnotateComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Comment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Comment (va_code_Comment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- LargeComment
[@ "opaque_to_smt"]
let va_code_LargeComment c =
(mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_LargeComment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_LargeComment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_LargeComment) (va_code_LargeComment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_LargeComment c)
(S.AnnotateLargeComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_LargeComment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_LargeComment (va_code_LargeComment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- NoNewline
[@ "opaque_to_smt"]
let va_code_NoNewline () =
(mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0)))
[@ "opaque_to_smt"]
let va_codegen_success_NoNewline () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_NoNewline va_b0 va_s0 =
va_reveal_opaque (`%va_code_NoNewline) (va_code_NoNewline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace
0))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_NoNewline va_s0 va_k =
let (va_sM, va_f0) = va_lemma_NoNewline (va_code_NoNewline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Newline
[@ "opaque_to_smt"]
let va_code_Newline () =
(mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ())))
[@ "opaque_to_smt"]
let va_codegen_success_Newline () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Newline va_b0 va_s0 =
va_reveal_opaque (`%va_code_Newline) (va_code_Newline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ()))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline
()))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Newline va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Newline (va_code_Newline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Space
[@ "opaque_to_smt"]
let va_code_Space n =
(mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace n)))
[@ "opaque_to_smt"]
let va_codegen_success_Space n =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Space va_b0 va_s0 n =
va_reveal_opaque (`%va_code_Space) (va_code_Space n);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace n))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace
n))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Space n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Space (va_code_Space n) va_s0 n in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Prefetchnta
[@ "opaque_to_smt"]
let va_code_Prefetchnta v =
(mk_ins (make_instr_annotate (I.ins_Prefetchnta) (S.AnnotatePrefetchnta ()) v))
[@ "opaque_to_smt"] | false | true | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_Prefetchnta : v:va_operand_opr64 -> Tot va_pbool | [] | Vale.X64.InsBasic.va_codegen_success_Prefetchnta | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | v: Vale.X64.Decls.va_operand_opr64 -> Vale.X64.Decls.va_pbool | {
"end_col": 15,
"end_line": 1195,
"start_col": 2,
"start_line": 1195
} |
Prims.Ghost | val va_lemma_Sbb64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 ->
src:va_operand_opr64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Sbb64 dst src) va_s0 /\ va_is_dst_dst_opr64 dst va_s0
/\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.valid_cf (va_get_flags
va_s0)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_dst_opr64 va_sM dst == Vale.Arch.Types.sub_wrap64 (va_eval_dst_opr64 va_s0 dst)
(Vale.Arch.Types.add_wrap64 (va_eval_opr64 va_s0 src) (if Vale.X64.Decls.cf (va_get_flags
va_s0) then 1 else 0)) /\ Vale.X64.Decls.updated_cf (va_get_flags va_sM) (va_eval_dst_opr64
va_s0 dst - (va_eval_opr64 va_s0 src + (if Vale.X64.Decls.cf (va_get_flags va_s0) then 1 else
0)) < 0) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_dst_opr64 dst va_sM va_s0))))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM) | val va_lemma_Sbb64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 ->
src:va_operand_opr64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Sbb64 dst src) va_s0 /\ va_is_dst_dst_opr64 dst va_s0
/\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.valid_cf (va_get_flags
va_s0)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_dst_opr64 va_sM dst == Vale.Arch.Types.sub_wrap64 (va_eval_dst_opr64 va_s0 dst)
(Vale.Arch.Types.add_wrap64 (va_eval_opr64 va_s0 src) (if Vale.X64.Decls.cf (va_get_flags
va_s0) then 1 else 0)) /\ Vale.X64.Decls.updated_cf (va_get_flags va_sM) (va_eval_dst_opr64
va_s0 dst - (va_eval_opr64 va_s0 src + (if Vale.X64.Decls.cf (va_get_flags va_s0) then 1 else
0)) < 0) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_dst_opr64 dst va_sM va_s0)))))
let va_lemma_Sbb64 va_b0 va_s0 dst src = | false | null | false | va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let va_sM, va_fM = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.opFlagsCf",
"Vale.X64.Instruction_s.op64",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.HavocFlags",
"Vale.X64.Instructions_s.ins_Sbb64",
"Prims.unit",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_Sbb64"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_Sbb64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 ->
src:va_operand_opr64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Sbb64 dst src) va_s0 /\ va_is_dst_dst_opr64 dst va_s0
/\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.valid_cf (va_get_flags
va_s0)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_dst_opr64 va_sM dst == Vale.Arch.Types.sub_wrap64 (va_eval_dst_opr64 va_s0 dst)
(Vale.Arch.Types.add_wrap64 (va_eval_opr64 va_s0 src) (if Vale.X64.Decls.cf (va_get_flags
va_s0) then 1 else 0)) /\ Vale.X64.Decls.updated_cf (va_get_flags va_sM) (va_eval_dst_opr64
va_s0 dst - (va_eval_opr64 va_s0 src + (if Vale.X64.Decls.cf (va_get_flags va_s0) then 1 else
0)) < 0) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_dst_opr64 dst va_sM va_s0))))) | [] | Vale.X64.InsBasic.va_lemma_Sbb64 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
va_b0: Vale.X64.Decls.va_code ->
va_s0: Vale.X64.Decls.va_state ->
dst: Vale.X64.Decls.va_operand_dst_opr64 ->
src: Vale.X64.Decls.va_operand_opr64
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 363,
"start_col": 2,
"start_line": 359
} |
Prims.Ghost | val va_lemma_IMul64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 ->
src:va_operand_opr64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_IMul64 dst src) va_s0 /\ va_is_dst_dst_opr64 dst va_s0
/\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ va_mul_nat (va_eval_dst_opr64 va_s0 dst)
(va_eval_opr64 va_s0 src) < pow2_64))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_dst_opr64 va_sM dst == va_mul_nat (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0
src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_dst_opr64 dst va_sM va_s0))))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM) | val va_lemma_IMul64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 ->
src:va_operand_opr64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_IMul64 dst src) va_s0 /\ va_is_dst_dst_opr64 dst va_s0
/\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ va_mul_nat (va_eval_dst_opr64 va_s0 dst)
(va_eval_opr64 va_s0 src) < pow2_64))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_dst_opr64 va_sM dst == va_mul_nat (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0
src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_dst_opr64 dst va_sM va_s0)))))
let va_lemma_IMul64 va_b0 va_s0 dst src = | false | null | false | va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let va_sM, va_fM = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Prims.unit",
"Vale.X64.Decls.lemma_mul_in_bounds",
"Vale.X64.Decls.va_eval_dst_opr64",
"Vale.X64.Decls.va_eval_opr64",
"Vale.X64.Decls.lemma_mul_nat",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.op64",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.HavocFlags",
"Vale.X64.Instructions_s.ins_IMul64",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_IMul64"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_IMul64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 ->
src:va_operand_opr64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_IMul64 dst src) va_s0 /\ va_is_dst_dst_opr64 dst va_s0
/\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ va_mul_nat (va_eval_dst_opr64 va_s0 dst)
(va_eval_opr64 va_s0 src) < pow2_64))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_dst_opr64 va_sM dst == va_mul_nat (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0
src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_dst_opr64 dst va_sM va_s0))))) | [] | Vale.X64.InsBasic.va_lemma_IMul64 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
va_b0: Vale.X64.Decls.va_code ->
va_s0: Vale.X64.Decls.va_state ->
dst: Vale.X64.Decls.va_operand_dst_opr64 ->
src: Vale.X64.Decls.va_operand_opr64
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 470,
"start_col": 2,
"start_line": 464
} |
Prims.Ghost | val va_lemma_Cpuid_Sha : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Sha ()) va_s0 /\ va_get_ok va_s0 /\ va_get_reg64
rRax va_s0 = 7 /\ va_get_reg64 rRcx va_s0 = 0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRbx va_sM) 536870912 > 0 == sha_enabled /\ va_state_eq
va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM) | val va_lemma_Cpuid_Sha : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Sha ()) va_s0 /\ va_get_ok va_s0 /\ va_get_reg64
rRax va_s0 = 7 /\ va_get_reg64 rRcx va_s0 = 0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRbx va_sM) 536870912 > 0 == sha_enabled /\ va_state_eq
va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0)))))))
let va_lemma_Cpuid_Sha va_b0 va_s0 = | false | null | false | va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let va_sM, va_fM = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Prims.unit",
"Vale.X64.CPU_Features_s.cpuid_features",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.one64Reg",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Instruction_s.out",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRdx",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Cpuid",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_Cpuid_Sha"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_Cpuid_Sha : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Sha ()) va_s0 /\ va_get_ok va_s0 /\ va_get_reg64
rRax va_s0 = 7 /\ va_get_reg64 rRcx va_s0 = 0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRbx va_sM) 536870912 > 0 == sha_enabled /\ va_state_eq
va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))) | [] | Vale.X64.InsBasic.va_lemma_Cpuid_Sha | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 654,
"start_col": 2,
"start_line": 649
} |
Prims.Ghost | val va_lemma_Cpuid_Adx_Bmi2 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 /\ va_get_ok va_s0 /\
va_get_reg64 rRax va_s0 = 7 /\ va_get_reg64 rRcx va_s0 = 0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRbx va_sM) 256 > 0 == bmi2_enabled /\
Vale.Arch.Types.iand64 (va_get_reg64 rRbx va_sM) 524288 > 0 == adx_enabled /\ va_state_eq va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM) | val va_lemma_Cpuid_Adx_Bmi2 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 /\ va_get_ok va_s0 /\
va_get_reg64 rRax va_s0 = 7 /\ va_get_reg64 rRcx va_s0 = 0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRbx va_sM) 256 > 0 == bmi2_enabled /\
Vale.Arch.Types.iand64 (va_get_reg64 rRbx va_sM) 524288 > 0 == adx_enabled /\ va_state_eq va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0)))))))
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 = | false | null | false | va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let va_sM, va_fM = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Prims.unit",
"Vale.X64.CPU_Features_s.cpuid_features",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.one64Reg",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Instruction_s.out",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRdx",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Cpuid",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_Cpuid_Adx_Bmi2"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_Cpuid_Adx_Bmi2 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 /\ va_get_ok va_s0 /\
va_get_reg64 rRax va_s0 = 7 /\ va_get_reg64 rRcx va_s0 = 0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRbx va_sM) 256 > 0 == bmi2_enabled /\
Vale.Arch.Types.iand64 (va_get_reg64 rRbx va_sM) 524288 > 0 == adx_enabled /\ va_state_eq va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))) | [] | Vale.X64.InsBasic.va_lemma_Cpuid_Adx_Bmi2 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 686,
"start_col": 2,
"start_line": 681
} |
Prims.Ghost | val va_wpProof_Cpuid_Avx512 : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Cpuid_Avx512 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Cpuid_Avx512 ()) ([va_Mod_reg64 rRdx;
va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax]) va_s0 va_k ((va_sM, va_f0, va_g)))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | val va_wpProof_Cpuid_Avx512 : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Cpuid_Avx512 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Cpuid_Avx512 ()) ([va_Mod_reg64 rRdx;
va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_Cpuid_Avx512 va_s0 va_k = | false | null | false | let va_sM, va_f0 = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM
(va_update_reg64 rRdx
va_sM
(va_update_reg64 rRcx
va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0)))))
);
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM
va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRax",
"Prims.Nil",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_reg64",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.X64.InsBasic.va_lemma_Cpuid_Avx512",
"Vale.X64.InsBasic.va_code_Cpuid_Avx512"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM) | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wpProof_Cpuid_Avx512 : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Cpuid_Avx512 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Cpuid_Avx512 ()) ([va_Mod_reg64 rRdx;
va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax]) va_s0 va_k ((va_sM, va_f0, va_g)))) | [] | Vale.X64.InsBasic.va_wpProof_Cpuid_Avx512 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | {
"end_col": 22,
"end_line": 890,
"start_col": 40,
"start_line": 882
} |
Prims.Ghost | val va_lemma_Cpuid_Avx2 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Avx2 ()) va_s0 /\ va_get_ok va_s0 /\
va_get_reg64 rRax va_s0 = 7 /\ va_get_reg64 rRcx va_s0 = 0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRbx va_sM) 32 > 0 == avx2_cpuid_enabled /\ va_state_eq
va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM) | val va_lemma_Cpuid_Avx2 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Avx2 ()) va_s0 /\ va_get_ok va_s0 /\
va_get_reg64 rRax va_s0 = 7 /\ va_get_reg64 rRcx va_s0 = 0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRbx va_sM) 32 > 0 == avx2_cpuid_enabled /\ va_state_eq
va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0)))))))
let va_lemma_Cpuid_Avx2 va_b0 va_s0 = | false | null | false | va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let va_sM, va_fM = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Prims.unit",
"Vale.X64.CPU_Features_s.cpuid_features",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.one64Reg",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Instruction_s.out",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRdx",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Cpuid",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_Cpuid_Avx2"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_Cpuid_Avx2 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Avx2 ()) va_s0 /\ va_get_ok va_s0 /\
va_get_reg64 rRax va_s0 = 7 /\ va_get_reg64 rRcx va_s0 = 0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRbx va_sM) 32 > 0 == avx2_cpuid_enabled /\ va_state_eq
va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))) | [] | Vale.X64.InsBasic.va_lemma_Cpuid_Avx2 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 750,
"start_col": 2,
"start_line": 745
} |
Prims.Ghost | val va_wpProof_Cpuid_Osxsave : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Cpuid_Osxsave va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Cpuid_Osxsave ()) ([va_Mod_reg64 rRdx;
va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax]) va_s0 va_k ((va_sM, va_f0, va_g)))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | val va_wpProof_Cpuid_Osxsave : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Cpuid_Osxsave va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Cpuid_Osxsave ()) ([va_Mod_reg64 rRdx;
va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_Cpuid_Osxsave va_s0 va_k = | false | null | false | let va_sM, va_f0 = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM
(va_update_reg64 rRdx
va_sM
(va_update_reg64 rRcx
va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0)))))
);
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM
va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRax",
"Prims.Nil",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_reg64",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.X64.InsBasic.va_lemma_Cpuid_Osxsave",
"Vale.X64.InsBasic.va_code_Cpuid_Osxsave"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM) | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wpProof_Cpuid_Osxsave : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Cpuid_Osxsave va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Cpuid_Osxsave ()) ([va_Mod_reg64 rRdx;
va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax]) va_s0 va_k ((va_sM, va_f0, va_g)))) | [] | Vale.X64.InsBasic.va_wpProof_Cpuid_Osxsave | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | {
"end_col": 22,
"end_line": 922,
"start_col": 41,
"start_line": 914
} |
Prims.Ghost | val va_lemma_Cpuid_Movbe : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Movbe ()) va_s0 /\ va_get_ok va_s0 /\
va_get_reg64 rRax va_s0 = 1))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRcx va_sM) 4194304 > 0 == movbe_enabled /\ va_state_eq
va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM) | val va_lemma_Cpuid_Movbe : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Movbe ()) va_s0 /\ va_get_ok va_s0 /\
va_get_reg64 rRax va_s0 = 1))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRcx va_sM) 4194304 > 0 == movbe_enabled /\ va_state_eq
va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0)))))))
let va_lemma_Cpuid_Movbe va_b0 va_s0 = | false | null | false | va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let va_sM, va_fM = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Prims.unit",
"Vale.X64.CPU_Features_s.cpuid_features",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.one64Reg",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Instruction_s.out",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRdx",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Cpuid",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_Cpuid_Movbe"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_Cpuid_Movbe : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Movbe ()) va_s0 /\ va_get_ok va_s0 /\
va_get_reg64 rRax va_s0 = 1))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRcx va_sM) 4194304 > 0 == movbe_enabled /\ va_state_eq
va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))) | [] | Vale.X64.InsBasic.va_lemma_Cpuid_Movbe | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 814,
"start_col": 2,
"start_line": 809
} |
Prims.Ghost | val va_wpProof_Xgetbv_Avx : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Xgetbv_Avx va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Xgetbv_Avx ()) ([va_Mod_reg64 rRdx;
va_Mod_reg64 rRax]) va_s0 va_k ((va_sM, va_f0, va_g)))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | val va_wpProof_Xgetbv_Avx : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Xgetbv_Avx va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Xgetbv_Avx ()) ([va_Mod_reg64 rRdx;
va_Mod_reg64 rRax]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_Xgetbv_Avx va_s0 va_k = | false | null | false | let va_sM, va_f0 = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRax",
"Prims.Nil",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_reg64",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.X64.InsBasic.va_lemma_Xgetbv_Avx",
"Vale.X64.InsBasic.va_code_Xgetbv_Avx"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM) | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wpProof_Xgetbv_Avx : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Xgetbv_Avx va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Xgetbv_Avx ()) ([va_Mod_reg64 rRdx;
va_Mod_reg64 rRax]) va_s0 va_k ((va_sM, va_f0, va_g)))) | [] | Vale.X64.InsBasic.va_wpProof_Xgetbv_Avx | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | {
"end_col": 22,
"end_line": 953,
"start_col": 38,
"start_line": 946
} |
Prims.Ghost | val va_lemma_Cpuid_Rdrand : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Rdrand ()) va_s0 /\ va_get_ok va_s0 /\
va_get_reg64 rRax va_s0 = 1))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRcx va_sM) 1073741824 > 0 == rdrand_enabled /\
va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx
va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM) | val va_lemma_Cpuid_Rdrand : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Rdrand ()) va_s0 /\ va_get_ok va_s0 /\
va_get_reg64 rRax va_s0 = 1))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRcx va_sM) 1073741824 > 0 == rdrand_enabled /\
va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx
va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0)))))))
let va_lemma_Cpuid_Rdrand va_b0 va_s0 = | false | null | false | va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let va_sM, va_fM = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Prims.unit",
"Vale.X64.CPU_Features_s.cpuid_features",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.one64Reg",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Instruction_s.out",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRdx",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Cpuid",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_Cpuid_Rdrand"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_Cpuid_Rdrand : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Rdrand ()) va_s0 /\ va_get_ok va_s0 /\
va_get_reg64 rRax va_s0 = 1))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRcx va_sM) 1073741824 > 0 == rdrand_enabled /\
va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx
va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))) | [] | Vale.X64.InsBasic.va_lemma_Cpuid_Rdrand | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 846,
"start_col": 2,
"start_line": 841
} |
Prims.Ghost | val va_lemma_Xgetbv_Avx : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Xgetbv_Avx ()) va_s0 /\ va_get_ok va_s0 /\
osxsave_enabled /\ va_get_reg64 rRcx va_s0 = 0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRax va_sM) 2 > 0 == sse_xcr0_enabled /\
Vale.Arch.Types.iand64 (va_get_reg64 rRax va_sM) 4 > 0 == avx_xcr0_enabled /\ va_state_eq va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM) | val va_lemma_Xgetbv_Avx : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Xgetbv_Avx ()) va_s0 /\ va_get_ok va_s0 /\
osxsave_enabled /\ va_get_reg64 rRcx va_s0 = 0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRax va_sM) 2 > 0 == sse_xcr0_enabled /\
Vale.Arch.Types.iand64 (va_get_reg64 rRax va_sM) 4 > 0 == avx_xcr0_enabled /\ va_state_eq va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0)))))
let va_lemma_Xgetbv_Avx va_b0 va_s0 = | false | null | false | va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let va_sM, va_fM = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Prims.unit",
"Vale.X64.CPU_Features_s.xgetbv_features",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.out",
"Vale.X64.Instruction_s.one64Reg",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Machine_s.rRdx",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Xgetbv",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_Xgetbv_Avx"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_Xgetbv_Avx : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Xgetbv_Avx ()) va_s0 /\ va_get_ok va_s0 /\
osxsave_enabled /\ va_get_reg64 rRcx va_s0 = 0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRax va_sM) 2 > 0 == sse_xcr0_enabled /\
Vale.Arch.Types.iand64 (va_get_reg64 rRax va_sM) 4 > 0 == avx_xcr0_enabled /\ va_state_eq va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))) | [] | Vale.X64.InsBasic.va_lemma_Xgetbv_Avx | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 942,
"start_col": 2,
"start_line": 937
} |
Prims.Ghost | val va_lemma_Cpuid_Osxsave : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Osxsave ()) va_s0 /\ va_get_ok va_s0 /\
va_get_reg64 rRax va_s0 = 1))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRcx va_sM) 134217728 > 0 == osxsave_enabled /\
va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx
va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM) | val va_lemma_Cpuid_Osxsave : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Osxsave ()) va_s0 /\ va_get_ok va_s0 /\
va_get_reg64 rRax va_s0 = 1))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRcx va_sM) 134217728 > 0 == osxsave_enabled /\
va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx
va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0)))))))
let va_lemma_Cpuid_Osxsave va_b0 va_s0 = | false | null | false | va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let va_sM, va_fM = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Prims.unit",
"Vale.X64.CPU_Features_s.cpuid_features",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.one64Reg",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Instruction_s.out",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRdx",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Cpuid",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_Cpuid_Osxsave"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_Cpuid_Osxsave : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Cpuid_Osxsave ()) va_s0 /\ va_get_ok va_s0 /\
va_get_reg64 rRax va_s0 = 1))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRcx va_sM) 134217728 > 0 == osxsave_enabled /\
va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx
va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))) | [] | Vale.X64.InsBasic.va_lemma_Cpuid_Osxsave | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 910,
"start_col": 2,
"start_line": 905
} |
Prims.Ghost | val va_wpProof_Xgetbv_Avx512 : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Xgetbv_Avx512 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Xgetbv_Avx512 ()) ([va_Mod_reg64 rRdx;
va_Mod_reg64 rRax]) va_s0 va_k ((va_sM, va_f0, va_g)))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | val va_wpProof_Xgetbv_Avx512 : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Xgetbv_Avx512 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Xgetbv_Avx512 ()) ([va_Mod_reg64 rRdx;
va_Mod_reg64 rRax]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_Xgetbv_Avx512 va_s0 va_k = | false | null | false | let va_sM, va_f0 = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRax",
"Prims.Nil",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_reg64",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.X64.InsBasic.va_lemma_Xgetbv_Avx512",
"Vale.X64.InsBasic.va_code_Xgetbv_Avx512"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM) | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wpProof_Xgetbv_Avx512 : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Xgetbv_Avx512 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Xgetbv_Avx512 ()) ([va_Mod_reg64 rRdx;
va_Mod_reg64 rRax]) va_s0 va_k ((va_sM, va_f0, va_g)))) | [] | Vale.X64.InsBasic.va_wpProof_Xgetbv_Avx512 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | {
"end_col": 22,
"end_line": 984,
"start_col": 41,
"start_line": 977
} |
Prims.Ghost | val va_lemma_Mulx64 : va_b0:va_code -> va_s0:va_state -> dst_hi:va_operand_dst_opr64 ->
dst_lo:va_operand_dst_opr64 -> src:va_operand_opr64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Mulx64 dst_hi dst_lo src) va_s0 /\ va_is_dst_dst_opr64
dst_hi va_s0 /\ va_is_dst_dst_opr64 dst_lo va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok
va_s0 /\ bmi2_enabled /\ dst_hi =!= dst_lo))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_mul_nat pow2_64 (va_eval_dst_opr64 va_sM dst_hi) + va_eval_dst_opr64 va_sM dst_lo ==
va_mul_nat (va_get_reg64 rRdx va_s0) (va_eval_opr64 va_s0 src) /\ va_state_eq va_sM
(va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM (va_update_operand_dst_opr64
dst_hi va_sM va_s0))))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM) | val va_lemma_Mulx64 : va_b0:va_code -> va_s0:va_state -> dst_hi:va_operand_dst_opr64 ->
dst_lo:va_operand_dst_opr64 -> src:va_operand_opr64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Mulx64 dst_hi dst_lo src) va_s0 /\ va_is_dst_dst_opr64
dst_hi va_s0 /\ va_is_dst_dst_opr64 dst_lo va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok
va_s0 /\ bmi2_enabled /\ dst_hi =!= dst_lo))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_mul_nat pow2_64 (va_eval_dst_opr64 va_sM dst_hi) + va_eval_dst_opr64 va_sM dst_lo ==
va_mul_nat (va_get_reg64 rRdx va_s0) (va_eval_opr64 va_s0 src) /\ va_state_eq va_sM
(va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM (va_update_operand_dst_opr64
dst_hi va_sM va_s0)))))
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src = | false | null | false | va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let va_sM, va_fM = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Prims.unit",
"Vale.X64.InsBasic.lemma_fundamental_div_mod",
"Vale.X64.Decls.va_get_reg64",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Decls.va_eval_opr64",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.out",
"Vale.X64.Instruction_s.op64",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.one64Reg",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Mulx64",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_Mulx64"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_Mulx64 : va_b0:va_code -> va_s0:va_state -> dst_hi:va_operand_dst_opr64 ->
dst_lo:va_operand_dst_opr64 -> src:va_operand_opr64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Mulx64 dst_hi dst_lo src) va_s0 /\ va_is_dst_dst_opr64
dst_hi va_s0 /\ va_is_dst_dst_opr64 dst_lo va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok
va_s0 /\ bmi2_enabled /\ dst_hi =!= dst_lo))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_mul_nat pow2_64 (va_eval_dst_opr64 va_sM dst_hi) + va_eval_dst_opr64 va_sM dst_lo ==
va_mul_nat (va_get_reg64 rRdx va_s0) (va_eval_opr64 va_s0 src) /\ va_state_eq va_sM
(va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM (va_update_operand_dst_opr64
dst_hi va_sM va_s0))))) | [] | Vale.X64.InsBasic.va_lemma_Mulx64 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
va_b0: Vale.X64.Decls.va_code ->
va_s0: Vale.X64.Decls.va_state ->
dst_hi: Vale.X64.Decls.va_operand_dst_opr64 ->
dst_lo: Vale.X64.Decls.va_operand_dst_opr64 ->
src: Vale.X64.Decls.va_operand_opr64
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 434,
"start_col": 2,
"start_line": 429
} |
Prims.Ghost | val va_wpProof_Comment : c:string -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Comment c va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Comment c) ([]) va_s0 va_k ((va_sM,
va_f0, va_g)))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_wpProof_Comment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Comment (va_code_Comment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | val va_wpProof_Comment : c:string -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Comment c va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Comment c) ([]) va_s0 va_k ((va_sM,
va_f0, va_g))))
let va_wpProof_Comment c va_s0 va_k = | false | null | false | let va_sM, va_f0 = va_lemma_Comment (va_code_Comment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Prims.string",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Nil",
"Vale.X64.QuickCode.mod_t",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.X64.InsBasic.va_lemma_Comment",
"Vale.X64.InsBasic.va_code_Comment"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"]
let va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Nat64Equal dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Nat64Equal (va_code_Nat64Equal dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_reg_opr64
src va_sM (va_update_operand_reg_opr64 dst va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_reg_opr64 src; va_mod_reg_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Comment
[@ "opaque_to_smt"]
let va_code_Comment c =
(mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_Comment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Comment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_Comment) (va_code_Comment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Comment c)
(S.AnnotateComment c))) va_s0 in
(va_sM, va_fM) | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wpProof_Comment : c:string -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Comment c va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Comment c) ([]) va_s0 va_k ((va_sM,
va_f0, va_g)))) | [] | Vale.X64.InsBasic.va_wpProof_Comment | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
c: Prims.string ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | {
"end_col": 22,
"end_line": 1063,
"start_col": 37,
"start_line": 1057
} |
Prims.Ghost | val va_lemma_Xgetbv_Avx512 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Xgetbv_Avx512 ()) va_s0 /\ va_get_ok va_s0 /\
osxsave_enabled /\ va_get_reg64 rRcx va_s0 = 0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRax va_sM) 32 > 0 == opmask_xcr0_enabled /\
Vale.Arch.Types.iand64 (va_get_reg64 rRax va_sM) 64 > 0 == zmm_hi256_xcr0_enabled /\
Vale.Arch.Types.iand64 (va_get_reg64 rRax va_sM) 128 > 0 == hi16_zmm_xcr0_enabled /\
va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM
va_s0))))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM) | val va_lemma_Xgetbv_Avx512 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Xgetbv_Avx512 ()) va_s0 /\ va_get_ok va_s0 /\
osxsave_enabled /\ va_get_reg64 rRcx va_s0 = 0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRax va_sM) 32 > 0 == opmask_xcr0_enabled /\
Vale.Arch.Types.iand64 (va_get_reg64 rRax va_sM) 64 > 0 == zmm_hi256_xcr0_enabled /\
Vale.Arch.Types.iand64 (va_get_reg64 rRax va_sM) 128 > 0 == hi16_zmm_xcr0_enabled /\
va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM
va_s0)))))
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 = | false | null | false | va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let va_sM, va_fM = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Prims.unit",
"Vale.X64.CPU_Features_s.xgetbv_features",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.out",
"Vale.X64.Instruction_s.one64Reg",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Machine_s.rRdx",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Xgetbv",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_Xgetbv_Avx512"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_Xgetbv_Avx512 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Xgetbv_Avx512 ()) va_s0 /\ va_get_ok va_s0 /\
osxsave_enabled /\ va_get_reg64 rRcx va_s0 = 0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.Arch.Types.iand64 (va_get_reg64 rRax va_sM) 32 > 0 == opmask_xcr0_enabled /\
Vale.Arch.Types.iand64 (va_get_reg64 rRax va_sM) 64 > 0 == zmm_hi256_xcr0_enabled /\
Vale.Arch.Types.iand64 (va_get_reg64 rRax va_sM) 128 > 0 == hi16_zmm_xcr0_enabled /\
va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM
va_s0))))) | [] | Vale.X64.InsBasic.va_lemma_Xgetbv_Avx512 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 973,
"start_col": 2,
"start_line": 968
} |
Prims.Ghost | val va_lemma_Comment : va_b0:va_code -> va_s0:va_state -> c:string
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Comment c) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_ok va_sM va_s0))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_Comment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_Comment) (va_code_Comment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Comment c)
(S.AnnotateComment c))) va_s0 in
(va_sM, va_fM) | val va_lemma_Comment : va_b0:va_code -> va_s0:va_state -> c:string
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Comment c) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_ok va_sM va_s0)))
let va_lemma_Comment va_b0 va_s0 c = | false | null | false | va_reveal_opaque (`%va_code_Comment) (va_code_Comment c);
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0;
let va_sM, va_fM =
va_eval_ins (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0
in
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Prims.string",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr_annotate",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Comment",
"Vale.X64.Machine_Semantics_s.AnnotateComment",
"Vale.X64.Instruction_s.InstrTypeRecord",
"Prims.unit",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_Comment"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"]
let va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Nat64Equal dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Nat64Equal (va_code_Nat64Equal dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_reg_opr64
src va_sM (va_update_operand_reg_opr64 dst va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_reg_opr64 src; va_mod_reg_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Comment
[@ "opaque_to_smt"]
let va_code_Comment c =
(mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_Comment c =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_Comment : va_b0:va_code -> va_s0:va_state -> c:string
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Comment c) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_ok va_sM va_s0))) | [] | Vale.X64.InsBasic.va_lemma_Comment | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> c: Prims.string
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 1053,
"start_col": 2,
"start_line": 1048
} |
Prims.Ghost | val va_lemma_Nat64Equal : va_b0:va_code -> va_s0:va_state -> dst:va_operand_reg_opr64 ->
src:va_operand_reg_opr64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Nat64Equal dst src) va_s0 /\ va_is_dst_reg_opr64 dst
va_s0 /\ va_is_dst_reg_opr64 src va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (if
(va_eval_reg_opr64 va_s0 src = 18446744073709551615) then (va_eval_reg_opr64 va_sM dst = 0)
else (va_eval_reg_opr64 va_sM dst = 1)) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_ok va_sM (va_update_operand_reg_opr64 src va_sM (va_update_operand_reg_opr64 dst
va_sM va_s0)))))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM) | val va_lemma_Nat64Equal : va_b0:va_code -> va_s0:va_state -> dst:va_operand_reg_opr64 ->
src:va_operand_reg_opr64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Nat64Equal dst src) va_s0 /\ va_is_dst_reg_opr64 dst
va_s0 /\ va_is_dst_reg_opr64 src va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (if
(va_eval_reg_opr64 va_s0 src = 18446744073709551615) then (va_eval_reg_opr64 va_sM dst = 0)
else (va_eval_reg_opr64 va_sM dst = 1)) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_ok va_sM (va_update_operand_reg_opr64 src va_sM (va_update_operand_reg_opr64 dst
va_sM va_s0))))))
let va_lemma_Nat64Equal va_b0 va_s0 dst src = | false | null | false | va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let va_old_s:va_state = va_s0 in
let va_b1:va_codes = va_get_block va_b0 in
let va_s2, va_fc2 =
va_lemma_Sub64Wrap (va_hd va_b1)
va_s0
(va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)
in
let va_b2 = va_tl va_b1 in
let va_s3, va_fc3 =
va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)
in
let va_b3 = va_tl va_b2 in
let va_s4, va_fc4 =
va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)
in
let va_b4 = va_tl va_b3 in
let va_sM, va_f4 = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_operand_reg_opr64",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_lemma_merge_total",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_lemma_empty_total",
"Prims.list",
"Vale.X64.Machine_s.precode",
"Vale.X64.Decls.ins",
"Vale.X64.Decls.ocmp",
"Vale.X64.Decls.va_tl",
"Vale.X64.InsBasic.va_lemma_Adc64",
"Vale.X64.Decls.va_hd",
"Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64",
"Vale.X64.Decls.va_const_opr64",
"Vale.X64.InsBasic.va_lemma_Mov64",
"Vale.X64.InsBasic.va_lemma_Sub64Wrap",
"Vale.X64.Decls.va_get_block",
"Prims.unit",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_Nat64Equal"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_Nat64Equal : va_b0:va_code -> va_s0:va_state -> dst:va_operand_reg_opr64 ->
src:va_operand_reg_opr64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Nat64Equal dst src) va_s0 /\ va_is_dst_reg_opr64 dst
va_s0 /\ va_is_dst_reg_opr64 src va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (if
(va_eval_reg_opr64 va_s0 src = 18446744073709551615) then (va_eval_reg_opr64 va_sM dst = 0)
else (va_eval_reg_opr64 va_sM dst = 1)) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_ok va_sM (va_update_operand_reg_opr64 src va_sM (va_update_operand_reg_opr64 dst
va_sM va_s0)))))) | [] | Vale.X64.InsBasic.va_lemma_Nat64Equal | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
va_b0: Vale.X64.Decls.va_code ->
va_s0: Vale.X64.Decls.va_state ->
dst: Vale.X64.Decls.va_operand_reg_opr64 ->
src: Vale.X64.Decls.va_operand_reg_opr64
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 1022,
"start_col": 2,
"start_line": 1006
} |
Prims.Ghost | val va_lemma_Xor64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 ->
src:va_operand_opr64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Xor64 dst src) va_s0 /\ va_is_dst_dst_opr64 dst va_s0
/\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_dst_opr64 va_sM dst == Vale.Arch.Types.ixor64 (va_eval_dst_opr64 va_s0 dst)
(va_eval_opr64 va_s0 src) /\ ~(Vale.X64.Decls.overflow (va_get_flags va_sM)) /\
~(Vale.X64.Decls.cf (va_get_flags va_sM)) /\ Vale.X64.Decls.valid_cf (va_get_flags va_sM) /\
Vale.X64.Decls.valid_of (va_get_flags va_sM) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM) | val va_lemma_Xor64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 ->
src:va_operand_opr64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Xor64 dst src) va_s0 /\ va_is_dst_dst_opr64 dst va_s0
/\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_dst_opr64 va_sM dst == Vale.Arch.Types.ixor64 (va_eval_dst_opr64 va_s0 dst)
(va_eval_opr64 va_s0 src) /\ ~(Vale.X64.Decls.overflow (va_get_flags va_sM)) /\
~(Vale.X64.Decls.cf (va_get_flags va_sM)) /\ Vale.X64.Decls.valid_cf (va_get_flags va_sM) /\
Vale.X64.Decls.valid_of (va_get_flags va_sM) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)))))
let va_lemma_Xor64 va_b0 va_s0 dst src = | false | null | false | va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let va_sM, va_fM =
va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0
in
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr_annotate",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.op64",
"Vale.X64.Instruction_s.out",
"Vale.X64.Instruction_s.opFlagsCf",
"Vale.X64.Instruction_s.opFlagsOf",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.HavocFlags",
"Vale.X64.Instructions_s.ins_Xor64",
"Vale.X64.Machine_Semantics_s.AnnotateXor64",
"Vale.X64.Instruction_s.InstrTypeRecord",
"Prims.unit",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_Xor64"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_Xor64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 ->
src:va_operand_opr64
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Xor64 dst src) va_s0 /\ va_is_dst_dst_opr64 dst va_s0
/\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_dst_opr64 va_sM dst == Vale.Arch.Types.ixor64 (va_eval_dst_opr64 va_s0 dst)
(va_eval_opr64 va_s0 src) /\ ~(Vale.X64.Decls.overflow (va_get_flags va_sM)) /\
~(Vale.X64.Decls.cf (va_get_flags va_sM)) /\ Vale.X64.Decls.valid_cf (va_get_flags va_sM) /\
Vale.X64.Decls.valid_of (va_get_flags va_sM) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))) | [] | Vale.X64.InsBasic.va_lemma_Xor64 | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
va_b0: Vale.X64.Decls.va_code ->
va_s0: Vale.X64.Decls.va_state ->
dst: Vale.X64.Decls.va_operand_dst_opr64 ->
src: Vale.X64.Decls.va_operand_opr64
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 501,
"start_col": 2,
"start_line": 496
} |
Prims.Ghost | val va_wpProof_LargeComment : c:string -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_LargeComment c va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_LargeComment c) ([]) va_s0 va_k
((va_sM, va_f0, va_g)))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_wpProof_LargeComment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_LargeComment (va_code_LargeComment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | val va_wpProof_LargeComment : c:string -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_LargeComment c va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_LargeComment c) ([]) va_s0 va_k
((va_sM, va_f0, va_g))))
let va_wpProof_LargeComment c va_s0 va_k = | false | null | false | let va_sM, va_f0 = va_lemma_LargeComment (va_code_LargeComment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Prims.string",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Nil",
"Vale.X64.QuickCode.mod_t",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.X64.InsBasic.va_lemma_LargeComment",
"Vale.X64.InsBasic.va_code_LargeComment"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"]
let va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Nat64Equal dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Nat64Equal (va_code_Nat64Equal dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_reg_opr64
src va_sM (va_update_operand_reg_opr64 dst va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_reg_opr64 src; va_mod_reg_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Comment
[@ "opaque_to_smt"]
let va_code_Comment c =
(mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_Comment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Comment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_Comment) (va_code_Comment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Comment c)
(S.AnnotateComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Comment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Comment (va_code_Comment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- LargeComment
[@ "opaque_to_smt"]
let va_code_LargeComment c =
(mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_LargeComment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_LargeComment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_LargeComment) (va_code_LargeComment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_LargeComment c)
(S.AnnotateLargeComment c))) va_s0 in
(va_sM, va_fM) | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wpProof_LargeComment : c:string -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_LargeComment c va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_LargeComment c) ([]) va_s0 va_k
((va_sM, va_f0, va_g)))) | [] | Vale.X64.InsBasic.va_wpProof_LargeComment | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
c: Prims.string ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | {
"end_col": 22,
"end_line": 1094,
"start_col": 42,
"start_line": 1088
} |
Prims.Ghost | val va_lemma_LargeComment : va_b0:va_code -> va_s0:va_state -> c:string
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_LargeComment c) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_ok va_sM va_s0))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_LargeComment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_LargeComment) (va_code_LargeComment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_LargeComment c)
(S.AnnotateLargeComment c))) va_s0 in
(va_sM, va_fM) | val va_lemma_LargeComment : va_b0:va_code -> va_s0:va_state -> c:string
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_LargeComment c) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_ok va_sM va_s0)))
let va_lemma_LargeComment va_b0 va_s0 c = | false | null | false | va_reveal_opaque (`%va_code_LargeComment) (va_code_LargeComment c);
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c))) va_s0;
let va_sM, va_fM =
va_eval_ins (mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c))) va_s0
in
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Prims.string",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr_annotate",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_LargeComment",
"Vale.X64.Machine_Semantics_s.AnnotateLargeComment",
"Vale.X64.Instruction_s.InstrTypeRecord",
"Prims.unit",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_LargeComment"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"]
let va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Nat64Equal dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Nat64Equal (va_code_Nat64Equal dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_reg_opr64
src va_sM (va_update_operand_reg_opr64 dst va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_reg_opr64 src; va_mod_reg_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Comment
[@ "opaque_to_smt"]
let va_code_Comment c =
(mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_Comment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Comment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_Comment) (va_code_Comment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Comment c)
(S.AnnotateComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Comment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Comment (va_code_Comment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- LargeComment
[@ "opaque_to_smt"]
let va_code_LargeComment c =
(mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_LargeComment c =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_LargeComment : va_b0:va_code -> va_s0:va_state -> c:string
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_LargeComment c) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_ok va_sM va_s0))) | [] | Vale.X64.InsBasic.va_lemma_LargeComment | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> c: Prims.string
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 1084,
"start_col": 2,
"start_line": 1078
} |
Prims.Ghost | val va_wpProof_Newline : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Newline va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Newline ()) ([]) va_s0 va_k ((va_sM,
va_f0, va_g)))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_wpProof_Newline va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Newline (va_code_Newline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | val va_wpProof_Newline : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Newline va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Newline ()) ([]) va_s0 va_k ((va_sM,
va_f0, va_g))))
let va_wpProof_Newline va_s0 va_k = | false | null | false | let va_sM, va_f0 = va_lemma_Newline (va_code_Newline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Nil",
"Vale.X64.QuickCode.mod_t",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.X64.InsBasic.va_lemma_Newline",
"Vale.X64.InsBasic.va_code_Newline"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"]
let va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Nat64Equal dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Nat64Equal (va_code_Nat64Equal dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_reg_opr64
src va_sM (va_update_operand_reg_opr64 dst va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_reg_opr64 src; va_mod_reg_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Comment
[@ "opaque_to_smt"]
let va_code_Comment c =
(mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_Comment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Comment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_Comment) (va_code_Comment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Comment c)
(S.AnnotateComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Comment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Comment (va_code_Comment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- LargeComment
[@ "opaque_to_smt"]
let va_code_LargeComment c =
(mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_LargeComment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_LargeComment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_LargeComment) (va_code_LargeComment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_LargeComment c)
(S.AnnotateLargeComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_LargeComment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_LargeComment (va_code_LargeComment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- NoNewline
[@ "opaque_to_smt"]
let va_code_NoNewline () =
(mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0)))
[@ "opaque_to_smt"]
let va_codegen_success_NoNewline () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_NoNewline va_b0 va_s0 =
va_reveal_opaque (`%va_code_NoNewline) (va_code_NoNewline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace
0))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_NoNewline va_s0 va_k =
let (va_sM, va_f0) = va_lemma_NoNewline (va_code_NoNewline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Newline
[@ "opaque_to_smt"]
let va_code_Newline () =
(mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ())))
[@ "opaque_to_smt"]
let va_codegen_success_Newline () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Newline va_b0 va_s0 =
va_reveal_opaque (`%va_code_Newline) (va_code_Newline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ()))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline
()))) va_s0 in
(va_sM, va_fM) | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wpProof_Newline : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Newline va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Newline ()) ([]) va_s0 va_k ((va_sM,
va_f0, va_g)))) | [] | Vale.X64.InsBasic.va_wpProof_Newline | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | {
"end_col": 22,
"end_line": 1154,
"start_col": 35,
"start_line": 1148
} |
Prims.Ghost | val va_lemma_Newline : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Newline ()) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_ok va_sM va_s0))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_Newline va_b0 va_s0 =
va_reveal_opaque (`%va_code_Newline) (va_code_Newline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ()))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline
()))) va_s0 in
(va_sM, va_fM) | val va_lemma_Newline : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Newline ()) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_ok va_sM va_s0)))
let va_lemma_Newline va_b0 va_s0 = | false | null | false | va_reveal_opaque (`%va_code_Newline) (va_code_Newline ());
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ()))) va_s0;
let va_sM, va_fM =
va_eval_ins (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ()))) va_s0
in
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr_annotate",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Newline",
"Vale.X64.Machine_Semantics_s.AnnotateNewline",
"Vale.X64.Instruction_s.InstrTypeRecord",
"Prims.unit",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_Newline"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"]
let va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Nat64Equal dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Nat64Equal (va_code_Nat64Equal dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_reg_opr64
src va_sM (va_update_operand_reg_opr64 dst va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_reg_opr64 src; va_mod_reg_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Comment
[@ "opaque_to_smt"]
let va_code_Comment c =
(mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_Comment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Comment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_Comment) (va_code_Comment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Comment c)
(S.AnnotateComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Comment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Comment (va_code_Comment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- LargeComment
[@ "opaque_to_smt"]
let va_code_LargeComment c =
(mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_LargeComment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_LargeComment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_LargeComment) (va_code_LargeComment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_LargeComment c)
(S.AnnotateLargeComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_LargeComment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_LargeComment (va_code_LargeComment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- NoNewline
[@ "opaque_to_smt"]
let va_code_NoNewline () =
(mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0)))
[@ "opaque_to_smt"]
let va_codegen_success_NoNewline () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_NoNewline va_b0 va_s0 =
va_reveal_opaque (`%va_code_NoNewline) (va_code_NoNewline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace
0))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_NoNewline va_s0 va_k =
let (va_sM, va_f0) = va_lemma_NoNewline (va_code_NoNewline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Newline
[@ "opaque_to_smt"]
let va_code_Newline () =
(mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ())))
[@ "opaque_to_smt"]
let va_codegen_success_Newline () =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_Newline : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Newline ()) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_ok va_sM va_s0))) | [] | Vale.X64.InsBasic.va_lemma_Newline | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 1144,
"start_col": 2,
"start_line": 1139
} |
Prims.Ghost | val va_lemma_NoNewline : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_NoNewline ()) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_ok va_sM va_s0))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_NoNewline va_b0 va_s0 =
va_reveal_opaque (`%va_code_NoNewline) (va_code_NoNewline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace
0))) va_s0 in
(va_sM, va_fM) | val va_lemma_NoNewline : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_NoNewline ()) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_ok va_sM va_s0)))
let va_lemma_NoNewline va_b0 va_s0 = | false | null | false | va_reveal_opaque (`%va_code_NoNewline) (va_code_NoNewline ());
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0))) va_s0;
let va_sM, va_fM =
va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0))) va_s0
in
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr_annotate",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Space",
"Vale.X64.Machine_Semantics_s.AnnotateSpace",
"Vale.X64.Instruction_s.InstrTypeRecord",
"Prims.unit",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_NoNewline"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"]
let va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Nat64Equal dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Nat64Equal (va_code_Nat64Equal dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_reg_opr64
src va_sM (va_update_operand_reg_opr64 dst va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_reg_opr64 src; va_mod_reg_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Comment
[@ "opaque_to_smt"]
let va_code_Comment c =
(mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_Comment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Comment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_Comment) (va_code_Comment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Comment c)
(S.AnnotateComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Comment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Comment (va_code_Comment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- LargeComment
[@ "opaque_to_smt"]
let va_code_LargeComment c =
(mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_LargeComment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_LargeComment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_LargeComment) (va_code_LargeComment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_LargeComment c)
(S.AnnotateLargeComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_LargeComment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_LargeComment (va_code_LargeComment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- NoNewline
[@ "opaque_to_smt"]
let va_code_NoNewline () =
(mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0)))
[@ "opaque_to_smt"]
let va_codegen_success_NoNewline () =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_NoNewline : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_NoNewline ()) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_ok va_sM va_s0))) | [] | Vale.X64.InsBasic.va_lemma_NoNewline | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 1114,
"start_col": 2,
"start_line": 1109
} |
Prims.Ghost | val va_wpProof_Space : n:nat -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Space n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Space n) ([]) va_s0 va_k ((va_sM,
va_f0, va_g)))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_wpProof_Space n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Space (va_code_Space n) va_s0 n in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | val va_wpProof_Space : n:nat -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Space n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Space n) ([]) va_s0 va_k ((va_sM,
va_f0, va_g))))
let va_wpProof_Space n va_s0 va_k = | false | null | false | let va_sM, va_f0 = va_lemma_Space (va_code_Space n) va_s0 n in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Prims.nat",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Nil",
"Vale.X64.QuickCode.mod_t",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.X64.InsBasic.va_lemma_Space",
"Vale.X64.InsBasic.va_code_Space"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"]
let va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Nat64Equal dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Nat64Equal (va_code_Nat64Equal dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_reg_opr64
src va_sM (va_update_operand_reg_opr64 dst va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_reg_opr64 src; va_mod_reg_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Comment
[@ "opaque_to_smt"]
let va_code_Comment c =
(mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_Comment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Comment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_Comment) (va_code_Comment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Comment c)
(S.AnnotateComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Comment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Comment (va_code_Comment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- LargeComment
[@ "opaque_to_smt"]
let va_code_LargeComment c =
(mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_LargeComment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_LargeComment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_LargeComment) (va_code_LargeComment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_LargeComment c)
(S.AnnotateLargeComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_LargeComment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_LargeComment (va_code_LargeComment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- NoNewline
[@ "opaque_to_smt"]
let va_code_NoNewline () =
(mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0)))
[@ "opaque_to_smt"]
let va_codegen_success_NoNewline () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_NoNewline va_b0 va_s0 =
va_reveal_opaque (`%va_code_NoNewline) (va_code_NoNewline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace
0))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_NoNewline va_s0 va_k =
let (va_sM, va_f0) = va_lemma_NoNewline (va_code_NoNewline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Newline
[@ "opaque_to_smt"]
let va_code_Newline () =
(mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ())))
[@ "opaque_to_smt"]
let va_codegen_success_Newline () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Newline va_b0 va_s0 =
va_reveal_opaque (`%va_code_Newline) (va_code_Newline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ()))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline
()))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Newline va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Newline (va_code_Newline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Space
[@ "opaque_to_smt"]
let va_code_Space n =
(mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace n)))
[@ "opaque_to_smt"]
let va_codegen_success_Space n =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Space va_b0 va_s0 n =
va_reveal_opaque (`%va_code_Space) (va_code_Space n);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace n))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace
n))) va_s0 in
(va_sM, va_fM) | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wpProof_Space : n:nat -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Space n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Space n) ([]) va_s0 va_k ((va_sM,
va_f0, va_g)))) | [] | Vale.X64.InsBasic.va_wpProof_Space | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
n: Prims.nat ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | {
"end_col": 22,
"end_line": 1184,
"start_col": 35,
"start_line": 1178
} |
Prims.Ghost | val va_lemma_Space : va_b0:va_code -> va_s0:va_state -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Space n) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_ok va_sM va_s0))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_lemma_Space va_b0 va_s0 n =
va_reveal_opaque (`%va_code_Space) (va_code_Space n);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace n))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace
n))) va_s0 in
(va_sM, va_fM) | val va_lemma_Space : va_b0:va_code -> va_s0:va_state -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Space n) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_ok va_sM va_s0)))
let va_lemma_Space va_b0 va_s0 n = | false | null | false | va_reveal_opaque (`%va_code_Space) (va_code_Space n);
let va_old_s:va_state = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace n))) va_s0;
let va_sM, va_fM =
va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace n))) va_s0
in
(va_sM, va_fM) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Prims.nat",
"Vale.X64.State.vale_state",
"Vale.X64.Lemmas.fuel",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Decls.va_eval_ins",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr_annotate",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Space",
"Vale.X64.Machine_Semantics_s.AnnotateSpace",
"Vale.X64.Instruction_s.InstrTypeRecord",
"Prims.unit",
"Vale.X64.Decls.va_ins_lemma",
"Vale.X64.Decls.va_reveal_opaque",
"Vale.X64.InsBasic.va_code_Space"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"]
let va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Nat64Equal dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Nat64Equal (va_code_Nat64Equal dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_reg_opr64
src va_sM (va_update_operand_reg_opr64 dst va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_reg_opr64 src; va_mod_reg_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Comment
[@ "opaque_to_smt"]
let va_code_Comment c =
(mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_Comment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Comment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_Comment) (va_code_Comment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Comment c)
(S.AnnotateComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Comment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Comment (va_code_Comment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- LargeComment
[@ "opaque_to_smt"]
let va_code_LargeComment c =
(mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_LargeComment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_LargeComment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_LargeComment) (va_code_LargeComment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_LargeComment c)
(S.AnnotateLargeComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_LargeComment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_LargeComment (va_code_LargeComment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- NoNewline
[@ "opaque_to_smt"]
let va_code_NoNewline () =
(mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0)))
[@ "opaque_to_smt"]
let va_codegen_success_NoNewline () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_NoNewline va_b0 va_s0 =
va_reveal_opaque (`%va_code_NoNewline) (va_code_NoNewline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace
0))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_NoNewline va_s0 va_k =
let (va_sM, va_f0) = va_lemma_NoNewline (va_code_NoNewline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Newline
[@ "opaque_to_smt"]
let va_code_Newline () =
(mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ())))
[@ "opaque_to_smt"]
let va_codegen_success_Newline () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Newline va_b0 va_s0 =
va_reveal_opaque (`%va_code_Newline) (va_code_Newline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ()))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline
()))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Newline va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Newline (va_code_Newline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Space
[@ "opaque_to_smt"]
let va_code_Space n =
(mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace n)))
[@ "opaque_to_smt"]
let va_codegen_success_Space n =
(va_ttrue ())
[@"opaque_to_smt"] | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_lemma_Space : va_b0:va_code -> va_s0:va_state -> n:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Space n) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_ok va_sM va_s0))) | [] | Vale.X64.InsBasic.va_lemma_Space | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> n: Prims.nat
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 16,
"end_line": 1174,
"start_col": 2,
"start_line": 1169
} |
Prims.Ghost | val va_wpProof_Prefetchnta : v:va_operand_opr64 -> va_s0:va_state -> va_k:(va_state -> unit ->
Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Prefetchnta v va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Prefetchnta v) ([]) va_s0 va_k
((va_sM, va_f0, va_g)))) | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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 va_wpProof_Prefetchnta v va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Prefetchnta (va_code_Prefetchnta v) va_s0 v in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | val va_wpProof_Prefetchnta : v:va_operand_opr64 -> va_s0:va_state -> va_k:(va_state -> unit ->
Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Prefetchnta v va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Prefetchnta v) ([]) va_s0 va_k
((va_sM, va_f0, va_g))))
let va_wpProof_Prefetchnta v va_s0 va_k = | false | null | false | let va_sM, va_f0 = va_lemma_Prefetchnta (va_code_Prefetchnta v) va_s0 v in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"checked_file": "Vale.X64.InsBasic.fst.checked",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [] | [
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Nil",
"Vale.X64.QuickCode.mod_t",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.X64.InsBasic.va_lemma_Prefetchnta",
"Vale.X64.InsBasic.va_code_Prefetchnta"
] | [] | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64) (va_code_Add64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64 (va_code_Add64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64Wrap
[@ "opaque_to_smt"]
let va_code_Add64Wrap dst src =
(mk_ins (make_instr (I.ins_Add64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Add64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Add64Wrap) (va_code_Add64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Add64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add64Wrap (va_code_Add64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddLea64
[@ "opaque_to_smt"]
let va_code_AddLea64 dst src1 src2 =
(mk_ins (make_instr (I.ins_AddLea64) dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddLea64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddLea64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddLea64) (va_code_AddLea64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddLea64) dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddLea64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddLea64 (va_code_AddLea64 dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64
[@ "opaque_to_smt"]
let va_code_Adc64 dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64) (va_code_Adc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64 (va_code_Adc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adc64Wrap
[@ "opaque_to_smt"]
let va_code_Adc64Wrap dst src =
(mk_ins (make_instr (I.ins_AddCarry64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adc64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adc64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adc64Wrap) (va_code_Adc64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_AddCarry64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adc64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adc64Wrap (va_code_Adc64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Adcx64Wrap
#push-options "--smtencoding.nl_arith_repr boxwrap"
[@ "opaque_to_smt"]
let va_code_Adcx64Wrap dst src =
(mk_ins (make_instr (I.ins_Adcx64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adcx64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adcx64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adcx64Wrap) (va_code_Adcx64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adcx64) dst src)) va_s0 in
assert (Vale.Arch.Types.add_wrap64 (Vale.Arch.Types.add_wrap64 (va_eval_dst_opr64 va_old_s dst)
(va_eval_opr64 va_old_s src)) (if Vale.X64.Decls.cf (va_get_flags va_old_s) then 1 else 0) ==
(va_eval_dst_opr64 va_old_s dst + va_eval_opr64 va_old_s src + (if Vale.X64.Decls.cf
(va_get_flags va_old_s) then 1 else 0)) `op_Modulus` pow2_64);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adcx64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adcx64Wrap (va_code_Adcx64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
#pop-options
//--
//-- Adox64Wrap
[@ "opaque_to_smt"]
let va_code_Adox64Wrap dst src =
(mk_ins (make_instr (I.ins_Adox64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Adox64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Adox64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Adox64Wrap) (va_code_Adox64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Adox64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Adox64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Adox64Wrap (va_code_Adox64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64
[@ "opaque_to_smt"]
let va_code_Sub64 dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64) (va_code_Sub64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64 (va_code_Sub64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub64Wrap
[@ "opaque_to_smt"]
let va_code_Sub64Wrap dst src =
(mk_ins (make_instr (I.ins_Sub64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sub64Wrap dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub64Wrap va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sub64Wrap) (va_code_Sub64Wrap dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sub64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub64Wrap dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub64Wrap (va_code_Sub64Wrap dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sbb64
[@ "opaque_to_smt"]
let va_code_Sbb64 dst src =
(mk_ins (make_instr (I.ins_Sbb64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Sbb64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sbb64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Sbb64) (va_code_Sbb64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Sbb64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sbb64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sbb64 (va_code_Sbb64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
#restart-solver
#push-options "--max_fuel 0 --max_ifuel 0 --using_facts_from 'Prims FStar.UInt'"
let lemma_fundamental_div_mod (a b:nat64) :
Lemma (pow2_64 * (FStar.UInt.mul_div #64 a b) + (FStar.UInt.mul_mod #64 a b) == a * b)
=
FStar.Math.Lemmas.lemma_div_mod (a * b) pow2_64
#pop-options
//-- lemma_fundamental_div_mod
//--
//-- Mul64Wrap
[@ "opaque_to_smt"]
let va_code_Mul64Wrap src =
(mk_ins (make_instr (I.ins_Mul64) src))
[@ "opaque_to_smt"]
let va_codegen_success_Mul64Wrap src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mul64Wrap va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Mul64Wrap) (va_code_Mul64Wrap src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mul64) src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mul64) src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRax va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mul64Wrap src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mul64Wrap (va_code_Mul64Wrap src) va_s0 src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM
(va_update_flags va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_flags]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Mulx64
[@ "opaque_to_smt"]
let va_code_Mulx64 dst_hi dst_lo src =
(mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src))
[@ "opaque_to_smt"]
let va_codegen_success_Mulx64 dst_hi dst_lo src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mulx64 va_b0 va_s0 dst_hi dst_lo src =
va_reveal_opaque (`%va_code_Mulx64) (va_code_Mulx64 dst_hi dst_lo src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Mulx64) dst_hi dst_lo src)) va_s0 in
lemma_fundamental_div_mod (va_get_reg64 rRdx va_old_s) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mulx64 dst_hi dst_lo src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mulx64 (va_code_Mulx64 dst_hi dst_lo src) va_s0 dst_hi dst_lo src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst_lo va_sM
(va_update_operand_dst_opr64 dst_hi va_sM va_s0))));
va_lemma_norm_mods ([va_mod_dst_opr64 dst_lo; va_mod_dst_opr64 dst_hi]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- lemma_mul_nat
//--
//-- lemma_mul_in_bounds
//--
//-- IMul64
[@ "opaque_to_smt"]
let va_code_IMul64 dst src =
(mk_ins (make_instr (I.ins_IMul64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_IMul64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_IMul64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_IMul64) (va_code_IMul64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_IMul64) dst src)) va_s0 in
lemma_mul_nat (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
lemma_mul_in_bounds (va_eval_dst_opr64 va_old_s dst) (va_eval_opr64 va_old_s src);
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_IMul64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_IMul64 (va_code_IMul64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xor64
[@ "opaque_to_smt"]
let va_code_Xor64 dst src =
(mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Xor64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xor64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Xor64) (va_code_Xor64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Xor64) (S.AnnotateXor64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xor64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xor64 (va_code_Xor64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- And64
[@ "opaque_to_smt"]
let va_code_And64 dst src =
(mk_ins (make_instr (I.ins_And64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_And64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_And64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_And64) (va_code_And64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_And64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_And64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_And64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_And64 (va_code_And64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shl64
[@ "opaque_to_smt"]
let va_code_Shl64 dst amt =
(mk_ins (make_instr (I.ins_Shl64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shl64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shl64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shl64) (va_code_Shl64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shl64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shl64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shl64 (va_code_Shl64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Shr64
[@ "opaque_to_smt"]
let va_code_Shr64 dst amt =
(mk_ins (make_instr (I.ins_Shr64) dst amt))
[@ "opaque_to_smt"]
let va_codegen_success_Shr64 dst amt =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Shr64 va_b0 va_s0 dst amt =
va_reveal_opaque (`%va_code_Shr64) (va_code_Shr64 dst amt);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Shr64) dst amt)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Shr64 dst amt va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Shr64 (va_code_Shr64 dst amt) va_s0 dst amt in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64
dst va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_AES
[@ "opaque_to_smt"]
let va_code_Cpuid_AES () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_AES () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_AES va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_AES) (va_code_Cpuid_AES ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_AES va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_AES (va_code_Cpuid_AES ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sha
[@ "opaque_to_smt"]
let va_code_Cpuid_Sha () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sha () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sha va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sha) (va_code_Cpuid_Sha ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sha va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sha (va_code_Cpuid_Sha ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Adx_Bmi2
[@ "opaque_to_smt"]
let va_code_Cpuid_Adx_Bmi2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Adx_Bmi2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Adx_Bmi2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Adx_Bmi2) (va_code_Cpuid_Adx_Bmi2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Adx_Bmi2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Adx_Bmi2 (va_code_Cpuid_Adx_Bmi2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx) (va_code_Cpuid_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx (va_code_Cpuid_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx2
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx2 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx2 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx2 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx2) (va_code_Cpuid_Avx2 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx2 (va_code_Cpuid_Avx2 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Sse
[@ "opaque_to_smt"]
let va_code_Cpuid_Sse () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Sse () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Sse va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Sse) (va_code_Cpuid_Sse ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Sse va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Sse (va_code_Cpuid_Sse ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Movbe
[@ "opaque_to_smt"]
let va_code_Cpuid_Movbe () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Movbe () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Movbe va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Movbe) (va_code_Cpuid_Movbe ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Movbe va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Movbe (va_code_Cpuid_Movbe ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Rdrand
[@ "opaque_to_smt"]
let va_code_Cpuid_Rdrand () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Rdrand () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Rdrand va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Rdrand) (va_code_Cpuid_Rdrand ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Rdrand va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Rdrand (va_code_Cpuid_Rdrand ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Avx512
[@ "opaque_to_smt"]
let va_code_Cpuid_Avx512 () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Avx512) (va_code_Cpuid_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Avx512 (va_code_Cpuid_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cpuid_Osxsave
[@ "opaque_to_smt"]
let va_code_Cpuid_Osxsave () =
(mk_ins (make_instr (I.ins_Cpuid)))
[@ "opaque_to_smt"]
let va_codegen_success_Cpuid_Osxsave () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cpuid_Osxsave va_b0 va_s0 =
va_reveal_opaque (`%va_code_Cpuid_Osxsave) (va_code_Cpuid_Osxsave ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cpuid))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cpuid))) va_s0 in
Vale.X64.CPU_Features_s.cpuid_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cpuid_Osxsave va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cpuid_Osxsave (va_code_Cpuid_Osxsave ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax])
va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx) (va_code_Xgetbv_Avx ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx (va_code_Xgetbv_Avx ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Xgetbv_Avx512
[@ "opaque_to_smt"]
let va_code_Xgetbv_Avx512 () =
(mk_ins (make_instr (I.ins_Xgetbv)))
[@ "opaque_to_smt"]
let va_codegen_success_Xgetbv_Avx512 () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Xgetbv_Avx512 va_b0 va_s0 =
va_reveal_opaque (`%va_code_Xgetbv_Avx512) (va_code_Xgetbv_Avx512 ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Xgetbv))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Xgetbv))) va_s0 in
Vale.X64.CPU_Features_s.xgetbv_features ();
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Xgetbv_Avx512 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Xgetbv_Avx512 (va_code_Xgetbv_Avx512 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Nat64Equal
[@ "opaque_to_smt"]
let va_code_Nat64Equal dst src =
(va_Block (va_CCons (va_code_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src) (va_const_opr64
18446744073709551615)) (va_CCons (va_code_Mov64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CCons (va_code_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0)) (va_CNil ())))))
[@ "opaque_to_smt"]
let va_codegen_success_Nat64Equal dst src =
(va_pbool_and (va_codegen_success_Sub64Wrap (va_coerce_reg_opr64_to_dst_opr64 src)
(va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Mov64
(va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_pbool_and
(va_codegen_success_Adc64 (va_coerce_reg_opr64_to_dst_opr64 dst) (va_const_opr64 0)) (va_ttrue
()))))
[@"opaque_to_smt"]
let va_lemma_Nat64Equal va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Nat64Equal) (va_code_Nat64Equal dst src);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
let (va_s2, va_fc2) = va_lemma_Sub64Wrap (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64
src) (va_const_opr64 18446744073709551615) in
let va_b2 = va_tl va_b1 in
let (va_s3, va_fc3) = va_lemma_Mov64 (va_hd va_b2) va_s2 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b3 = va_tl va_b2 in
let (va_s4, va_fc4) = va_lemma_Adc64 (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 dst)
(va_const_opr64 0) in
let va_b4 = va_tl va_b3 in
let (va_sM, va_f4) = va_lemma_empty_total va_s4 va_b4 in
let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in
let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Nat64Equal dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Nat64Equal (va_code_Nat64Equal dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_reg_opr64
src va_sM (va_update_operand_reg_opr64 dst va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_flags; va_mod_reg_opr64 src; va_mod_reg_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Comment
[@ "opaque_to_smt"]
let va_code_Comment c =
(mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_Comment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Comment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_Comment) (va_code_Comment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Comment c) (S.AnnotateComment c))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Comment c)
(S.AnnotateComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Comment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Comment (va_code_Comment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- LargeComment
[@ "opaque_to_smt"]
let va_code_LargeComment c =
(mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
[@ "opaque_to_smt"]
let va_codegen_success_LargeComment c =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_LargeComment va_b0 va_s0 c =
va_reveal_opaque (`%va_code_LargeComment) (va_code_LargeComment c);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_LargeComment c) (S.AnnotateLargeComment c)))
va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_LargeComment c)
(S.AnnotateLargeComment c))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_LargeComment c va_s0 va_k =
let (va_sM, va_f0) = va_lemma_LargeComment (va_code_LargeComment c) va_s0 c in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- NoNewline
[@ "opaque_to_smt"]
let va_code_NoNewline () =
(mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0)))
[@ "opaque_to_smt"]
let va_codegen_success_NoNewline () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_NoNewline va_b0 va_s0 =
va_reveal_opaque (`%va_code_NoNewline) (va_code_NoNewline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace 0))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space 0) (S.AnnotateSpace
0))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_NoNewline va_s0 va_k =
let (va_sM, va_f0) = va_lemma_NoNewline (va_code_NoNewline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Newline
[@ "opaque_to_smt"]
let va_code_Newline () =
(mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ())))
[@ "opaque_to_smt"]
let va_codegen_success_Newline () =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Newline va_b0 va_s0 =
va_reveal_opaque (`%va_code_Newline) (va_code_Newline ());
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline ()))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Newline) (S.AnnotateNewline
()))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Newline va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Newline (va_code_Newline ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Space
[@ "opaque_to_smt"]
let va_code_Space n =
(mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace n)))
[@ "opaque_to_smt"]
let va_codegen_success_Space n =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Space va_b0 va_s0 n =
va_reveal_opaque (`%va_code_Space) (va_code_Space n);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace n))) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Space n) (S.AnnotateSpace
n))) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Space n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Space (va_code_Space n) va_s0 n in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM va_s0));
va_lemma_norm_mods ([]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Prefetchnta
[@ "opaque_to_smt"]
let va_code_Prefetchnta v =
(mk_ins (make_instr_annotate (I.ins_Prefetchnta) (S.AnnotatePrefetchnta ()) v))
[@ "opaque_to_smt"]
let va_codegen_success_Prefetchnta v =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Prefetchnta va_b0 va_s0 v =
va_reveal_opaque (`%va_code_Prefetchnta) (va_code_Prefetchnta v);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Prefetchnta) (S.AnnotatePrefetchnta ()) v))
va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Prefetchnta)
(S.AnnotatePrefetchnta ()) v)) va_s0 in
(va_sM, va_fM) | false | false | Vale.X64.InsBasic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wpProof_Prefetchnta : v:va_operand_opr64 -> va_s0:va_state -> va_k:(va_state -> unit ->
Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Prefetchnta v va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Prefetchnta v) ([]) va_s0 va_k
((va_sM, va_f0, va_g)))) | [] | Vale.X64.InsBasic.va_wpProof_Prefetchnta | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
v: Vale.X64.Decls.va_operand_opr64 ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | {
"end_col": 22,
"end_line": 1215,
"start_col": 41,
"start_line": 1209
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"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.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let less_than_max_input_length = Spec.Hash.Definitions.less_than_max_input_length | let less_than_max_input_length = | false | null | false | Spec.Hash.Definitions.less_than_max_input_length | {
"checked_file": "Hacl.Impl.RSAPSS.MGF.fst.checked",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.MGF.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.less_than_max_input_length"
] | [] | module Hacl.Impl.RSAPSS.MGF
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 = Spec.RSAPSS
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module Hash = Spec.Agile.Hash
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val hash_len: a:Hash.hash_alg{S.hash_is_supported a} -> Tot (res:size_t{v res == Hash.hash_length a})
[@CInline]
let hash_len a =
Hacl.Hash.Definitions.hash_len a
inline_for_extraction noextract
let max_input_length = Hash.max_input_length | false | true | Hacl.Impl.RSAPSS.MGF.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 less_than_max_input_length : l: Prims.int -> a: Spec.Hash.Definitions.hash_alg -> Prims.bool | [] | Hacl.Impl.RSAPSS.MGF.less_than_max_input_length | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.MGF.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | l: Prims.int -> a: Spec.Hash.Definitions.hash_alg -> Prims.bool | {
"end_col": 81,
"end_line": 30,
"start_col": 33,
"start_line": 30
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"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.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let max_input_length = Hash.max_input_length | let max_input_length = | false | null | false | Hash.max_input_length | {
"checked_file": "Hacl.Impl.RSAPSS.MGF.fst.checked",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.MGF.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.max_input_length"
] | [] | module Hacl.Impl.RSAPSS.MGF
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 = Spec.RSAPSS
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module Hash = Spec.Agile.Hash
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val hash_len: a:Hash.hash_alg{S.hash_is_supported a} -> Tot (res:size_t{v res == Hash.hash_length a})
[@CInline]
let hash_len a =
Hacl.Hash.Definitions.hash_len a | false | true | Hacl.Impl.RSAPSS.MGF.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 max_input_length : _: Spec.Hash.Definitions.hash_alg -> FStar.Pervasives.Native.option Prims.pos | [] | Hacl.Impl.RSAPSS.MGF.max_input_length | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.MGF.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Spec.Hash.Definitions.hash_alg -> FStar.Pervasives.Native.option Prims.pos | {
"end_col": 44,
"end_line": 27,
"start_col": 23,
"start_line": 27
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"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.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mgf_hash_st (a:Hash.hash_alg{S.hash_is_supported a}) =
len:size_t{v len + 4 <= max_size_t /\ (v len + 4) `less_than_max_input_length` a}
-> mgfseed:lbuffer uint8 len
-> maskLen:size_t{0 < v maskLen /\ S.blocks (v maskLen) (Hash.hash_length a) * Hash.hash_length a < pow2 32}
-> res:lbuffer uint8 maskLen ->
Stack unit
(requires fun h -> live h mgfseed /\ live h res /\ disjoint res mgfseed)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.mgf_hash a (v len) (as_seq h0 mgfseed) (v maskLen)) | let mgf_hash_st (a: Hash.hash_alg{S.hash_is_supported a}) = | false | null | false |
len: size_t{v len + 4 <= max_size_t /\ (v len + 4) `less_than_max_input_length` a} ->
mgfseed: lbuffer uint8 len ->
maskLen:
size_t
{0 < v maskLen /\ S.blocks (v maskLen) (Hash.hash_length a) * Hash.hash_length a < pow2 32} ->
res: lbuffer uint8 maskLen
-> Stack unit
(requires fun h -> live h mgfseed /\ live h res /\ disjoint res mgfseed)
(ensures
fun h0 _ h1 ->
modifies (loc res) h0 h1 /\
as_seq h1 res == S.mgf_hash a (v len) (as_seq h0 mgfseed) (v maskLen)) | {
"checked_file": "Hacl.Impl.RSAPSS.MGF.fst.checked",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.MGF.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.RSAPSS.hash_is_supported",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Hacl.Impl.RSAPSS.MGF.less_than_max_input_length",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Prims.op_LessThan",
"FStar.Mul.op_Star",
"Spec.RSAPSS.blocks",
"Spec.Hash.Definitions.hash_length",
"Prims.pow2",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.Buffer.as_seq",
"Spec.RSAPSS.mgf_hash"
] | [] | module Hacl.Impl.RSAPSS.MGF
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 = Spec.RSAPSS
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module Hash = Spec.Agile.Hash
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val hash_len: a:Hash.hash_alg{S.hash_is_supported a} -> Tot (res:size_t{v res == Hash.hash_length a})
[@CInline]
let hash_len a =
Hacl.Hash.Definitions.hash_len a
inline_for_extraction noextract
let max_input_length = Hash.max_input_length
inline_for_extraction noextract
let less_than_max_input_length = Spec.Hash.Definitions.less_than_max_input_length
val hash:
a:Hash.hash_alg{S.hash_is_supported a}
-> mHash:lbuffer uint8 (hash_len a)
-> msgLen:size_t{v msgLen `less_than_max_input_length` a}
-> msg:lbuffer uint8 msgLen ->
Stack unit
(requires fun h -> live h mHash /\ live h msg /\ disjoint msg mHash)
(ensures fun h0 _ h1 -> modifies (loc mHash) h0 h1 /\
as_seq h1 mHash == Hash.hash a (as_seq h0 msg))
[@CInline]
let hash a mHash msgLen msg =
match a with
| Hash.SHA2_256 -> Hacl.Streaming.SHA2.hash_256 msg msgLen mHash
| Hash.SHA2_384 -> Hacl.Streaming.SHA2.hash_384 msg msgLen mHash
| Hash.SHA2_512 -> Hacl.Streaming.SHA2.hash_512 msg msgLen mHash
(* Mask Generation Function *)
inline_for_extraction noextract
val counter_to_bytes:
i:size_t
-> counter:lbuffer uint8 4ul ->
Stack unit
(requires fun h -> live h counter)
(ensures fun h0 _ h1 -> modifies (loc counter) h0 h1 /\
as_seq h1 counter == BSeq.nat_to_intseq_be 4 (v i))
let counter_to_bytes i c =
let h0 = ST.get () in
c.(0ul) <- to_u8 (i >>. 24ul);
c.(1ul) <- to_u8 (i >>. 16ul);
c.(2ul) <- to_u8 (i >>. 8ul);
c.(3ul) <- to_u8 i;
let h1 = ST.get () in
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 0;
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 1;
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 2;
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 3;
LSeq.eq_intro (as_seq h1 c) (BSeq.nat_to_intseq_be 4 (v i))
inline_for_extraction noextract
val mgf_hash_f:
a:Hash.hash_alg{S.hash_is_supported a}
-> len:size_t{v len + 4 <= max_size_t /\ (v len + 4) `less_than_max_input_length` a}
-> i:size_t
-> mgfseed_counter:lbuffer uint8 (len +! 4ul)
-> block:lbuffer uint8 (hash_len a) ->
Stack unit
(requires fun h -> live h mgfseed_counter /\ live h block /\ disjoint mgfseed_counter block)
(ensures fun h0 _ h1 -> modifies (loc mgfseed_counter |+| loc block) h0 h1 /\
(as_seq h1 mgfseed_counter, as_seq h1 block) == S.mgf_hash_f a (v len) (v i) (as_seq h0 mgfseed_counter))
let mgf_hash_f a len i mgfseed_counter block =
let h0 = ST.get () in
update_sub_f h0 mgfseed_counter len 4ul
(fun h -> BSeq.nat_to_intseq_be 4 (v i))
(fun _ ->
let c = sub mgfseed_counter len 4ul in
counter_to_bytes i c);
hash a block (len +! 4ul) mgfseed_counter
inline_for_extraction noextract | false | false | Hacl.Impl.RSAPSS.MGF.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 mgf_hash_st : a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> Type0 | [] | Hacl.Impl.RSAPSS.MGF.mgf_hash_st | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.MGF.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> Type0 | {
"end_col": 74,
"end_line": 105,
"start_col": 2,
"start_line": 98
} |
|
Prims.Tot | val hash_len: a:Hash.hash_alg{S.hash_is_supported a} -> Tot (res:size_t{v res == Hash.hash_length a}) | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"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.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_len a =
Hacl.Hash.Definitions.hash_len a | val hash_len: a:Hash.hash_alg{S.hash_is_supported a} -> Tot (res:size_t{v res == Hash.hash_length a})
let hash_len a = | false | null | false | Hacl.Hash.Definitions.hash_len a | {
"checked_file": "Hacl.Impl.RSAPSS.MGF.fst.checked",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.MGF.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.RSAPSS.hash_is_supported",
"Hacl.Hash.Definitions.hash_len",
"Lib.IntTypes.size_t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Spec.Hash.Definitions.hash_length"
] | [] | module Hacl.Impl.RSAPSS.MGF
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 = Spec.RSAPSS
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module Hash = Spec.Agile.Hash
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val hash_len: a:Hash.hash_alg{S.hash_is_supported a} -> Tot (res:size_t{v res == Hash.hash_length a})
[@CInline] | false | false | Hacl.Impl.RSAPSS.MGF.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 hash_len: a:Hash.hash_alg{S.hash_is_supported a} -> Tot (res:size_t{v res == Hash.hash_length a}) | [] | Hacl.Impl.RSAPSS.MGF.hash_len | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.MGF.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a}
-> res: Lib.IntTypes.size_t{Lib.IntTypes.v res == Spec.Hash.Definitions.hash_length a} | {
"end_col": 34,
"end_line": 24,
"start_col": 2,
"start_line": 24
} |
FStar.HyperStack.ST.Stack | val hash:
a:Hash.hash_alg{S.hash_is_supported a}
-> mHash:lbuffer uint8 (hash_len a)
-> msgLen:size_t{v msgLen `less_than_max_input_length` a}
-> msg:lbuffer uint8 msgLen ->
Stack unit
(requires fun h -> live h mHash /\ live h msg /\ disjoint msg mHash)
(ensures fun h0 _ h1 -> modifies (loc mHash) h0 h1 /\
as_seq h1 mHash == Hash.hash a (as_seq h0 msg)) | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"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.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash a mHash msgLen msg =
match a with
| Hash.SHA2_256 -> Hacl.Streaming.SHA2.hash_256 msg msgLen mHash
| Hash.SHA2_384 -> Hacl.Streaming.SHA2.hash_384 msg msgLen mHash
| Hash.SHA2_512 -> Hacl.Streaming.SHA2.hash_512 msg msgLen mHash | val hash:
a:Hash.hash_alg{S.hash_is_supported a}
-> mHash:lbuffer uint8 (hash_len a)
-> msgLen:size_t{v msgLen `less_than_max_input_length` a}
-> msg:lbuffer uint8 msgLen ->
Stack unit
(requires fun h -> live h mHash /\ live h msg /\ disjoint msg mHash)
(ensures fun h0 _ h1 -> modifies (loc mHash) h0 h1 /\
as_seq h1 mHash == Hash.hash a (as_seq h0 msg))
let hash a mHash msgLen msg = | true | null | false | match a with
| Hash.SHA2_256 -> Hacl.Streaming.SHA2.hash_256 msg msgLen mHash
| Hash.SHA2_384 -> Hacl.Streaming.SHA2.hash_384 msg msgLen mHash
| Hash.SHA2_512 -> Hacl.Streaming.SHA2.hash_512 msg msgLen mHash | {
"checked_file": "Hacl.Impl.RSAPSS.MGF.fst.checked",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.MGF.fst"
} | [] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.RSAPSS.hash_is_supported",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Hacl.Impl.RSAPSS.MGF.hash_len",
"Lib.IntTypes.size_t",
"Hacl.Impl.RSAPSS.MGF.less_than_max_input_length",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Streaming.SHA2.hash_256",
"Prims.unit",
"Hacl.Streaming.SHA2.hash_384",
"Hacl.Streaming.SHA2.hash_512"
] | [] | module Hacl.Impl.RSAPSS.MGF
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 = Spec.RSAPSS
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module Hash = Spec.Agile.Hash
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val hash_len: a:Hash.hash_alg{S.hash_is_supported a} -> Tot (res:size_t{v res == Hash.hash_length a})
[@CInline]
let hash_len a =
Hacl.Hash.Definitions.hash_len a
inline_for_extraction noextract
let max_input_length = Hash.max_input_length
inline_for_extraction noextract
let less_than_max_input_length = Spec.Hash.Definitions.less_than_max_input_length
val hash:
a:Hash.hash_alg{S.hash_is_supported a}
-> mHash:lbuffer uint8 (hash_len a)
-> msgLen:size_t{v msgLen `less_than_max_input_length` a}
-> msg:lbuffer uint8 msgLen ->
Stack unit
(requires fun h -> live h mHash /\ live h msg /\ disjoint msg mHash)
(ensures fun h0 _ h1 -> modifies (loc mHash) h0 h1 /\
as_seq h1 mHash == Hash.hash a (as_seq h0 msg))
[@CInline] | false | false | Hacl.Impl.RSAPSS.MGF.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 hash:
a:Hash.hash_alg{S.hash_is_supported a}
-> mHash:lbuffer uint8 (hash_len a)
-> msgLen:size_t{v msgLen `less_than_max_input_length` a}
-> msg:lbuffer uint8 msgLen ->
Stack unit
(requires fun h -> live h mHash /\ live h msg /\ disjoint msg mHash)
(ensures fun h0 _ h1 -> modifies (loc mHash) h0 h1 /\
as_seq h1 mHash == Hash.hash a (as_seq h0 msg)) | [] | Hacl.Impl.RSAPSS.MGF.hash | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.MGF.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} ->
mHash: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.Impl.RSAPSS.MGF.hash_len a) ->
msgLen:
Lib.IntTypes.size_t{Hacl.Impl.RSAPSS.MGF.less_than_max_input_length (Lib.IntTypes.v msgLen) a} ->
msg: Lib.Buffer.lbuffer Lib.IntTypes.uint8 msgLen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 66,
"end_line": 47,
"start_col": 2,
"start_line": 44
} |
FStar.HyperStack.ST.Stack | val counter_to_bytes:
i:size_t
-> counter:lbuffer uint8 4ul ->
Stack unit
(requires fun h -> live h counter)
(ensures fun h0 _ h1 -> modifies (loc counter) h0 h1 /\
as_seq h1 counter == BSeq.nat_to_intseq_be 4 (v i)) | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"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.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let counter_to_bytes i c =
let h0 = ST.get () in
c.(0ul) <- to_u8 (i >>. 24ul);
c.(1ul) <- to_u8 (i >>. 16ul);
c.(2ul) <- to_u8 (i >>. 8ul);
c.(3ul) <- to_u8 i;
let h1 = ST.get () in
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 0;
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 1;
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 2;
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 3;
LSeq.eq_intro (as_seq h1 c) (BSeq.nat_to_intseq_be 4 (v i)) | val counter_to_bytes:
i:size_t
-> counter:lbuffer uint8 4ul ->
Stack unit
(requires fun h -> live h counter)
(ensures fun h0 _ h1 -> modifies (loc counter) h0 h1 /\
as_seq h1 counter == BSeq.nat_to_intseq_be 4 (v i))
let counter_to_bytes i c = | true | null | false | let h0 = ST.get () in
c.(0ul) <- to_u8 (i >>. 24ul);
c.(1ul) <- to_u8 (i >>. 16ul);
c.(2ul) <- to_u8 (i >>. 8ul);
c.(3ul) <- to_u8 i;
let h1 = ST.get () in
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 0;
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 1;
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 2;
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 3;
LSeq.eq_intro (as_seq h1 c) (BSeq.nat_to_intseq_be 4 (v i)) | {
"checked_file": "Hacl.Impl.RSAPSS.MGF.fst.checked",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.MGF.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.Sequence.eq_intro",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.ByteSequence.nat_to_intseq_be",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"Lib.ByteSequence.index_nat_to_intseq_be",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.to_u8",
"Lib.IntTypes.op_Greater_Greater_Dot"
] | [] | module Hacl.Impl.RSAPSS.MGF
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 = Spec.RSAPSS
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module Hash = Spec.Agile.Hash
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val hash_len: a:Hash.hash_alg{S.hash_is_supported a} -> Tot (res:size_t{v res == Hash.hash_length a})
[@CInline]
let hash_len a =
Hacl.Hash.Definitions.hash_len a
inline_for_extraction noextract
let max_input_length = Hash.max_input_length
inline_for_extraction noextract
let less_than_max_input_length = Spec.Hash.Definitions.less_than_max_input_length
val hash:
a:Hash.hash_alg{S.hash_is_supported a}
-> mHash:lbuffer uint8 (hash_len a)
-> msgLen:size_t{v msgLen `less_than_max_input_length` a}
-> msg:lbuffer uint8 msgLen ->
Stack unit
(requires fun h -> live h mHash /\ live h msg /\ disjoint msg mHash)
(ensures fun h0 _ h1 -> modifies (loc mHash) h0 h1 /\
as_seq h1 mHash == Hash.hash a (as_seq h0 msg))
[@CInline]
let hash a mHash msgLen msg =
match a with
| Hash.SHA2_256 -> Hacl.Streaming.SHA2.hash_256 msg msgLen mHash
| Hash.SHA2_384 -> Hacl.Streaming.SHA2.hash_384 msg msgLen mHash
| Hash.SHA2_512 -> Hacl.Streaming.SHA2.hash_512 msg msgLen mHash
(* Mask Generation Function *)
inline_for_extraction noextract
val counter_to_bytes:
i:size_t
-> counter:lbuffer uint8 4ul ->
Stack unit
(requires fun h -> live h counter)
(ensures fun h0 _ h1 -> modifies (loc counter) h0 h1 /\
as_seq h1 counter == BSeq.nat_to_intseq_be 4 (v i)) | false | false | Hacl.Impl.RSAPSS.MGF.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 counter_to_bytes:
i:size_t
-> counter:lbuffer uint8 4ul ->
Stack unit
(requires fun h -> live h counter)
(ensures fun h0 _ h1 -> modifies (loc counter) h0 h1 /\
as_seq h1 counter == BSeq.nat_to_intseq_be 4 (v i)) | [] | Hacl.Impl.RSAPSS.MGF.counter_to_bytes | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.MGF.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Lib.IntTypes.size_t -> counter: Lib.Buffer.lbuffer Lib.IntTypes.uint8 4ul
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 61,
"end_line": 71,
"start_col": 26,
"start_line": 60
} |
FStar.HyperStack.ST.Stack | val mgf_hash_f:
a:Hash.hash_alg{S.hash_is_supported a}
-> len:size_t{v len + 4 <= max_size_t /\ (v len + 4) `less_than_max_input_length` a}
-> i:size_t
-> mgfseed_counter:lbuffer uint8 (len +! 4ul)
-> block:lbuffer uint8 (hash_len a) ->
Stack unit
(requires fun h -> live h mgfseed_counter /\ live h block /\ disjoint mgfseed_counter block)
(ensures fun h0 _ h1 -> modifies (loc mgfseed_counter |+| loc block) h0 h1 /\
(as_seq h1 mgfseed_counter, as_seq h1 block) == S.mgf_hash_f a (v len) (v i) (as_seq h0 mgfseed_counter)) | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"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.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mgf_hash_f a len i mgfseed_counter block =
let h0 = ST.get () in
update_sub_f h0 mgfseed_counter len 4ul
(fun h -> BSeq.nat_to_intseq_be 4 (v i))
(fun _ ->
let c = sub mgfseed_counter len 4ul in
counter_to_bytes i c);
hash a block (len +! 4ul) mgfseed_counter | val mgf_hash_f:
a:Hash.hash_alg{S.hash_is_supported a}
-> len:size_t{v len + 4 <= max_size_t /\ (v len + 4) `less_than_max_input_length` a}
-> i:size_t
-> mgfseed_counter:lbuffer uint8 (len +! 4ul)
-> block:lbuffer uint8 (hash_len a) ->
Stack unit
(requires fun h -> live h mgfseed_counter /\ live h block /\ disjoint mgfseed_counter block)
(ensures fun h0 _ h1 -> modifies (loc mgfseed_counter |+| loc block) h0 h1 /\
(as_seq h1 mgfseed_counter, as_seq h1 block) == S.mgf_hash_f a (v len) (v i) (as_seq h0 mgfseed_counter))
let mgf_hash_f a len i mgfseed_counter block = | true | null | false | let h0 = ST.get () in
update_sub_f h0
mgfseed_counter
len
4ul
(fun h -> BSeq.nat_to_intseq_be 4 (v i))
(fun _ ->
let c = sub mgfseed_counter len 4ul in
counter_to_bytes i c);
hash a block (len +! 4ul) mgfseed_counter | {
"checked_file": "Hacl.Impl.RSAPSS.MGF.fst.checked",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.MGF.fst"
} | [] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.RSAPSS.hash_is_supported",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Hacl.Impl.RSAPSS.MGF.less_than_max_input_length",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.op_Plus_Bang",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.RSAPSS.MGF.hash_len",
"Hacl.Impl.RSAPSS.MGF.hash",
"Prims.unit",
"Lib.Buffer.update_sub_f",
"FStar.Monotonic.HyperStack.mem",
"Lib.ByteSequence.nat_to_intseq_be",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Sequence.lseq",
"Hacl.Impl.RSAPSS.MGF.counter_to_bytes",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"FStar.HyperStack.ST.get"
] | [] | module Hacl.Impl.RSAPSS.MGF
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 = Spec.RSAPSS
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module Hash = Spec.Agile.Hash
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val hash_len: a:Hash.hash_alg{S.hash_is_supported a} -> Tot (res:size_t{v res == Hash.hash_length a})
[@CInline]
let hash_len a =
Hacl.Hash.Definitions.hash_len a
inline_for_extraction noextract
let max_input_length = Hash.max_input_length
inline_for_extraction noextract
let less_than_max_input_length = Spec.Hash.Definitions.less_than_max_input_length
val hash:
a:Hash.hash_alg{S.hash_is_supported a}
-> mHash:lbuffer uint8 (hash_len a)
-> msgLen:size_t{v msgLen `less_than_max_input_length` a}
-> msg:lbuffer uint8 msgLen ->
Stack unit
(requires fun h -> live h mHash /\ live h msg /\ disjoint msg mHash)
(ensures fun h0 _ h1 -> modifies (loc mHash) h0 h1 /\
as_seq h1 mHash == Hash.hash a (as_seq h0 msg))
[@CInline]
let hash a mHash msgLen msg =
match a with
| Hash.SHA2_256 -> Hacl.Streaming.SHA2.hash_256 msg msgLen mHash
| Hash.SHA2_384 -> Hacl.Streaming.SHA2.hash_384 msg msgLen mHash
| Hash.SHA2_512 -> Hacl.Streaming.SHA2.hash_512 msg msgLen mHash
(* Mask Generation Function *)
inline_for_extraction noextract
val counter_to_bytes:
i:size_t
-> counter:lbuffer uint8 4ul ->
Stack unit
(requires fun h -> live h counter)
(ensures fun h0 _ h1 -> modifies (loc counter) h0 h1 /\
as_seq h1 counter == BSeq.nat_to_intseq_be 4 (v i))
let counter_to_bytes i c =
let h0 = ST.get () in
c.(0ul) <- to_u8 (i >>. 24ul);
c.(1ul) <- to_u8 (i >>. 16ul);
c.(2ul) <- to_u8 (i >>. 8ul);
c.(3ul) <- to_u8 i;
let h1 = ST.get () in
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 0;
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 1;
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 2;
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 3;
LSeq.eq_intro (as_seq h1 c) (BSeq.nat_to_intseq_be 4 (v i))
inline_for_extraction noextract
val mgf_hash_f:
a:Hash.hash_alg{S.hash_is_supported a}
-> len:size_t{v len + 4 <= max_size_t /\ (v len + 4) `less_than_max_input_length` a}
-> i:size_t
-> mgfseed_counter:lbuffer uint8 (len +! 4ul)
-> block:lbuffer uint8 (hash_len a) ->
Stack unit
(requires fun h -> live h mgfseed_counter /\ live h block /\ disjoint mgfseed_counter block)
(ensures fun h0 _ h1 -> modifies (loc mgfseed_counter |+| loc block) h0 h1 /\
(as_seq h1 mgfseed_counter, as_seq h1 block) == S.mgf_hash_f a (v len) (v i) (as_seq h0 mgfseed_counter)) | false | false | Hacl.Impl.RSAPSS.MGF.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 mgf_hash_f:
a:Hash.hash_alg{S.hash_is_supported a}
-> len:size_t{v len + 4 <= max_size_t /\ (v len + 4) `less_than_max_input_length` a}
-> i:size_t
-> mgfseed_counter:lbuffer uint8 (len +! 4ul)
-> block:lbuffer uint8 (hash_len a) ->
Stack unit
(requires fun h -> live h mgfseed_counter /\ live h block /\ disjoint mgfseed_counter block)
(ensures fun h0 _ h1 -> modifies (loc mgfseed_counter |+| loc block) h0 h1 /\
(as_seq h1 mgfseed_counter, as_seq h1 block) == S.mgf_hash_f a (v len) (v i) (as_seq h0 mgfseed_counter)) | [] | Hacl.Impl.RSAPSS.MGF.mgf_hash_f | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.MGF.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} ->
len:
Lib.IntTypes.size_t
{ Lib.IntTypes.v len + 4 <= Lib.IntTypes.max_size_t /\
Hacl.Impl.RSAPSS.MGF.less_than_max_input_length (Lib.IntTypes.v len + 4) a } ->
i: Lib.IntTypes.size_t ->
mgfseed_counter: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (len +! 4ul) ->
block: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.Impl.RSAPSS.MGF.hash_len a)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 43,
"end_line": 93,
"start_col": 46,
"start_line": 86
} |
Prims.Tot | val mgf_hash: a:Hash.hash_alg{S.hash_is_supported a} -> mgf_hash_st a | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"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.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mgf_hash a len mgfseed maskLen res =
push_frame ();
let mgfseed_counter = create (len +! 4ul) (u8 0) in
update_sub mgfseed_counter 0ul len mgfseed;
let hLen = hash_len a in
let n = blocks maskLen hLen in
let accLen = n *! hLen in
let acc = create accLen (u8 0) in
[@ inline_let]
let a_spec = S.mgf_hash_a (v len) (v n) in
let h0 = ST.get () in
fill_blocks h0 hLen n acc a_spec
(fun h i -> as_seq h mgfseed_counter)
(fun _ -> loc mgfseed_counter)
(fun h0 -> S.mgf_hash_f a (v len))
(fun i ->
let acc_i = sub acc (i *! hLen) hLen in
mgf_hash_f a len i mgfseed_counter acc_i);
copy res (sub acc 0ul maskLen);
pop_frame () | val mgf_hash: a:Hash.hash_alg{S.hash_is_supported a} -> mgf_hash_st a
let mgf_hash a len mgfseed maskLen res = | false | null | false | push_frame ();
let mgfseed_counter = create (len +! 4ul) (u8 0) in
update_sub mgfseed_counter 0ul len mgfseed;
let hLen = hash_len a in
let n = blocks maskLen hLen in
let accLen = n *! hLen in
let acc = create accLen (u8 0) in
[@@ inline_let ]let a_spec = S.mgf_hash_a (v len) (v n) in
let h0 = ST.get () in
fill_blocks h0
hLen
n
acc
a_spec
(fun h i -> as_seq h mgfseed_counter)
(fun _ -> loc mgfseed_counter)
(fun h0 -> S.mgf_hash_f a (v len))
(fun i ->
let acc_i = sub acc (i *! hLen) hLen in
mgf_hash_f a len i mgfseed_counter acc_i);
copy res (sub acc 0ul maskLen);
pop_frame () | {
"checked_file": "Hacl.Impl.RSAPSS.MGF.fst.checked",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.MGF.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.RSAPSS.hash_is_supported",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Hacl.Impl.RSAPSS.MGF.less_than_max_input_length",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Prims.op_LessThan",
"FStar.Mul.op_Star",
"Spec.RSAPSS.blocks",
"Spec.Hash.Definitions.hash_length",
"Prims.pow2",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Lib.Buffer.copy",
"Lib.Buffer.MUT",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.sub",
"Lib.IntTypes.uint_t",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.fill_blocks",
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_nat",
"Lib.Buffer.as_seq",
"Lib.IntTypes.op_Plus_Bang",
"Lib.Buffer.loc",
"LowStar.Monotonic.Buffer.loc",
"LowStar.Monotonic.Buffer.loc_disjoint",
"LowStar.Monotonic.Buffer.loc_includes",
"LowStar.Monotonic.Buffer.address_liveness_insensitive_locs",
"Spec.RSAPSS.mgf_hash_f",
"FStar.Pervasives.Native.tuple2",
"Lib.Sequence.lseq",
"Hacl.Impl.RSAPSS.MGF.mgf_hash_f",
"Lib.IntTypes.op_Star_Bang",
"FStar.HyperStack.ST.get",
"Prims.nat",
"Spec.RSAPSS.mgf_hash_a",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.op_GreaterThan",
"Prims.op_Subtraction",
"Prims.op_Multiply",
"Hacl.Spec.Bignum.Definitions.blocks",
"Hacl.Bignum.Definitions.blocks",
"Prims.op_GreaterThanOrEqual",
"Hacl.Impl.RSAPSS.MGF.hash_len",
"Lib.Buffer.update_sub",
"Lib.IntTypes.add",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.RSAPSS.MGF
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 = Spec.RSAPSS
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module Hash = Spec.Agile.Hash
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val hash_len: a:Hash.hash_alg{S.hash_is_supported a} -> Tot (res:size_t{v res == Hash.hash_length a})
[@CInline]
let hash_len a =
Hacl.Hash.Definitions.hash_len a
inline_for_extraction noextract
let max_input_length = Hash.max_input_length
inline_for_extraction noextract
let less_than_max_input_length = Spec.Hash.Definitions.less_than_max_input_length
val hash:
a:Hash.hash_alg{S.hash_is_supported a}
-> mHash:lbuffer uint8 (hash_len a)
-> msgLen:size_t{v msgLen `less_than_max_input_length` a}
-> msg:lbuffer uint8 msgLen ->
Stack unit
(requires fun h -> live h mHash /\ live h msg /\ disjoint msg mHash)
(ensures fun h0 _ h1 -> modifies (loc mHash) h0 h1 /\
as_seq h1 mHash == Hash.hash a (as_seq h0 msg))
[@CInline]
let hash a mHash msgLen msg =
match a with
| Hash.SHA2_256 -> Hacl.Streaming.SHA2.hash_256 msg msgLen mHash
| Hash.SHA2_384 -> Hacl.Streaming.SHA2.hash_384 msg msgLen mHash
| Hash.SHA2_512 -> Hacl.Streaming.SHA2.hash_512 msg msgLen mHash
(* Mask Generation Function *)
inline_for_extraction noextract
val counter_to_bytes:
i:size_t
-> counter:lbuffer uint8 4ul ->
Stack unit
(requires fun h -> live h counter)
(ensures fun h0 _ h1 -> modifies (loc counter) h0 h1 /\
as_seq h1 counter == BSeq.nat_to_intseq_be 4 (v i))
let counter_to_bytes i c =
let h0 = ST.get () in
c.(0ul) <- to_u8 (i >>. 24ul);
c.(1ul) <- to_u8 (i >>. 16ul);
c.(2ul) <- to_u8 (i >>. 8ul);
c.(3ul) <- to_u8 i;
let h1 = ST.get () in
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 0;
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 1;
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 2;
BSeq.index_nat_to_intseq_be #U8 #SEC 4 (v i) 3;
LSeq.eq_intro (as_seq h1 c) (BSeq.nat_to_intseq_be 4 (v i))
inline_for_extraction noextract
val mgf_hash_f:
a:Hash.hash_alg{S.hash_is_supported a}
-> len:size_t{v len + 4 <= max_size_t /\ (v len + 4) `less_than_max_input_length` a}
-> i:size_t
-> mgfseed_counter:lbuffer uint8 (len +! 4ul)
-> block:lbuffer uint8 (hash_len a) ->
Stack unit
(requires fun h -> live h mgfseed_counter /\ live h block /\ disjoint mgfseed_counter block)
(ensures fun h0 _ h1 -> modifies (loc mgfseed_counter |+| loc block) h0 h1 /\
(as_seq h1 mgfseed_counter, as_seq h1 block) == S.mgf_hash_f a (v len) (v i) (as_seq h0 mgfseed_counter))
let mgf_hash_f a len i mgfseed_counter block =
let h0 = ST.get () in
update_sub_f h0 mgfseed_counter len 4ul
(fun h -> BSeq.nat_to_intseq_be 4 (v i))
(fun _ ->
let c = sub mgfseed_counter len 4ul in
counter_to_bytes i c);
hash a block (len +! 4ul) mgfseed_counter
inline_for_extraction noextract
let mgf_hash_st (a:Hash.hash_alg{S.hash_is_supported a}) =
len:size_t{v len + 4 <= max_size_t /\ (v len + 4) `less_than_max_input_length` a}
-> mgfseed:lbuffer uint8 len
-> maskLen:size_t{0 < v maskLen /\ S.blocks (v maskLen) (Hash.hash_length a) * Hash.hash_length a < pow2 32}
-> res:lbuffer uint8 maskLen ->
Stack unit
(requires fun h -> live h mgfseed /\ live h res /\ disjoint res mgfseed)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.mgf_hash a (v len) (as_seq h0 mgfseed) (v maskLen))
#push-options "--z3rlimit 100"
val mgf_hash: a:Hash.hash_alg{S.hash_is_supported a} -> mgf_hash_st a
[@CInline] | false | false | Hacl.Impl.RSAPSS.MGF.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mgf_hash: a:Hash.hash_alg{S.hash_is_supported a} -> mgf_hash_st a | [] | Hacl.Impl.RSAPSS.MGF.mgf_hash | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.MGF.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a}
-> Hacl.Impl.RSAPSS.MGF.mgf_hash_st a | {
"end_col": 14,
"end_line": 130,
"start_col": 2,
"start_line": 111
} |
Prims.Tot | val cs:S.ciphersuite | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let cs:S.ciphersuite = (DH.DH_Curve25519, Hash.SHA2_256, S.Seal AEAD.CHACHA20_POLY1305, Hash.SHA2_256) | val cs:S.ciphersuite
let cs:S.ciphersuite = | false | null | false | (DH.DH_Curve25519, Hash.SHA2_256, S.Seal AEAD.CHACHA20_POLY1305, Hash.SHA2_256) | {
"checked_file": "Hacl.HPKE.Curve51_CP128_SHA256.fsti.checked",
"dependencies": [
"Spec.Agile.HPKE.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Hacl.Impl.HPKE.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.HPKE.Curve51_CP128_SHA256.fsti"
} | [
"total"
] | [
"FStar.Pervasives.Native.Mktuple4",
"Spec.Agile.DH.algorithm",
"Spec.Agile.HPKE.hash_algorithm",
"Spec.Agile.HPKE.aead",
"Spec.Hash.Definitions.hash_alg",
"Spec.Agile.DH.DH_Curve25519",
"Spec.Hash.Definitions.SHA2_256",
"Spec.Agile.HPKE.Seal",
"Spec.Agile.AEAD.CHACHA20_POLY1305"
] | [] | module Hacl.HPKE.Curve51_CP128_SHA256
open Hacl.Impl.HPKE
module S = Spec.Agile.HPKE
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash | false | true | Hacl.HPKE.Curve51_CP128_SHA256.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val cs:S.ciphersuite | [] | Hacl.HPKE.Curve51_CP128_SHA256.cs | {
"file_name": "code/hpke/Hacl.HPKE.Curve51_CP128_SHA256.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.Agile.HPKE.ciphersuite | {
"end_col": 102,
"end_line": 10,
"start_col": 23,
"start_line": 10
} |
Prims.Tot | val add1_: add1_t True | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Core",
"short_module": "CC"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Definition",
"short_module": "CD"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Lib.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let add1_ out f1 f2 =
let h0 = ST.get () in
let c = BN.bn_add1 4ul f1 f2 out in
let h1 = ST.get () in
assert (let c1, r1 = CC.add1 (as_seq h0 f1) f2 in c == c1 /\ as_seq h1 out == r1);
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out);
c | val add1_: add1_t True
let add1_ out f1 f2 = | false | null | false | let h0 = ST.get () in
let c = BN.bn_add1 4ul f1 f2 out in
let h1 = ST.get () in
assert (let c1, r1 = CC.add1 (as_seq h0 f1) f2 in
c == c1 /\ as_seq h1 out == r1);
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out);
c | {
"checked_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field64.Core.fst.checked",
"Hacl.Spec.Bignum.Lib.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M64",
"Lib.IntTypes.uint64",
"FStar.Ghost.hide",
"Prims.unit",
"Hacl.Spec.Curve25519.Field64.Definition.bn_v_is_as_nat",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Prims._assert",
"Hacl.Spec.Curve25519.Field64.Core.felem",
"Prims.l_and",
"Prims.eq2",
"Lib.IntTypes.sec_int_t",
"Lib.IntTypes.U64",
"Lib.Sequence.lseq",
"Hacl.Spec.Bignum.Definitions.limb",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Curve25519.Field64.Core.add1",
"FStar.Ghost.erased",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.bn_add1",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Impl.Curve25519.Field64.Hacl
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module B = Lib.Buffer
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module CD = Hacl.Spec.Curve25519.Field64.Definition
module CC = Hacl.Spec.Curve25519.Field64.Core
module BN = Hacl.Bignum
module BD = Hacl.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | true | Hacl.Impl.Curve25519.Field64.Hacl.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 add1_: add1_t True | [] | Hacl.Impl.Curve25519.Field64.Hacl.add1_ | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field64.Hacl.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.add1_t Prims.l_True | {
"end_col": 3,
"end_line": 35,
"start_col": 21,
"start_line": 28
} |
Prims.Tot | val fsqr_: fsqr_t M64 True | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Core",
"short_module": "CC"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Definition",
"short_module": "CD"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Lib.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fsqr_ out f1 tmp =
let h0 = ST.get () in
BN.bn_sqr 4ul f1 tmp;
SB.bn_sqr_lemma (as_seq h0 f1);
let c0 = BN.bn_mul1_lshift_add_in_place 4ul (sub tmp 4ul 4ul) (u64 38) 4ul 0ul (sub tmp 0ul 4ul) in
let c = BN.bn_add1 4ul (sub tmp 0ul 4ul) (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fsqr4 (as_seq h0 f1));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out) | val fsqr_: fsqr_t M64 True
let fsqr_ out f1 tmp = | false | null | false | let h0 = ST.get () in
BN.bn_sqr 4ul f1 tmp;
SB.bn_sqr_lemma (as_seq h0 f1);
let c0 = BN.bn_mul1_lshift_add_in_place 4ul (sub tmp 4ul 4ul) (u64 38) 4ul 0ul (sub tmp 0ul 4ul) in
let c = BN.bn_add1 4ul (sub tmp 0ul 4ul) (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fsqr4 (as_seq h0 f1));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out) | {
"checked_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field64.Core.fst.checked",
"Hacl.Spec.Bignum.Lib.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M64",
"Hacl.Impl.Curve25519.Fields.Core.felem_wide",
"Hacl.Spec.Curve25519.Field64.Definition.bn_v_is_as_nat",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Spec.Curve25519.Field64.Core.fsqr4",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.op_Array_Assignment",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.u64",
"Lib.Buffer.op_Array_Access",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.bn_add1",
"Hacl.Bignum.Definitions.lbignum",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"Hacl.Impl.Curve25519.Fields.Core.wide",
"Hacl.Impl.Curve25519.Fields.Core.nwide",
"Lib.Buffer.lbuffer_t",
"Hacl.Bignum.Definitions.limb",
"Hacl.Bignum.bn_mul1_lshift_add_in_place",
"Hacl.Spec.Bignum.bn_sqr_lemma",
"Hacl.Bignum.bn_sqr"
] | [] | module Hacl.Impl.Curve25519.Field64.Hacl
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module B = Lib.Buffer
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module CD = Hacl.Spec.Curve25519.Field64.Definition
module CC = Hacl.Spec.Curve25519.Field64.Core
module BN = Hacl.Bignum
module BD = Hacl.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let add1_ out f1 f2 =
let h0 = ST.get () in
let c = BN.bn_add1 4ul f1 f2 out in
let h1 = ST.get () in
assert (let c1, r1 = CC.add1 (as_seq h0 f1) f2 in c == c1 /\ as_seq h1 out == r1);
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out);
c
[@CInline]
let fadd_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_add_eq_len 4ul f1 f2 out in
let c = BN.bn_add1 4ul out (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fadd4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fsub_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_sub_eq_len 4ul f1 f2 out in
let c = BN.bn_sub1 4ul out (c0 *! u64 38) out in
out.(0ul) <- out.(0ul) -. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fsub4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fmul_ out f1 f2 tmp =
let h0 = ST.get () in
let tmp0 = sub tmp 0ul 8ul in
BN.bn_mul 4ul 4ul f1 f2 tmp0;
let c0 = BN.bn_mul1_lshift_add_in_place 4ul (sub tmp0 4ul 4ul) (u64 38) 4ul 0ul (sub tmp0 0ul 4ul) in
let c = BN.bn_add1 4ul (sub tmp0 0ul 4ul) (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fmul4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fmul2_ out f1 f2 tmp =
let out1 = B.sub out 0ul 4ul in
let out2 = B.sub out 4ul 4ul in
let f11 = B.sub f1 0ul 4ul in
let f12 = B.sub f1 4ul 4ul in
let f21 = B.sub f2 0ul 4ul in
let f22 = B.sub f2 4ul 4ul in
fmul_ out1 f11 f21 tmp;
fmul_ out2 f12 f22 tmp
[@CInline]
let fmul1_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_mul1 4ul f1 f2 out in
let c = BN.bn_add1 4ul out (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fmul14 (as_seq h0 f1) f2);
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out) | false | true | Hacl.Impl.Curve25519.Field64.Hacl.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fsqr_: fsqr_t M64 True | [] | Hacl.Impl.Curve25519.Field64.Hacl.fsqr_ | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field64.Hacl.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.fsqr_t Hacl.Impl.Curve25519.Fields.Core.M64 Prims.l_True | {
"end_col": 35,
"end_line": 114,
"start_col": 22,
"start_line": 104
} |
Prims.Tot | val fsqr2_: fsqr2_t M64 True | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Core",
"short_module": "CC"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Definition",
"short_module": "CD"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Lib.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fsqr2_ out f tmp =
let out1 = B.sub out 0ul 4ul in
let out2 = B.sub out 4ul 4ul in
let f1 = B.sub f 0ul 4ul in
let f2 = B.sub f 4ul 4ul in
fmul_ out1 f1 f1 tmp;
fmul_ out2 f2 f2 tmp | val fsqr2_: fsqr2_t M64 True
let fsqr2_ out f tmp = | false | null | false | let out1 = B.sub out 0ul 4ul in
let out2 = B.sub out 4ul 4ul in
let f1 = B.sub f 0ul 4ul in
let f2 = B.sub f 4ul 4ul in
fmul_ out1 f1 f1 tmp;
fmul_ out2 f2 f2 tmp | {
"checked_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field64.Core.fst.checked",
"Hacl.Spec.Bignum.Lib.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.felem2",
"Hacl.Impl.Curve25519.Fields.Core.M64",
"Hacl.Impl.Curve25519.Fields.Core.felem_wide2",
"Hacl.Impl.Curve25519.Field64.Hacl.fmul_",
"Prims.unit",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Impl.Curve25519.Field64.Hacl
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module B = Lib.Buffer
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module CD = Hacl.Spec.Curve25519.Field64.Definition
module CC = Hacl.Spec.Curve25519.Field64.Core
module BN = Hacl.Bignum
module BD = Hacl.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let add1_ out f1 f2 =
let h0 = ST.get () in
let c = BN.bn_add1 4ul f1 f2 out in
let h1 = ST.get () in
assert (let c1, r1 = CC.add1 (as_seq h0 f1) f2 in c == c1 /\ as_seq h1 out == r1);
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out);
c
[@CInline]
let fadd_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_add_eq_len 4ul f1 f2 out in
let c = BN.bn_add1 4ul out (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fadd4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fsub_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_sub_eq_len 4ul f1 f2 out in
let c = BN.bn_sub1 4ul out (c0 *! u64 38) out in
out.(0ul) <- out.(0ul) -. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fsub4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fmul_ out f1 f2 tmp =
let h0 = ST.get () in
let tmp0 = sub tmp 0ul 8ul in
BN.bn_mul 4ul 4ul f1 f2 tmp0;
let c0 = BN.bn_mul1_lshift_add_in_place 4ul (sub tmp0 4ul 4ul) (u64 38) 4ul 0ul (sub tmp0 0ul 4ul) in
let c = BN.bn_add1 4ul (sub tmp0 0ul 4ul) (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fmul4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fmul2_ out f1 f2 tmp =
let out1 = B.sub out 0ul 4ul in
let out2 = B.sub out 4ul 4ul in
let f11 = B.sub f1 0ul 4ul in
let f12 = B.sub f1 4ul 4ul in
let f21 = B.sub f2 0ul 4ul in
let f22 = B.sub f2 4ul 4ul in
fmul_ out1 f11 f21 tmp;
fmul_ out2 f12 f22 tmp
[@CInline]
let fmul1_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_mul1 4ul f1 f2 out in
let c = BN.bn_add1 4ul out (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fmul14 (as_seq h0 f1) f2);
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fsqr_ out f1 tmp =
let h0 = ST.get () in
BN.bn_sqr 4ul f1 tmp;
SB.bn_sqr_lemma (as_seq h0 f1);
let c0 = BN.bn_mul1_lshift_add_in_place 4ul (sub tmp 4ul 4ul) (u64 38) 4ul 0ul (sub tmp 0ul 4ul) in
let c = BN.bn_add1 4ul (sub tmp 0ul 4ul) (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fsqr4 (as_seq h0 f1));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out) | false | true | Hacl.Impl.Curve25519.Field64.Hacl.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 fsqr2_: fsqr2_t M64 True | [] | Hacl.Impl.Curve25519.Field64.Hacl.fsqr2_ | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field64.Hacl.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.fsqr2_t Hacl.Impl.Curve25519.Fields.Core.M64 Prims.l_True | {
"end_col": 22,
"end_line": 124,
"start_col": 22,
"start_line": 118
} |
Prims.Tot | val fmul1_: fmul1_t M64 True | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Core",
"short_module": "CC"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Definition",
"short_module": "CD"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Lib.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul1_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_mul1 4ul f1 f2 out in
let c = BN.bn_add1 4ul out (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fmul14 (as_seq h0 f1) f2);
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out) | val fmul1_: fmul1_t M64 True
let fmul1_ out f1 f2 = | false | null | false | let h0 = ST.get () in
let c0 = BN.bn_mul1 4ul f1 f2 out in
let c = BN.bn_add1 4ul out (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fmul14 (as_seq h0 f1) f2);
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out) | {
"checked_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field64.Core.fst.checked",
"Hacl.Spec.Bignum.Lib.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M64",
"Lib.IntTypes.uint64",
"Hacl.Spec.Curve25519.Field64.Definition.bn_v_is_as_nat",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Spec.Curve25519.Field64.Core.fmul14",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.op_Array_Assignment",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.u64",
"Lib.Buffer.op_Array_Access",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.bn_add1",
"Hacl.Bignum.Definitions.limb",
"Hacl.Bignum.bn_mul1"
] | [] | module Hacl.Impl.Curve25519.Field64.Hacl
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module B = Lib.Buffer
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module CD = Hacl.Spec.Curve25519.Field64.Definition
module CC = Hacl.Spec.Curve25519.Field64.Core
module BN = Hacl.Bignum
module BD = Hacl.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let add1_ out f1 f2 =
let h0 = ST.get () in
let c = BN.bn_add1 4ul f1 f2 out in
let h1 = ST.get () in
assert (let c1, r1 = CC.add1 (as_seq h0 f1) f2 in c == c1 /\ as_seq h1 out == r1);
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out);
c
[@CInline]
let fadd_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_add_eq_len 4ul f1 f2 out in
let c = BN.bn_add1 4ul out (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fadd4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fsub_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_sub_eq_len 4ul f1 f2 out in
let c = BN.bn_sub1 4ul out (c0 *! u64 38) out in
out.(0ul) <- out.(0ul) -. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fsub4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fmul_ out f1 f2 tmp =
let h0 = ST.get () in
let tmp0 = sub tmp 0ul 8ul in
BN.bn_mul 4ul 4ul f1 f2 tmp0;
let c0 = BN.bn_mul1_lshift_add_in_place 4ul (sub tmp0 4ul 4ul) (u64 38) 4ul 0ul (sub tmp0 0ul 4ul) in
let c = BN.bn_add1 4ul (sub tmp0 0ul 4ul) (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fmul4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fmul2_ out f1 f2 tmp =
let out1 = B.sub out 0ul 4ul in
let out2 = B.sub out 4ul 4ul in
let f11 = B.sub f1 0ul 4ul in
let f12 = B.sub f1 4ul 4ul in
let f21 = B.sub f2 0ul 4ul in
let f22 = B.sub f2 4ul 4ul in
fmul_ out1 f11 f21 tmp;
fmul_ out2 f12 f22 tmp | false | true | Hacl.Impl.Curve25519.Field64.Hacl.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 fmul1_: fmul1_t M64 True | [] | Hacl.Impl.Curve25519.Field64.Hacl.fmul1_ | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field64.Hacl.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.fmul1_t Hacl.Impl.Curve25519.Fields.Core.M64 Prims.l_True | {
"end_col": 35,
"end_line": 100,
"start_col": 22,
"start_line": 92
} |
Prims.Tot | val fadd_: fadd_t M64 True | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Core",
"short_module": "CC"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Definition",
"short_module": "CD"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Lib.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fadd_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_add_eq_len 4ul f1 f2 out in
let c = BN.bn_add1 4ul out (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fadd4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out) | val fadd_: fadd_t M64 True
let fadd_ out f1 f2 = | false | null | false | let h0 = ST.get () in
let c0 = BN.bn_add_eq_len 4ul f1 f2 out in
let c = BN.bn_add1 4ul out (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fadd4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out) | {
"checked_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field64.Core.fst.checked",
"Hacl.Spec.Bignum.Lib.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M64",
"Hacl.Spec.Curve25519.Field64.Definition.bn_v_is_as_nat",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Spec.Curve25519.Field64.Core.fadd4",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.op_Array_Assignment",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.u64",
"Lib.Buffer.op_Array_Access",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.bn_add1",
"Hacl.Bignum.bn_add_eq_len"
] | [] | module Hacl.Impl.Curve25519.Field64.Hacl
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module B = Lib.Buffer
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module CD = Hacl.Spec.Curve25519.Field64.Definition
module CC = Hacl.Spec.Curve25519.Field64.Core
module BN = Hacl.Bignum
module BD = Hacl.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let add1_ out f1 f2 =
let h0 = ST.get () in
let c = BN.bn_add1 4ul f1 f2 out in
let h1 = ST.get () in
assert (let c1, r1 = CC.add1 (as_seq h0 f1) f2 in c == c1 /\ as_seq h1 out == r1);
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out);
c | false | true | Hacl.Impl.Curve25519.Field64.Hacl.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 fadd_: fadd_t M64 True | [] | Hacl.Impl.Curve25519.Field64.Hacl.fadd_ | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field64.Hacl.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.fadd_t Hacl.Impl.Curve25519.Fields.Core.M64 Prims.l_True | {
"end_col": 35,
"end_line": 48,
"start_col": 21,
"start_line": 39
} |
Prims.Tot | val fmul_: fmul_t M64 True | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Core",
"short_module": "CC"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Definition",
"short_module": "CD"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Lib.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul_ out f1 f2 tmp =
let h0 = ST.get () in
let tmp0 = sub tmp 0ul 8ul in
BN.bn_mul 4ul 4ul f1 f2 tmp0;
let c0 = BN.bn_mul1_lshift_add_in_place 4ul (sub tmp0 4ul 4ul) (u64 38) 4ul 0ul (sub tmp0 0ul 4ul) in
let c = BN.bn_add1 4ul (sub tmp0 0ul 4ul) (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fmul4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out) | val fmul_: fmul_t M64 True
let fmul_ out f1 f2 tmp = | false | null | false | let h0 = ST.get () in
let tmp0 = sub tmp 0ul 8ul in
BN.bn_mul 4ul 4ul f1 f2 tmp0;
let c0 =
BN.bn_mul1_lshift_add_in_place 4ul (sub tmp0 4ul 4ul) (u64 38) 4ul 0ul (sub tmp0 0ul 4ul)
in
let c = BN.bn_add1 4ul (sub tmp0 0ul 4ul) (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fmul4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out) | {
"checked_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field64.Core.fst.checked",
"Hacl.Spec.Bignum.Lib.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M64",
"Hacl.Impl.Curve25519.Fields.Core.felem_wide2",
"Hacl.Spec.Curve25519.Field64.Definition.bn_v_is_as_nat",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Spec.Curve25519.Field64.Core.fmul4",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.op_Array_Assignment",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.u64",
"Lib.Buffer.op_Array_Access",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.bn_add1",
"Hacl.Bignum.Definitions.lbignum",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"Hacl.Impl.Curve25519.Fields.Core.wide",
"Lib.Buffer.lbuffer_t",
"Hacl.Bignum.Definitions.limb",
"Hacl.Bignum.bn_mul1_lshift_add_in_place",
"Hacl.Bignum.bn_mul",
"Hacl.Impl.Curve25519.Fields.Core.nwide"
] | [] | module Hacl.Impl.Curve25519.Field64.Hacl
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module B = Lib.Buffer
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module CD = Hacl.Spec.Curve25519.Field64.Definition
module CC = Hacl.Spec.Curve25519.Field64.Core
module BN = Hacl.Bignum
module BD = Hacl.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let add1_ out f1 f2 =
let h0 = ST.get () in
let c = BN.bn_add1 4ul f1 f2 out in
let h1 = ST.get () in
assert (let c1, r1 = CC.add1 (as_seq h0 f1) f2 in c == c1 /\ as_seq h1 out == r1);
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out);
c
[@CInline]
let fadd_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_add_eq_len 4ul f1 f2 out in
let c = BN.bn_add1 4ul out (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fadd4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fsub_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_sub_eq_len 4ul f1 f2 out in
let c = BN.bn_sub1 4ul out (c0 *! u64 38) out in
out.(0ul) <- out.(0ul) -. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fsub4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out) | false | true | Hacl.Impl.Curve25519.Field64.Hacl.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 fmul_: fmul_t M64 True | [] | Hacl.Impl.Curve25519.Field64.Hacl.fmul_ | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field64.Hacl.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.fmul_t Hacl.Impl.Curve25519.Fields.Core.M64 Prims.l_True | {
"end_col": 35,
"end_line": 76,
"start_col": 25,
"start_line": 65
} |
Prims.Tot | val fsub_: fsub_t M64 True | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Core",
"short_module": "CC"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Definition",
"short_module": "CD"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Lib.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fsub_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_sub_eq_len 4ul f1 f2 out in
let c = BN.bn_sub1 4ul out (c0 *! u64 38) out in
out.(0ul) <- out.(0ul) -. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fsub4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out) | val fsub_: fsub_t M64 True
let fsub_ out f1 f2 = | false | null | false | let h0 = ST.get () in
let c0 = BN.bn_sub_eq_len 4ul f1 f2 out in
let c = BN.bn_sub1 4ul out (c0 *! u64 38) out in
out.(0ul) <- out.(0ul) -. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fsub4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out) | {
"checked_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field64.Core.fst.checked",
"Hacl.Spec.Bignum.Lib.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M64",
"Hacl.Spec.Curve25519.Field64.Definition.bn_v_is_as_nat",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Spec.Curve25519.Field64.Core.fsub4",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.op_Array_Assignment",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.u64",
"Lib.Buffer.op_Array_Access",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.bn_sub1",
"Lib.IntTypes.op_Star_Bang",
"Hacl.Bignum.bn_sub_eq_len"
] | [] | module Hacl.Impl.Curve25519.Field64.Hacl
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module B = Lib.Buffer
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module CD = Hacl.Spec.Curve25519.Field64.Definition
module CC = Hacl.Spec.Curve25519.Field64.Core
module BN = Hacl.Bignum
module BD = Hacl.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let add1_ out f1 f2 =
let h0 = ST.get () in
let c = BN.bn_add1 4ul f1 f2 out in
let h1 = ST.get () in
assert (let c1, r1 = CC.add1 (as_seq h0 f1) f2 in c == c1 /\ as_seq h1 out == r1);
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out);
c
[@CInline]
let fadd_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_add_eq_len 4ul f1 f2 out in
let c = BN.bn_add1 4ul out (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fadd4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out) | false | true | Hacl.Impl.Curve25519.Field64.Hacl.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 fsub_: fsub_t M64 True | [] | Hacl.Impl.Curve25519.Field64.Hacl.fsub_ | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field64.Hacl.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.fsub_t Hacl.Impl.Curve25519.Fields.Core.M64 Prims.l_True | {
"end_col": 35,
"end_line": 61,
"start_col": 21,
"start_line": 52
} |
Prims.Tot | val fmul2_: fmul2_t M64 True | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Core",
"short_module": "CC"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Definition",
"short_module": "CD"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Lib.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul2_ out f1 f2 tmp =
let out1 = B.sub out 0ul 4ul in
let out2 = B.sub out 4ul 4ul in
let f11 = B.sub f1 0ul 4ul in
let f12 = B.sub f1 4ul 4ul in
let f21 = B.sub f2 0ul 4ul in
let f22 = B.sub f2 4ul 4ul in
fmul_ out1 f11 f21 tmp;
fmul_ out2 f12 f22 tmp | val fmul2_: fmul2_t M64 True
let fmul2_ out f1 f2 tmp = | false | null | false | let out1 = B.sub out 0ul 4ul in
let out2 = B.sub out 4ul 4ul in
let f11 = B.sub f1 0ul 4ul in
let f12 = B.sub f1 4ul 4ul in
let f21 = B.sub f2 0ul 4ul in
let f22 = B.sub f2 4ul 4ul in
fmul_ out1 f11 f21 tmp;
fmul_ out2 f12 f22 tmp | {
"checked_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field64.Core.fst.checked",
"Hacl.Spec.Bignum.Lib.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.felem2",
"Hacl.Impl.Curve25519.Fields.Core.M64",
"Hacl.Impl.Curve25519.Fields.Core.felem_wide2",
"Hacl.Impl.Curve25519.Field64.Hacl.fmul_",
"Prims.unit",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Impl.Curve25519.Field64.Hacl
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module B = Lib.Buffer
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module CD = Hacl.Spec.Curve25519.Field64.Definition
module CC = Hacl.Spec.Curve25519.Field64.Core
module BN = Hacl.Bignum
module BD = Hacl.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let add1_ out f1 f2 =
let h0 = ST.get () in
let c = BN.bn_add1 4ul f1 f2 out in
let h1 = ST.get () in
assert (let c1, r1 = CC.add1 (as_seq h0 f1) f2 in c == c1 /\ as_seq h1 out == r1);
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out);
c
[@CInline]
let fadd_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_add_eq_len 4ul f1 f2 out in
let c = BN.bn_add1 4ul out (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fadd4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fsub_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_sub_eq_len 4ul f1 f2 out in
let c = BN.bn_sub1 4ul out (c0 *! u64 38) out in
out.(0ul) <- out.(0ul) -. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fsub4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fmul_ out f1 f2 tmp =
let h0 = ST.get () in
let tmp0 = sub tmp 0ul 8ul in
BN.bn_mul 4ul 4ul f1 f2 tmp0;
let c0 = BN.bn_mul1_lshift_add_in_place 4ul (sub tmp0 4ul 4ul) (u64 38) 4ul 0ul (sub tmp0 0ul 4ul) in
let c = BN.bn_add1 4ul (sub tmp0 0ul 4ul) (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fmul4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out) | false | true | Hacl.Impl.Curve25519.Field64.Hacl.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 fmul2_: fmul2_t M64 True | [] | Hacl.Impl.Curve25519.Field64.Hacl.fmul2_ | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field64.Hacl.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.fmul2_t Hacl.Impl.Curve25519.Fields.Core.M64 Prims.l_True | {
"end_col": 24,
"end_line": 88,
"start_col": 26,
"start_line": 80
} |
Prims.Tot | val cswap2_: cswap2_t M64 True | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Core",
"short_module": "CC"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Definition",
"short_module": "CD"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Lib.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let cswap2_ bit p1 p2 =
let h0 = ST.get () in
let mask = u64 0 -. bit in
[@ inline_let]
let inv h1 (i:nat{i <= 8}) =
(forall (k:nat{k < i}).
if v bit = 1
then (as_seq h1 p1).[k] == (as_seq h0 p2).[k] /\ (as_seq h1 p2).[k] == (as_seq h0 p1).[k]
else (as_seq h1 p1).[k] == (as_seq h0 p1).[k] /\ (as_seq h1 p2).[k] == (as_seq h0 p2).[k]) /\
(forall (k:nat{i <= k /\ k < 8}).
(as_seq h1 p1).[k] == (as_seq h0 p1).[k] /\ (as_seq h1 p2).[k] == (as_seq h0 p2).[k]) /\
modifies (loc p1 |+| loc p2) h0 h1 in
Lib.Loops.for 0ul 8ul inv
(fun i ->
let dummy = mask &. (p1.(i) ^. p2.(i)) in
p1.(i) <- p1.(i) ^. dummy;
p2.(i) <- p2.(i) ^. dummy;
Hacl.Spec.Bignum.Lib.lemma_cswap2_step bit ((as_seq h0 p1).[v i]) ((as_seq h0 p2).[v i])
);
let h1 = ST.get () in
assert (if v bit = 1 then (eq_intro (as_seq h1 p1) (as_seq h0 p2); as_seq h1 p1 == as_seq h0 p2)
else (eq_intro (as_seq h1 p1) (as_seq h0 p1); as_seq h1 p1 == as_seq h0 p1));
assert (if v bit = 1 then (eq_intro (as_seq h1 p2) (as_seq h0 p1); as_seq h1 p2 == as_seq h0 p1)
else (eq_intro (as_seq h1 p2) (as_seq h0 p2); as_seq h1 p2 == as_seq h0 p2)) | val cswap2_: cswap2_t M64 True
let cswap2_ bit p1 p2 = | false | null | false | let h0 = ST.get () in
let mask = u64 0 -. bit in
[@@ inline_let ]let inv h1 (i: nat{i <= 8}) =
(forall (k: nat{k < i}).
if v bit = 1
then
(as_seq h1 p1).[ k ] == (as_seq h0 p2).[ k ] /\ (as_seq h1 p2).[ k ] == (as_seq h0 p1).[ k ]
else
(as_seq h1 p1).[ k ] == (as_seq h0 p1).[ k ] /\ (as_seq h1 p2).[ k ] == (as_seq h0 p2).[ k ]
) /\
(forall (k: nat{i <= k /\ k < 8}).
(as_seq h1 p1).[ k ] == (as_seq h0 p1).[ k ] /\ (as_seq h1 p2).[ k ] == (as_seq h0 p2).[ k ]) /\
modifies (loc p1 |+| loc p2) h0 h1
in
Lib.Loops.for 0ul
8ul
inv
(fun i ->
let dummy = mask &. (p1.(i) ^. p2.(i)) in
p1.(i) <- p1.(i) ^. dummy;
p2.(i) <- p2.(i) ^. dummy;
Hacl.Spec.Bignum.Lib.lemma_cswap2_step bit ((as_seq h0 p1).[ v i ]) ((as_seq h0 p2).[ v i ]));
let h1 = ST.get () in
assert (if v bit = 1
then
(eq_intro (as_seq h1 p1) (as_seq h0 p2);
as_seq h1 p1 == as_seq h0 p2)
else
(eq_intro (as_seq h1 p1) (as_seq h0 p1);
as_seq h1 p1 == as_seq h0 p1));
assert (if v bit = 1
then
(eq_intro (as_seq h1 p2) (as_seq h0 p1);
as_seq h1 p2 == as_seq h0 p1)
else
(eq_intro (as_seq h1 p2) (as_seq h0 p2);
as_seq h1 p2 == as_seq h0 p2)) | {
"checked_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field64.Core.fst.checked",
"Hacl.Spec.Bignum.Lib.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Field64.Hacl.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint64",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Impl.Curve25519.Fields.Core.felem2",
"Hacl.Impl.Curve25519.Fields.Core.M64",
"Prims._assert",
"Prims.op_Equality",
"Prims.int",
"Prims.eq2",
"Lib.Sequence.lseq",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.op_Plus_Dot",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Lib.Sequence.eq_intro",
"Prims.bool",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Loops.for",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Lib.lemma_cswap2_step",
"Lib.Sequence.op_String_Access",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Hat_Dot",
"Lib.Buffer.op_Array_Access",
"Lib.IntTypes.op_Amp_Dot",
"Prims.nat",
"Prims.logical",
"Prims.l_Forall",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.u64"
] | [] | module Hacl.Impl.Curve25519.Field64.Hacl
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module B = Lib.Buffer
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module CD = Hacl.Spec.Curve25519.Field64.Definition
module CC = Hacl.Spec.Curve25519.Field64.Core
module BN = Hacl.Bignum
module BD = Hacl.Bignum.Definitions
module SB = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let add1_ out f1 f2 =
let h0 = ST.get () in
let c = BN.bn_add1 4ul f1 f2 out in
let h1 = ST.get () in
assert (let c1, r1 = CC.add1 (as_seq h0 f1) f2 in c == c1 /\ as_seq h1 out == r1);
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out);
c
[@CInline]
let fadd_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_add_eq_len 4ul f1 f2 out in
let c = BN.bn_add1 4ul out (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fadd4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fsub_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_sub_eq_len 4ul f1 f2 out in
let c = BN.bn_sub1 4ul out (c0 *! u64 38) out in
out.(0ul) <- out.(0ul) -. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fsub4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fmul_ out f1 f2 tmp =
let h0 = ST.get () in
let tmp0 = sub tmp 0ul 8ul in
BN.bn_mul 4ul 4ul f1 f2 tmp0;
let c0 = BN.bn_mul1_lshift_add_in_place 4ul (sub tmp0 4ul 4ul) (u64 38) 4ul 0ul (sub tmp0 0ul 4ul) in
let c = BN.bn_add1 4ul (sub tmp0 0ul 4ul) (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fmul4 (as_seq h0 f1) (as_seq h0 f2));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h0 f2);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fmul2_ out f1 f2 tmp =
let out1 = B.sub out 0ul 4ul in
let out2 = B.sub out 4ul 4ul in
let f11 = B.sub f1 0ul 4ul in
let f12 = B.sub f1 4ul 4ul in
let f21 = B.sub f2 0ul 4ul in
let f22 = B.sub f2 4ul 4ul in
fmul_ out1 f11 f21 tmp;
fmul_ out2 f12 f22 tmp
[@CInline]
let fmul1_ out f1 f2 =
let h0 = ST.get () in
let c0 = BN.bn_mul1 4ul f1 f2 out in
let c = BN.bn_add1 4ul out (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fmul14 (as_seq h0 f1) f2);
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fsqr_ out f1 tmp =
let h0 = ST.get () in
BN.bn_sqr 4ul f1 tmp;
SB.bn_sqr_lemma (as_seq h0 f1);
let c0 = BN.bn_mul1_lshift_add_in_place 4ul (sub tmp 4ul 4ul) (u64 38) 4ul 0ul (sub tmp 0ul 4ul) in
let c = BN.bn_add1 4ul (sub tmp 0ul 4ul) (c0 *. u64 38) out in
out.(0ul) <- out.(0ul) +. c *. u64 38;
let h1 = ST.get () in
assert (as_seq h1 out == CC.fsqr4 (as_seq h0 f1));
CD.bn_v_is_as_nat (as_seq h0 f1);
CD.bn_v_is_as_nat (as_seq h1 out)
[@CInline]
let fsqr2_ out f tmp =
let out1 = B.sub out 0ul 4ul in
let out2 = B.sub out 4ul 4ul in
let f1 = B.sub f 0ul 4ul in
let f2 = B.sub f 4ul 4ul in
fmul_ out1 f1 f1 tmp;
fmul_ out2 f2 f2 tmp | false | true | Hacl.Impl.Curve25519.Field64.Hacl.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 cswap2_: cswap2_t M64 True | [] | Hacl.Impl.Curve25519.Field64.Hacl.cswap2_ | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field64.Hacl.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.cswap2_t Hacl.Impl.Curve25519.Fields.Core.M64 Prims.l_True | {
"end_col": 80,
"end_line": 153,
"start_col": 23,
"start_line": 128
} |
Prims.Tot | val tl: l:list 'a {Cons? l} -> Tot (list 'a) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tl = tail | val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = | false | null | false | tail | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"FStar.List.Tot.Base.tail"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*) | false | false | FStar.List.Tot.Base.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 tl: l:list 'a {Cons? l} -> Tot (list 'a) | [] | FStar.List.Tot.Base.tl | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list 'a {Cons? l} -> Prims.list 'a | {
"end_col": 13,
"end_line": 53,
"start_col": 9,
"start_line": 53
} |
Prims.Tot | val isEmpty: list 'a -> Tot bool | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let isEmpty l = match l with
| [] -> true
| _ -> false | val isEmpty: list 'a -> Tot bool
let isEmpty l = | false | null | false | match l with
| [] -> true
| _ -> false | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.bool"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *) | false | false | FStar.List.Tot.Base.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 isEmpty: list 'a -> Tot bool | [] | FStar.List.Tot.Base.isEmpty | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list 'a -> Prims.bool | {
"end_col": 14,
"end_line": 34,
"start_col": 16,
"start_line": 32
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_At x y = append x y | let op_At x y = | false | null | false | append x y | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"FStar.List.Tot.Base.append"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y | false | false | FStar.List.Tot.Base.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 op_At : x: Prims.list _ -> y: Prims.list _ -> Prims.list _ | [] | FStar.List.Tot.Base.op_At | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: Prims.list _ -> y: Prims.list _ -> Prims.list _ | {
"end_col": 26,
"end_line": 124,
"start_col": 16,
"start_line": 124
} |
|
Prims.GTot | val map_gtot (#a #b: _) (f: (a -> GTot b)) (x: list a) : GTot (list b) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) [] | val map_gtot (#a #b: _) (f: (a -> GTot b)) (x: list a) : GTot (list b)
let map_gtot #a #b (f: (a -> GTot b)) (x: list a) : GTot (list b) = | false | null | false | fold_right_gtot x (fun x tl -> f x :: tl) [] | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"sometrivial"
] | [
"Prims.list",
"FStar.List.Tot.Base.fold_right_gtot",
"Prims.Cons",
"Prims.Nil"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a) | false | false | FStar.List.Tot.Base.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 map_gtot (#a #b: _) (f: (a -> GTot b)) (x: list a) : GTot (list b) | [] | FStar.List.Tot.Base.map_gtot | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> Prims.GTot b) -> x: Prims.list a -> Prims.GTot (Prims.list b) | {
"end_col": 48,
"end_line": 210,
"start_col": 4,
"start_line": 210
} |
Prims.Tot | val contains: #a: eqtype -> a -> list a -> Tot bool | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let contains : #a:eqtype -> a -> list a -> Tot bool = mem | val contains: #a: eqtype -> a -> list a -> Tot bool
let contains: #a: eqtype -> a -> list a -> Tot bool = | false | null | false | mem | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"FStar.List.Tot.Base.mem"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x | false | false | FStar.List.Tot.Base.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 contains: #a: eqtype -> a -> list a -> Tot bool | [] | FStar.List.Tot.Base.contains | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: a -> _: Prims.list a -> Prims.bool | {
"end_col": 57,
"end_line": 248,
"start_col": 54,
"start_line": 248
} |
Prims.Tot | val snoc: (list 'a * 'a) -> Tot (list 'a) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let snoc (l, x) = append l [x] | val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = | false | null | false | append l [x] | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"Prims.list",
"FStar.List.Tot.Base.append",
"Prims.Cons",
"Prims.Nil"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *) | false | false | FStar.List.Tot.Base.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 snoc: (list 'a * 'a) -> Tot (list 'a) | [] | FStar.List.Tot.Base.snoc | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: (Prims.list 'a * 'a) -> Prims.list 'a | {
"end_col": 30,
"end_line": 137,
"start_col": 18,
"start_line": 137
} |
Prims.Tot | val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mapi f l = mapi_init f l 0 | val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = | false | null | false | mapi_init f l 0 | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.int",
"Prims.list",
"FStar.List.Tot.Base.mapi_init"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *) | false | false | FStar.List.Tot.Base.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 mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b) | [] | FStar.List.Tot.Base.mapi | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: Prims.int -> _: 'a -> 'b) -> l: Prims.list 'a -> Prims.list 'b | {
"end_col": 30,
"end_line": 169,
"start_col": 15,
"start_line": 169
} |
Prims.Pure | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let strict_prefix_of = strict_suffix_of | let strict_prefix_of = | false | null | false | strict_suffix_of | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
""
] | [
"FStar.List.Tot.Base.strict_suffix_of",
"Prims.list",
"Prims.l_True"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl
(** [no_repeats_p l] valid if, and only if, no element of [l]
appears in [l] more than once. *)
val no_repeats_p : #a:Type -> list a -> Tot prop
let rec no_repeats_p #a la =
match la with
| [] -> True
| h :: tl -> ~(memP h tl) /\ no_repeats_p tl
(** List of tuples **)
(** [assoc x l] returns [Some y] where [(x, y)] is the first element
of [l] whose first element is [x], or [None] only if no such element
exists. Requires, at type-checking time, the type of [x] to have
decidable equality. Named as in: OCaml. *)
val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b)
let rec assoc #a #b x = function
| [] -> None
| (x', y)::tl -> if x=x' then Some y else assoc x tl
(** [split] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
OCaml *)
val split: list ('a * 'b) -> Tot (list 'a * list 'b)
let rec split l = match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = split tl in
(hd1::tl1,hd2::tl2)
(** [unzip] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
Haskell *)
let unzip l = split l
(** [unzip3] takes a list of triples [(x1, y1, z1), ..., (xn, yn, zn)]
and returns the triple of lists ([x1, ..., xn], [y1, ..., yn], [z1,
..., zn]). Named as in: Haskell *)
val unzip3: list ('a * 'b * 'c) -> Tot (list 'a * list 'b * list 'c)
let rec unzip3 l = match l with
| [] -> ([],[],[])
| (hd1,hd2,hd3)::tl ->
let (tl1,tl2,tl3) = unzip3 tl in
(hd1::tl1,hd2::tl2,hd3::tl3)
(** Splitting a list at some index **)
(** [splitAt] takes a natural number n and a list and returns a pair
of the maximal prefix of l of size smaller than n and the rest of
the list *)
let rec splitAt (#a:Type) (n:nat) (l:list a) : Tot (list a * list a) =
if n = 0 then [], l
else
match l with
| [] -> [], l
| x :: xs -> let l1, l2 = splitAt (n-1) xs in x :: l1, l2
let rec lemma_splitAt_snd_length (#a:Type) (n:nat) (l:list a) :
Lemma
(requires (n <= length l))
(ensures (length (snd (splitAt n l)) = length l - n)) =
match n, l with
| 0, _ -> ()
| _, [] -> ()
| _, _ :: l' -> lemma_splitAt_snd_length (n - 1) l'
(** [unsnoc] is an inverse of [snoc]. It splits a list into
all-elements-except-last and last element. *)
val unsnoc: #a:Type -> l:list a{length l > 0} -> Tot (list a * a)
let unsnoc #a l =
let l1, l2 = splitAt (length l - 1) l in
lemma_splitAt_snd_length (length l - 1) l;
l1, hd l2
(** [split3] splits a list into 3 parts. This allows easy access to
the part of the list before and after the element, as well as the
element itself. *)
val split3: #a:Type -> l:list a -> i:nat{i < length l} -> Tot (list a * a * list a)
let split3 #a l i =
let a, rest = splitAt i l in
lemma_splitAt_snd_length i l;
let b :: c = rest in
a, b, c
(** Sorting (implemented as quicksort) **)
(** [partition] splits a list [l] into two lists, the sum of whose
lengths is the length of [l]. *)
val partition_length: f:('a -> Tot bool)
-> l:list 'a
-> Lemma (requires True)
(ensures (length (fst (partition f l))
+ length (snd (partition f l)) = length l))
let rec partition_length f l = match l with
| [] -> ()
| hd::tl -> partition_length f tl
(** [bool_of_compare] turns a comparison function into a strict
order. More precisely, [bool_of_compare compare x y] returns true
if, and only if, [compare x y] is negative, meaning [x] precedes
[y] in the ordering defined by compare.
This is used in sorting, and is defined to be consistent with
OCaml and F#, where sorting is performed in ascending order.
*)
val bool_of_compare : #a:Type -> (a -> a -> Tot int) -> a -> a -> Tot bool
let bool_of_compare #a f x y = f x y < 0
(** [compare_of_bool] turns a strict order into a comparison
function. More precisely, [compare_of_bool rel x y] returns a positive
number if, and only if, x `rel` y holds. Inspired from OCaml, where
polymorphic comparison using both the [compare] function and the (>)
infix operator are such that [compare x y] is positive if, and only
if, x > y. Requires, at type-checking time, [rel] to be a pure total
function. *)
val compare_of_bool : #a:eqtype -> (a -> a -> Tot bool) -> a -> a -> Tot int
let compare_of_bool #a rel x y =
if x `rel` y then -1
else if x = y then 0
else 1
let compare_of_bool_of_compare (#a:eqtype) (f:a -> a -> Tot bool)
: Lemma (forall x y. bool_of_compare (compare_of_bool f) x y == f x y)
= ()
(** [sortWith compare l] returns the list [l'] containing the elements
of [l] sorted along the comparison function [compare], in such a
way that if [compare x y > 0], then [x] appears before [y] in
[l']. Sorts in ascending order *)
val sortWith: ('a -> 'a -> Tot int) -> l:list 'a -> Tot (list 'a) (decreases (length l))
let rec sortWith f = function
| [] -> []
| pivot::tl ->
let hi, lo = partition (bool_of_compare f pivot) tl in
partition_length (bool_of_compare f pivot) tl;
append (sortWith f lo) (pivot::sortWith f hi)
(** A l1 is a strict suffix of l2. *)
let rec strict_suffix_of (#a: Type) (l1 l2: list a)
: Pure Type0
(requires True)
(ensures (fun _ -> True))
(decreases l2)
= match l2 with
| [] -> False
| _ :: q -> l1 == q \/ l1 `strict_suffix_of` q | false | false | FStar.List.Tot.Base.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 strict_prefix_of : l1: Prims.list _ -> l2: Prims.list _ -> Prims.Pure Type0 | [] | FStar.List.Tot.Base.strict_prefix_of | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l1: Prims.list _ -> l2: Prims.list _ -> Prims.Pure Type0 | {
"end_col": 39,
"end_line": 541,
"start_col": 23,
"start_line": 541
} |
|
Prims.Tot | val bool_of_compare : #a:Type -> (a -> a -> Tot int) -> a -> a -> Tot bool | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bool_of_compare #a f x y = f x y < 0 | val bool_of_compare : #a:Type -> (a -> a -> Tot int) -> a -> a -> Tot bool
let bool_of_compare #a f x y = | false | null | false | f x y < 0 | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.int",
"Prims.op_LessThan",
"Prims.bool"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl
(** [no_repeats_p l] valid if, and only if, no element of [l]
appears in [l] more than once. *)
val no_repeats_p : #a:Type -> list a -> Tot prop
let rec no_repeats_p #a la =
match la with
| [] -> True
| h :: tl -> ~(memP h tl) /\ no_repeats_p tl
(** List of tuples **)
(** [assoc x l] returns [Some y] where [(x, y)] is the first element
of [l] whose first element is [x], or [None] only if no such element
exists. Requires, at type-checking time, the type of [x] to have
decidable equality. Named as in: OCaml. *)
val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b)
let rec assoc #a #b x = function
| [] -> None
| (x', y)::tl -> if x=x' then Some y else assoc x tl
(** [split] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
OCaml *)
val split: list ('a * 'b) -> Tot (list 'a * list 'b)
let rec split l = match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = split tl in
(hd1::tl1,hd2::tl2)
(** [unzip] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
Haskell *)
let unzip l = split l
(** [unzip3] takes a list of triples [(x1, y1, z1), ..., (xn, yn, zn)]
and returns the triple of lists ([x1, ..., xn], [y1, ..., yn], [z1,
..., zn]). Named as in: Haskell *)
val unzip3: list ('a * 'b * 'c) -> Tot (list 'a * list 'b * list 'c)
let rec unzip3 l = match l with
| [] -> ([],[],[])
| (hd1,hd2,hd3)::tl ->
let (tl1,tl2,tl3) = unzip3 tl in
(hd1::tl1,hd2::tl2,hd3::tl3)
(** Splitting a list at some index **)
(** [splitAt] takes a natural number n and a list and returns a pair
of the maximal prefix of l of size smaller than n and the rest of
the list *)
let rec splitAt (#a:Type) (n:nat) (l:list a) : Tot (list a * list a) =
if n = 0 then [], l
else
match l with
| [] -> [], l
| x :: xs -> let l1, l2 = splitAt (n-1) xs in x :: l1, l2
let rec lemma_splitAt_snd_length (#a:Type) (n:nat) (l:list a) :
Lemma
(requires (n <= length l))
(ensures (length (snd (splitAt n l)) = length l - n)) =
match n, l with
| 0, _ -> ()
| _, [] -> ()
| _, _ :: l' -> lemma_splitAt_snd_length (n - 1) l'
(** [unsnoc] is an inverse of [snoc]. It splits a list into
all-elements-except-last and last element. *)
val unsnoc: #a:Type -> l:list a{length l > 0} -> Tot (list a * a)
let unsnoc #a l =
let l1, l2 = splitAt (length l - 1) l in
lemma_splitAt_snd_length (length l - 1) l;
l1, hd l2
(** [split3] splits a list into 3 parts. This allows easy access to
the part of the list before and after the element, as well as the
element itself. *)
val split3: #a:Type -> l:list a -> i:nat{i < length l} -> Tot (list a * a * list a)
let split3 #a l i =
let a, rest = splitAt i l in
lemma_splitAt_snd_length i l;
let b :: c = rest in
a, b, c
(** Sorting (implemented as quicksort) **)
(** [partition] splits a list [l] into two lists, the sum of whose
lengths is the length of [l]. *)
val partition_length: f:('a -> Tot bool)
-> l:list 'a
-> Lemma (requires True)
(ensures (length (fst (partition f l))
+ length (snd (partition f l)) = length l))
let rec partition_length f l = match l with
| [] -> ()
| hd::tl -> partition_length f tl
(** [bool_of_compare] turns a comparison function into a strict
order. More precisely, [bool_of_compare compare x y] returns true
if, and only if, [compare x y] is negative, meaning [x] precedes
[y] in the ordering defined by compare.
This is used in sorting, and is defined to be consistent with
OCaml and F#, where sorting is performed in ascending order.
*) | false | false | FStar.List.Tot.Base.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 bool_of_compare : #a:Type -> (a -> a -> Tot int) -> a -> a -> Tot bool | [] | FStar.List.Tot.Base.bool_of_compare | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> _: a -> Prims.int) -> x: a -> y: a -> Prims.bool | {
"end_col": 40,
"end_line": 499,
"start_col": 31,
"start_line": 499
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let unzip l = split l | let unzip l = | false | null | false | split l | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"FStar.List.Tot.Base.split"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl
(** [no_repeats_p l] valid if, and only if, no element of [l]
appears in [l] more than once. *)
val no_repeats_p : #a:Type -> list a -> Tot prop
let rec no_repeats_p #a la =
match la with
| [] -> True
| h :: tl -> ~(memP h tl) /\ no_repeats_p tl
(** List of tuples **)
(** [assoc x l] returns [Some y] where [(x, y)] is the first element
of [l] whose first element is [x], or [None] only if no such element
exists. Requires, at type-checking time, the type of [x] to have
decidable equality. Named as in: OCaml. *)
val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b)
let rec assoc #a #b x = function
| [] -> None
| (x', y)::tl -> if x=x' then Some y else assoc x tl
(** [split] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
OCaml *)
val split: list ('a * 'b) -> Tot (list 'a * list 'b)
let rec split l = match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = split tl in
(hd1::tl1,hd2::tl2)
(** [unzip] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in: | false | false | FStar.List.Tot.Base.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 unzip : l: Prims.list (_ * _) -> Prims.list _ * Prims.list _ | [] | FStar.List.Tot.Base.unzip | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list (_ * _) -> Prims.list _ * Prims.list _ | {
"end_col": 21,
"end_line": 426,
"start_col": 14,
"start_line": 426
} |
|
FStar.Pervasives.Lemma | val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)] | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l) | val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = | false | null | true | FStar.Classical.ghost_lemma (mem_filter f l) | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"lemma"
] | [
"Prims.bool",
"Prims.list",
"FStar.Classical.ghost_lemma",
"FStar.List.Tot.Base.memP",
"FStar.List.Tot.Base.filter",
"Prims.unit",
"Prims.b2t",
"FStar.List.Tot.Base.mem_filter"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x)) | false | false | FStar.List.Tot.Base.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 mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)] | [] | FStar.List.Tot.Base.mem_filter_forall | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> Prims.bool) -> l: Prims.list a
-> FStar.Pervasives.Lemma
(ensures forall (x: a). FStar.List.Tot.Base.memP x (FStar.List.Tot.Base.filter f l) ==> f x)
[SMTPat (FStar.List.Tot.Base.filter f l)] | {
"end_col": 72,
"end_line": 296,
"start_col": 28,
"start_line": 296
} |
Prims.Tot | val compare_of_bool : #a:eqtype -> (a -> a -> Tot bool) -> a -> a -> Tot int | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let compare_of_bool #a rel x y =
if x `rel` y then -1
else if x = y then 0
else 1 | val compare_of_bool : #a:eqtype -> (a -> a -> Tot bool) -> a -> a -> Tot int
let compare_of_bool #a rel x y = | false | null | false | if x `rel` y then - 1 else if x = y then 0 else 1 | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.eqtype",
"Prims.bool",
"Prims.op_Minus",
"Prims.op_Equality",
"Prims.int"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl
(** [no_repeats_p l] valid if, and only if, no element of [l]
appears in [l] more than once. *)
val no_repeats_p : #a:Type -> list a -> Tot prop
let rec no_repeats_p #a la =
match la with
| [] -> True
| h :: tl -> ~(memP h tl) /\ no_repeats_p tl
(** List of tuples **)
(** [assoc x l] returns [Some y] where [(x, y)] is the first element
of [l] whose first element is [x], or [None] only if no such element
exists. Requires, at type-checking time, the type of [x] to have
decidable equality. Named as in: OCaml. *)
val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b)
let rec assoc #a #b x = function
| [] -> None
| (x', y)::tl -> if x=x' then Some y else assoc x tl
(** [split] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
OCaml *)
val split: list ('a * 'b) -> Tot (list 'a * list 'b)
let rec split l = match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = split tl in
(hd1::tl1,hd2::tl2)
(** [unzip] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
Haskell *)
let unzip l = split l
(** [unzip3] takes a list of triples [(x1, y1, z1), ..., (xn, yn, zn)]
and returns the triple of lists ([x1, ..., xn], [y1, ..., yn], [z1,
..., zn]). Named as in: Haskell *)
val unzip3: list ('a * 'b * 'c) -> Tot (list 'a * list 'b * list 'c)
let rec unzip3 l = match l with
| [] -> ([],[],[])
| (hd1,hd2,hd3)::tl ->
let (tl1,tl2,tl3) = unzip3 tl in
(hd1::tl1,hd2::tl2,hd3::tl3)
(** Splitting a list at some index **)
(** [splitAt] takes a natural number n and a list and returns a pair
of the maximal prefix of l of size smaller than n and the rest of
the list *)
let rec splitAt (#a:Type) (n:nat) (l:list a) : Tot (list a * list a) =
if n = 0 then [], l
else
match l with
| [] -> [], l
| x :: xs -> let l1, l2 = splitAt (n-1) xs in x :: l1, l2
let rec lemma_splitAt_snd_length (#a:Type) (n:nat) (l:list a) :
Lemma
(requires (n <= length l))
(ensures (length (snd (splitAt n l)) = length l - n)) =
match n, l with
| 0, _ -> ()
| _, [] -> ()
| _, _ :: l' -> lemma_splitAt_snd_length (n - 1) l'
(** [unsnoc] is an inverse of [snoc]. It splits a list into
all-elements-except-last and last element. *)
val unsnoc: #a:Type -> l:list a{length l > 0} -> Tot (list a * a)
let unsnoc #a l =
let l1, l2 = splitAt (length l - 1) l in
lemma_splitAt_snd_length (length l - 1) l;
l1, hd l2
(** [split3] splits a list into 3 parts. This allows easy access to
the part of the list before and after the element, as well as the
element itself. *)
val split3: #a:Type -> l:list a -> i:nat{i < length l} -> Tot (list a * a * list a)
let split3 #a l i =
let a, rest = splitAt i l in
lemma_splitAt_snd_length i l;
let b :: c = rest in
a, b, c
(** Sorting (implemented as quicksort) **)
(** [partition] splits a list [l] into two lists, the sum of whose
lengths is the length of [l]. *)
val partition_length: f:('a -> Tot bool)
-> l:list 'a
-> Lemma (requires True)
(ensures (length (fst (partition f l))
+ length (snd (partition f l)) = length l))
let rec partition_length f l = match l with
| [] -> ()
| hd::tl -> partition_length f tl
(** [bool_of_compare] turns a comparison function into a strict
order. More precisely, [bool_of_compare compare x y] returns true
if, and only if, [compare x y] is negative, meaning [x] precedes
[y] in the ordering defined by compare.
This is used in sorting, and is defined to be consistent with
OCaml and F#, where sorting is performed in ascending order.
*)
val bool_of_compare : #a:Type -> (a -> a -> Tot int) -> a -> a -> Tot bool
let bool_of_compare #a f x y = f x y < 0
(** [compare_of_bool] turns a strict order into a comparison
function. More precisely, [compare_of_bool rel x y] returns a positive
number if, and only if, x `rel` y holds. Inspired from OCaml, where
polymorphic comparison using both the [compare] function and the (>)
infix operator are such that [compare x y] is positive if, and only
if, x > y. Requires, at type-checking time, [rel] to be a pure total
function. *)
val compare_of_bool : #a:eqtype -> (a -> a -> Tot bool) -> a -> a -> Tot int | false | false | FStar.List.Tot.Base.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 compare_of_bool : #a:eqtype -> (a -> a -> Tot bool) -> a -> a -> Tot int | [] | FStar.List.Tot.Base.compare_of_bool | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | rel: (_: a -> _: a -> Prims.bool) -> x: a -> y: a -> Prims.int | {
"end_col": 10,
"end_line": 512,
"start_col": 4,
"start_line": 510
} |
Prims.Tot | val rev: list 'a -> Tot (list 'a) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rev l = rev_acc l [] | val rev: list 'a -> Tot (list 'a)
let rev l = | false | null | false | rev_acc l [] | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"FStar.List.Tot.Base.rev_acc",
"Prims.Nil"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *) | false | false | FStar.List.Tot.Base.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 rev: list 'a -> Tot (list 'a) | [] | FStar.List.Tot.Base.rev | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list 'a -> Prims.list 'a | {
"end_col": 24,
"end_line": 115,
"start_col": 12,
"start_line": 115
} |
Prims.Tot | val length: list 'a -> Tot nat | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec length = function
| [] -> 0
| _::tl -> 1 + length tl | val length: list 'a -> Tot nat
let rec length = | false | null | false | function
| [] -> 0
| _ :: tl -> 1 + length tl | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.op_Addition",
"FStar.List.Tot.Base.length",
"Prims.nat"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *) | false | false | FStar.List.Tot.Base.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 length: list 'a -> Tot nat | [
"recursion"
] | FStar.List.Tot.Base.length | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: Prims.list 'a -> Prims.nat | {
"end_col": 26,
"end_line": 76,
"start_col": 17,
"start_line": 74
} |
Prims.Tot | val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1) | val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i: nat{i < length l}) : Tot a = | false | null | false | if i = 0 then hd l else index (tl l) (i - 1) | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.List.Tot.Base.length",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.hd",
"Prims.bool",
"FStar.List.Tot.Base.index",
"FStar.List.Tot.Base.tl",
"Prims.op_Subtraction"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a | false | false | FStar.List.Tot.Base.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 index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a | [
"recursion"
] | FStar.List.Tot.Base.index | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list a -> i: Prims.nat{i < FStar.List.Tot.Base.length l} -> a | {
"end_col": 24,
"end_line": 94,
"start_col": 2,
"start_line": 91
} |
Prims.Tot | val tail: l:list 'a {Cons? l} -> Tot (list 'a) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tail = function
| _::tl -> tl | val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = | false | null | false | function | _ :: tl -> tl | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.b2t",
"Prims.uu___is_Cons"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*) | false | false | FStar.List.Tot.Base.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 tail: l:list 'a {Cons? l} -> Tot (list 'a) | [] | FStar.List.Tot.Base.tail | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list 'a {Cons? l} -> Prims.list 'a | {
"end_col": 15,
"end_line": 47,
"start_col": 11,
"start_line": 46
} |
Prims.Tot | val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl) | val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = | false | null | false | match l with
| [] -> []
| hd :: tl -> append (f hd) (collect f tl) | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.Nil",
"FStar.List.Tot.Base.append",
"FStar.List.Tot.Base.collect"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *) | false | false | FStar.List.Tot.Base.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 collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b) | [
"recursion"
] | FStar.List.Tot.Base.collect | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: 'a -> Prims.list 'b) -> l: Prims.list 'a -> Prims.list 'b | {
"end_col": 44,
"end_line": 326,
"start_col": 22,
"start_line": 324
} |
Prims.Tot | val flatten: list (list 'a) -> Tot (list 'a) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl) | val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = | false | null | false | match l with
| [] -> []
| hd :: tl -> append hd (flatten tl) | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.Nil",
"FStar.List.Tot.Base.append",
"FStar.List.Tot.Base.flatten"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *) | false | false | FStar.List.Tot.Base.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 flatten: list (list 'a) -> Tot (list 'a) | [
"recursion"
] | FStar.List.Tot.Base.flatten | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list (Prims.list 'a) -> Prims.list 'a | {
"end_col": 38,
"end_line": 145,
"start_col": 20,
"start_line": 143
} |
Prims.Tot | val last: l:list 'a {Cons? l} -> Tot 'a | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec last = function
| [hd] -> hd
| _::tl -> last tl | val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = | false | null | false | function
| [hd] -> hd
| _ :: tl -> last tl | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.b2t",
"Prims.uu___is_Cons",
"FStar.List.Tot.Base.last"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*) | false | false | FStar.List.Tot.Base.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 last: l:list 'a {Cons? l} -> Tot 'a | [
"recursion"
] | FStar.List.Tot.Base.last | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list 'a {Cons? l} -> 'a | {
"end_col": 20,
"end_line": 61,
"start_col": 15,
"start_line": 59
} |
Prims.Tot | val hd: l:list 'a{Cons? l} -> Tot 'a | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hd = function
| hd::_ -> hd | val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = | false | null | false | function | hd :: _ -> hd | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.b2t",
"Prims.uu___is_Cons"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *) | false | false | FStar.List.Tot.Base.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 hd: l:list 'a{Cons? l} -> Tot 'a | [] | FStar.List.Tot.Base.hd | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list 'a {Cons? l} -> 'a | {
"end_col": 15,
"end_line": 40,
"start_col": 9,
"start_line": 39
} |
Prims.Tot | val count: #a:eqtype -> a -> list a -> Tot nat | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl | val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = | false | null | false | function
| [] -> 0
| hd :: tl -> if x = hd then 1 + count x tl else count x tl | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.eqtype",
"Prims.list",
"Prims.op_Equality",
"Prims.op_Addition",
"FStar.List.Tot.Base.count",
"Prims.bool",
"Prims.nat"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *) | false | false | FStar.List.Tot.Base.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 count: #a:eqtype -> a -> list a -> Tot nat | [
"recursion"
] | FStar.List.Tot.Base.count | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: a -> _: Prims.list a -> Prims.nat | {
"end_col": 57,
"end_line": 102,
"start_col": 21,
"start_line": 100
} |
Prims.Tot | val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x})) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl | val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = | false | null | false | match l with
| [] -> None #(x: a{f x})
| hd :: tl -> if f hd then Some #(x: a{f x}) hd else find f tl | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.bool",
"Prims.list",
"FStar.Pervasives.Native.None",
"Prims.b2t",
"FStar.Pervasives.Native.Some",
"FStar.List.Tot.Base.find",
"FStar.Pervasives.Native.option"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a | false | false | FStar.List.Tot.Base.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 find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x})) | [
"recursion"
] | FStar.List.Tot.Base.find | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> Prims.bool) -> l: Prims.list a -> FStar.Pervasives.Native.option (x: a{f x}) | {
"end_col": 61,
"end_line": 268,
"start_col": 22,
"start_line": 266
} |
Prims.Tot | val nth: list 'a -> nat -> Tot (option 'a) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1) | val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = | false | null | false | match l with
| [] -> None
| hd :: tl -> if n = 0 then Some hd else nth tl (n - 1) | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.nat",
"FStar.Pervasives.Native.None",
"Prims.op_Equality",
"Prims.int",
"FStar.Pervasives.Native.Some",
"Prims.bool",
"FStar.List.Tot.Base.nth",
"Prims.op_Subtraction",
"FStar.Pervasives.Native.option"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *) | false | false | FStar.List.Tot.Base.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 nth: list 'a -> nat -> Tot (option 'a) | [
"recursion"
] | FStar.List.Tot.Base.nth | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list 'a -> n: Prims.nat -> FStar.Pervasives.Native.option 'a | {
"end_col": 55,
"end_line": 84,
"start_col": 18,
"start_line": 82
} |
Prims.GTot | val fold_right_gtot (#a #b: Type) (l: list a) (f: (a -> b -> GTot b)) (x: b) : GTot b | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x) | val fold_right_gtot (#a #b: Type) (l: list a) (f: (a -> b -> GTot b)) (x: b) : GTot b
let rec fold_right_gtot (#a #b: Type) (l: list a) (f: (a -> b -> GTot b)) (x: b) : GTot b = | false | null | false | match l with
| [] -> x
| hd :: tl -> f hd (fold_right_gtot tl f x) | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"sometrivial"
] | [
"Prims.list",
"FStar.List.Tot.Base.fold_right_gtot"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b) | false | false | FStar.List.Tot.Base.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 fold_right_gtot (#a #b: Type) (l: list a) (f: (a -> b -> GTot b)) (x: b) : GTot b | [
"recursion"
] | FStar.List.Tot.Base.fold_right_gtot | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list a -> f: (_: a -> _: b -> Prims.GTot b) -> x: b -> Prims.GTot b | {
"end_col": 45,
"end_line": 205,
"start_col": 4,
"start_line": 203
} |
Prims.Tot | val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1)) | val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = | false | null | false | match l with
| [] -> []
| hd :: tl -> (f i hd) :: (mapi_init f tl (i + 1)) | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.int",
"Prims.list",
"Prims.Nil",
"Prims.Cons",
"FStar.List.Tot.Base.mapi_init",
"Prims.op_Addition"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *) | false | false | FStar.List.Tot.Base.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 mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b) | [
"recursion"
] | FStar.List.Tot.Base.mapi_init | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: Prims.int -> _: 'a -> 'b) -> l: Prims.list 'a -> i: Prims.int -> Prims.list 'b | {
"end_col": 48,
"end_line": 162,
"start_col": 26,
"start_line": 160
} |
Prims.Tot | val append: list 'a -> list 'a -> Tot (list 'a) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y | val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = | false | null | false | match x with
| [] -> y
| a :: tl -> a :: append tl y | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.Cons",
"FStar.List.Tot.Base.append"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *) | false | false | FStar.List.Tot.Base.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 append: list 'a -> list 'a -> Tot (list 'a) | [
"recursion"
] | FStar.List.Tot.Base.append | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: Prims.list 'a -> y: Prims.list 'a -> Prims.list 'a | {
"end_col": 27,
"end_line": 121,
"start_col": 21,
"start_line": 119
} |
Prims.Tot | val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl | val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = | false | null | false | match x with
| [] -> []
| a :: tl -> f a :: map f tl | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.Nil",
"Prims.Cons",
"FStar.List.Tot.Base.map"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *) | false | false | FStar.List.Tot.Base.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 map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b) | [
"recursion"
] | FStar.List.Tot.Base.map | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: 'a -> 'b) -> x: Prims.list 'a -> Prims.list 'b | {
"end_col": 26,
"end_line": 153,
"start_col": 18,
"start_line": 151
} |
Prims.Tot | val init: l:list 'a {Cons? l} -> Tot (list 'a) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl) | val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = | false | null | false | function
| [_] -> []
| hd :: tl -> hd :: (init tl) | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.b2t",
"Prims.uu___is_Cons",
"Prims.Nil",
"Prims.Cons",
"FStar.List.Tot.Base.init"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*) | false | false | FStar.List.Tot.Base.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 init: l:list 'a {Cons? l} -> Tot (list 'a) | [
"recursion"
] | FStar.List.Tot.Base.init | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list 'a {Cons? l} -> Prims.list 'a | {
"end_col": 27,
"end_line": 69,
"start_col": 15,
"start_line": 67
} |
Prims.Tot | val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl | val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = | false | null | false | function
| [] -> []
| a :: tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.Nil",
"FStar.List.Tot.Base.append",
"FStar.List.Tot.Base.concatMap"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *) | false | false | FStar.List.Tot.Base.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 concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b) | [
"recursion"
] | FStar.List.Tot.Base.concatMap | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: 'a -> Prims.list 'b) -> _: Prims.list 'a -> Prims.list 'b | {
"end_col": 17,
"end_line": 181,
"start_col": 22,
"start_line": 176
} |
Prims.Tot | val split3: #a:Type -> l:list a -> i:nat{i < length l} -> Tot (list a * a * list a) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let split3 #a l i =
let a, rest = splitAt i l in
lemma_splitAt_snd_length i l;
let b :: c = rest in
a, b, c | val split3: #a:Type -> l:list a -> i:nat{i < length l} -> Tot (list a * a * list a)
let split3 #a l i = | false | null | false | let a, rest = splitAt i l in
lemma_splitAt_snd_length i l;
let b :: c = rest in
a, b, c | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.List.Tot.Base.length",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Pervasives.Native.tuple3",
"Prims.unit",
"FStar.List.Tot.Base.lemma_splitAt_snd_length",
"FStar.Pervasives.Native.tuple2",
"FStar.List.Tot.Base.splitAt"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl
(** [no_repeats_p l] valid if, and only if, no element of [l]
appears in [l] more than once. *)
val no_repeats_p : #a:Type -> list a -> Tot prop
let rec no_repeats_p #a la =
match la with
| [] -> True
| h :: tl -> ~(memP h tl) /\ no_repeats_p tl
(** List of tuples **)
(** [assoc x l] returns [Some y] where [(x, y)] is the first element
of [l] whose first element is [x], or [None] only if no such element
exists. Requires, at type-checking time, the type of [x] to have
decidable equality. Named as in: OCaml. *)
val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b)
let rec assoc #a #b x = function
| [] -> None
| (x', y)::tl -> if x=x' then Some y else assoc x tl
(** [split] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
OCaml *)
val split: list ('a * 'b) -> Tot (list 'a * list 'b)
let rec split l = match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = split tl in
(hd1::tl1,hd2::tl2)
(** [unzip] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
Haskell *)
let unzip l = split l
(** [unzip3] takes a list of triples [(x1, y1, z1), ..., (xn, yn, zn)]
and returns the triple of lists ([x1, ..., xn], [y1, ..., yn], [z1,
..., zn]). Named as in: Haskell *)
val unzip3: list ('a * 'b * 'c) -> Tot (list 'a * list 'b * list 'c)
let rec unzip3 l = match l with
| [] -> ([],[],[])
| (hd1,hd2,hd3)::tl ->
let (tl1,tl2,tl3) = unzip3 tl in
(hd1::tl1,hd2::tl2,hd3::tl3)
(** Splitting a list at some index **)
(** [splitAt] takes a natural number n and a list and returns a pair
of the maximal prefix of l of size smaller than n and the rest of
the list *)
let rec splitAt (#a:Type) (n:nat) (l:list a) : Tot (list a * list a) =
if n = 0 then [], l
else
match l with
| [] -> [], l
| x :: xs -> let l1, l2 = splitAt (n-1) xs in x :: l1, l2
let rec lemma_splitAt_snd_length (#a:Type) (n:nat) (l:list a) :
Lemma
(requires (n <= length l))
(ensures (length (snd (splitAt n l)) = length l - n)) =
match n, l with
| 0, _ -> ()
| _, [] -> ()
| _, _ :: l' -> lemma_splitAt_snd_length (n - 1) l'
(** [unsnoc] is an inverse of [snoc]. It splits a list into
all-elements-except-last and last element. *)
val unsnoc: #a:Type -> l:list a{length l > 0} -> Tot (list a * a)
let unsnoc #a l =
let l1, l2 = splitAt (length l - 1) l in
lemma_splitAt_snd_length (length l - 1) l;
l1, hd l2
(** [split3] splits a list into 3 parts. This allows easy access to
the part of the list before and after the element, as well as the
element itself. *) | false | false | FStar.List.Tot.Base.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 split3: #a:Type -> l:list a -> i:nat{i < length l} -> Tot (list a * a * list a) | [] | FStar.List.Tot.Base.split3 | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list a -> i: Prims.nat{i < FStar.List.Tot.Base.length l}
-> (Prims.list a * a) * Prims.list a | {
"end_col": 9,
"end_line": 475,
"start_col": 19,
"start_line": 471
} |
Prims.Tot | val mem: #a:eqtype -> a -> list a -> Tot bool | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl | val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = | false | null | false | function
| [] -> false
| hd :: tl -> if hd = x then true else mem x tl | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.eqtype",
"Prims.list",
"Prims.op_Equality",
"Prims.bool",
"FStar.List.Tot.Base.mem"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *) | false | false | FStar.List.Tot.Base.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 mem: #a:eqtype -> a -> list a -> Tot bool | [
"recursion"
] | FStar.List.Tot.Base.mem | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: a -> _: Prims.list a -> Prims.bool | {
"end_col": 47,
"end_line": 242,
"start_col": 19,
"start_line": 240
} |
Prims.Tot | val noRepeats : #a:eqtype -> list a -> Tot bool | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl | val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la = | false | null | false | match la with
| [] -> true
| h :: tl -> not (mem h tl) && noRepeats tl | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.eqtype",
"Prims.list",
"Prims.op_AmpAmp",
"Prims.op_Negation",
"FStar.List.Tot.Base.mem",
"FStar.List.Tot.Base.noRepeats",
"Prims.bool"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool | false | false | FStar.List.Tot.Base.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 noRepeats : #a:eqtype -> list a -> Tot bool | [
"recursion"
] | FStar.List.Tot.Base.noRepeats | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | la: Prims.list a -> Prims.bool | {
"end_col": 44,
"end_line": 391,
"start_col": 2,
"start_line": 389
} |
Prims.Tot | val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl | val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = | false | null | false | match l with
| [] -> x
| hd :: tl -> fold_left f (f x hd) tl | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total",
""
] | [
"Prims.list",
"FStar.List.Tot.Base.fold_left"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *) | false | false | FStar.List.Tot.Base.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 fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l) | [
"recursion"
] | FStar.List.Tot.Base.fold_left | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: 'a -> _: 'b -> 'a) -> x: 'a -> l: Prims.list 'b -> Prims.Tot 'a | {
"end_col": 37,
"end_line": 189,
"start_col": 26,
"start_line": 187
} |
Prims.Tot | val for_all: ('a -> Tot bool) -> list 'a -> Tot bool | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false | val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = | false | null | false | match l with
| [] -> true
| hd :: tl -> if f hd then for_all f tl else false | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.bool",
"Prims.list",
"FStar.List.Tot.Base.for_all"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *) | false | false | FStar.List.Tot.Base.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 for_all: ('a -> Tot bool) -> list 'a -> Tot bool | [
"recursion"
] | FStar.List.Tot.Base.for_all | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: 'a -> Prims.bool) -> l: Prims.list 'a -> Prims.bool | {
"end_col": 52,
"end_line": 305,
"start_col": 22,
"start_line": 303
} |
Prims.Tot | val splitAt (#a: Type) (n: nat) (l: list a) : Tot (list a * list a) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec splitAt (#a:Type) (n:nat) (l:list a) : Tot (list a * list a) =
if n = 0 then [], l
else
match l with
| [] -> [], l
| x :: xs -> let l1, l2 = splitAt (n-1) xs in x :: l1, l2 | val splitAt (#a: Type) (n: nat) (l: list a) : Tot (list a * list a)
let rec splitAt (#a: Type) (n: nat) (l: list a) : Tot (list a * list a) = | false | null | false | if n = 0
then [], l
else
match l with
| [] -> [], l
| x :: xs ->
let l1, l2 = splitAt (n - 1) xs in
x :: l1, l2 | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.list",
"Prims.op_Equality",
"Prims.int",
"FStar.Pervasives.Native.Mktuple2",
"Prims.Nil",
"Prims.bool",
"Prims.Cons",
"FStar.Pervasives.Native.tuple2",
"FStar.List.Tot.Base.splitAt",
"Prims.op_Subtraction"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl
(** [no_repeats_p l] valid if, and only if, no element of [l]
appears in [l] more than once. *)
val no_repeats_p : #a:Type -> list a -> Tot prop
let rec no_repeats_p #a la =
match la with
| [] -> True
| h :: tl -> ~(memP h tl) /\ no_repeats_p tl
(** List of tuples **)
(** [assoc x l] returns [Some y] where [(x, y)] is the first element
of [l] whose first element is [x], or [None] only if no such element
exists. Requires, at type-checking time, the type of [x] to have
decidable equality. Named as in: OCaml. *)
val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b)
let rec assoc #a #b x = function
| [] -> None
| (x', y)::tl -> if x=x' then Some y else assoc x tl
(** [split] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
OCaml *)
val split: list ('a * 'b) -> Tot (list 'a * list 'b)
let rec split l = match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = split tl in
(hd1::tl1,hd2::tl2)
(** [unzip] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
Haskell *)
let unzip l = split l
(** [unzip3] takes a list of triples [(x1, y1, z1), ..., (xn, yn, zn)]
and returns the triple of lists ([x1, ..., xn], [y1, ..., yn], [z1,
..., zn]). Named as in: Haskell *)
val unzip3: list ('a * 'b * 'c) -> Tot (list 'a * list 'b * list 'c)
let rec unzip3 l = match l with
| [] -> ([],[],[])
| (hd1,hd2,hd3)::tl ->
let (tl1,tl2,tl3) = unzip3 tl in
(hd1::tl1,hd2::tl2,hd3::tl3)
(** Splitting a list at some index **)
(** [splitAt] takes a natural number n and a list and returns a pair
of the maximal prefix of l of size smaller than n and the rest of
the list *) | false | false | FStar.List.Tot.Base.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 splitAt (#a: Type) (n: nat) (l: list a) : Tot (list a * list a) | [
"recursion"
] | FStar.List.Tot.Base.splitAt | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | n: Prims.nat -> l: Prims.list a -> Prims.list a * Prims.list a | {
"end_col": 61,
"end_line": 448,
"start_col": 2,
"start_line": 444
} |
Prims.Tot | val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec assoc #a #b x = function
| [] -> None
| (x', y)::tl -> if x=x' then Some y else assoc x tl | val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b)
let rec assoc #a #b x = | false | null | false | function
| [] -> None
| (x', y) :: tl -> if x = x' then Some y else assoc x tl | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.eqtype",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.None",
"Prims.op_Equality",
"FStar.Pervasives.Native.Some",
"Prims.bool",
"FStar.List.Tot.Base.assoc",
"FStar.Pervasives.Native.option"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl
(** [no_repeats_p l] valid if, and only if, no element of [l]
appears in [l] more than once. *)
val no_repeats_p : #a:Type -> list a -> Tot prop
let rec no_repeats_p #a la =
match la with
| [] -> True
| h :: tl -> ~(memP h tl) /\ no_repeats_p tl
(** List of tuples **)
(** [assoc x l] returns [Some y] where [(x, y)] is the first element
of [l] whose first element is [x], or [None] only if no such element
exists. Requires, at type-checking time, the type of [x] to have
decidable equality. Named as in: OCaml. *) | false | false | FStar.List.Tot.Base.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 assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b) | [
"recursion"
] | FStar.List.Tot.Base.assoc | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: a -> _: Prims.list (a * b) -> FStar.Pervasives.Native.option b | {
"end_col": 54,
"end_line": 411,
"start_col": 24,
"start_line": 409
} |
Prims.Tot | val unsnoc: #a:Type -> l:list a{length l > 0} -> Tot (list a * a) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let unsnoc #a l =
let l1, l2 = splitAt (length l - 1) l in
lemma_splitAt_snd_length (length l - 1) l;
l1, hd l2 | val unsnoc: #a:Type -> l:list a{length l > 0} -> Tot (list a * a)
let unsnoc #a l = | false | null | false | let l1, l2 = splitAt (length l - 1) l in
lemma_splitAt_snd_length (length l - 1) l;
l1, hd l2 | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.b2t",
"Prims.op_GreaterThan",
"FStar.List.Tot.Base.length",
"FStar.Pervasives.Native.Mktuple2",
"FStar.List.Tot.Base.hd",
"Prims.unit",
"FStar.List.Tot.Base.lemma_splitAt_snd_length",
"Prims.op_Subtraction",
"FStar.Pervasives.Native.tuple2",
"FStar.List.Tot.Base.splitAt"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl
(** [no_repeats_p l] valid if, and only if, no element of [l]
appears in [l] more than once. *)
val no_repeats_p : #a:Type -> list a -> Tot prop
let rec no_repeats_p #a la =
match la with
| [] -> True
| h :: tl -> ~(memP h tl) /\ no_repeats_p tl
(** List of tuples **)
(** [assoc x l] returns [Some y] where [(x, y)] is the first element
of [l] whose first element is [x], or [None] only if no such element
exists. Requires, at type-checking time, the type of [x] to have
decidable equality. Named as in: OCaml. *)
val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b)
let rec assoc #a #b x = function
| [] -> None
| (x', y)::tl -> if x=x' then Some y else assoc x tl
(** [split] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
OCaml *)
val split: list ('a * 'b) -> Tot (list 'a * list 'b)
let rec split l = match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = split tl in
(hd1::tl1,hd2::tl2)
(** [unzip] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
Haskell *)
let unzip l = split l
(** [unzip3] takes a list of triples [(x1, y1, z1), ..., (xn, yn, zn)]
and returns the triple of lists ([x1, ..., xn], [y1, ..., yn], [z1,
..., zn]). Named as in: Haskell *)
val unzip3: list ('a * 'b * 'c) -> Tot (list 'a * list 'b * list 'c)
let rec unzip3 l = match l with
| [] -> ([],[],[])
| (hd1,hd2,hd3)::tl ->
let (tl1,tl2,tl3) = unzip3 tl in
(hd1::tl1,hd2::tl2,hd3::tl3)
(** Splitting a list at some index **)
(** [splitAt] takes a natural number n and a list and returns a pair
of the maximal prefix of l of size smaller than n and the rest of
the list *)
let rec splitAt (#a:Type) (n:nat) (l:list a) : Tot (list a * list a) =
if n = 0 then [], l
else
match l with
| [] -> [], l
| x :: xs -> let l1, l2 = splitAt (n-1) xs in x :: l1, l2
let rec lemma_splitAt_snd_length (#a:Type) (n:nat) (l:list a) :
Lemma
(requires (n <= length l))
(ensures (length (snd (splitAt n l)) = length l - n)) =
match n, l with
| 0, _ -> ()
| _, [] -> ()
| _, _ :: l' -> lemma_splitAt_snd_length (n - 1) l'
(** [unsnoc] is an inverse of [snoc]. It splits a list into
all-elements-except-last and last element. *) | false | false | FStar.List.Tot.Base.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 unsnoc: #a:Type -> l:list a{length l > 0} -> Tot (list a * a) | [] | FStar.List.Tot.Base.unsnoc | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list a {FStar.List.Tot.Base.length l > 0} -> Prims.list a * a | {
"end_col": 11,
"end_line": 465,
"start_col": 17,
"start_line": 462
} |
Prims.Tot | val unzip3: list ('a * 'b * 'c) -> Tot (list 'a * list 'b * list 'c) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec unzip3 l = match l with
| [] -> ([],[],[])
| (hd1,hd2,hd3)::tl ->
let (tl1,tl2,tl3) = unzip3 tl in
(hd1::tl1,hd2::tl2,hd3::tl3) | val unzip3: list ('a * 'b * 'c) -> Tot (list 'a * list 'b * list 'c)
let rec unzip3 l = | false | null | false | match l with
| [] -> ([], [], [])
| (hd1, hd2, hd3) :: tl ->
let tl1, tl2, tl3 = unzip3 tl in
(hd1 :: tl1, hd2 :: tl2, hd3 :: tl3) | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"Prims.Nil",
"Prims.Cons",
"FStar.List.Tot.Base.unzip3"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl
(** [no_repeats_p l] valid if, and only if, no element of [l]
appears in [l] more than once. *)
val no_repeats_p : #a:Type -> list a -> Tot prop
let rec no_repeats_p #a la =
match la with
| [] -> True
| h :: tl -> ~(memP h tl) /\ no_repeats_p tl
(** List of tuples **)
(** [assoc x l] returns [Some y] where [(x, y)] is the first element
of [l] whose first element is [x], or [None] only if no such element
exists. Requires, at type-checking time, the type of [x] to have
decidable equality. Named as in: OCaml. *)
val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b)
let rec assoc #a #b x = function
| [] -> None
| (x', y)::tl -> if x=x' then Some y else assoc x tl
(** [split] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
OCaml *)
val split: list ('a * 'b) -> Tot (list 'a * list 'b)
let rec split l = match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = split tl in
(hd1::tl1,hd2::tl2)
(** [unzip] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
Haskell *)
let unzip l = split l
(** [unzip3] takes a list of triples [(x1, y1, z1), ..., (xn, yn, zn)]
and returns the triple of lists ([x1, ..., xn], [y1, ..., yn], [z1,
..., zn]). Named as in: Haskell *) | false | false | FStar.List.Tot.Base.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 unzip3: list ('a * 'b * 'c) -> Tot (list 'a * list 'b * list 'c) | [
"recursion"
] | FStar.List.Tot.Base.unzip3 | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list (('a * 'b) * 'c) -> (Prims.list 'a * Prims.list 'b) * Prims.list 'c | {
"end_col": 35,
"end_line": 436,
"start_col": 19,
"start_line": 432
} |
Prims.Pure | val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2 | val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 = | false | null | false | match (l1, l2) with
| [], [] -> accu
| a1 :: l1, a2 :: l2 -> fold_left2 f (f accu a1 a2) l1 l2 | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
""
] | [
"Prims.list",
"FStar.Pervasives.Native.Mktuple2",
"FStar.List.Tot.Base.fold_left2"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1) | false | false | FStar.List.Tot.Base.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 fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1) | [
"recursion"
] | FStar.List.Tot.Base.fold_left2 | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: 'a -> _: 'b -> _: 'c -> 'a) -> accu: 'a -> l1: Prims.list 'b -> l2: Prims.list 'c
-> Prims.Pure 'a | {
"end_col": 57,
"end_line": 221,
"start_col": 2,
"start_line": 219
} |
Prims.Tot | val sortWith: ('a -> 'a -> Tot int) -> l:list 'a -> Tot (list 'a) (decreases (length l)) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec sortWith f = function
| [] -> []
| pivot::tl ->
let hi, lo = partition (bool_of_compare f pivot) tl in
partition_length (bool_of_compare f pivot) tl;
append (sortWith f lo) (pivot::sortWith f hi) | val sortWith: ('a -> 'a -> Tot int) -> l:list 'a -> Tot (list 'a) (decreases (length l))
let rec sortWith f = | false | null | false | function
| [] -> []
| pivot :: tl ->
let hi, lo = partition (bool_of_compare f pivot) tl in
partition_length (bool_of_compare f pivot) tl;
append (sortWith f lo) (pivot :: sortWith f hi) | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total",
""
] | [
"Prims.int",
"Prims.list",
"Prims.Nil",
"FStar.List.Tot.Base.append",
"FStar.List.Tot.Base.sortWith",
"Prims.Cons",
"Prims.unit",
"FStar.List.Tot.Base.partition_length",
"FStar.List.Tot.Base.bool_of_compare",
"FStar.Pervasives.Native.tuple2",
"FStar.List.Tot.Base.partition"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl
(** [no_repeats_p l] valid if, and only if, no element of [l]
appears in [l] more than once. *)
val no_repeats_p : #a:Type -> list a -> Tot prop
let rec no_repeats_p #a la =
match la with
| [] -> True
| h :: tl -> ~(memP h tl) /\ no_repeats_p tl
(** List of tuples **)
(** [assoc x l] returns [Some y] where [(x, y)] is the first element
of [l] whose first element is [x], or [None] only if no such element
exists. Requires, at type-checking time, the type of [x] to have
decidable equality. Named as in: OCaml. *)
val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b)
let rec assoc #a #b x = function
| [] -> None
| (x', y)::tl -> if x=x' then Some y else assoc x tl
(** [split] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
OCaml *)
val split: list ('a * 'b) -> Tot (list 'a * list 'b)
let rec split l = match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = split tl in
(hd1::tl1,hd2::tl2)
(** [unzip] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
Haskell *)
let unzip l = split l
(** [unzip3] takes a list of triples [(x1, y1, z1), ..., (xn, yn, zn)]
and returns the triple of lists ([x1, ..., xn], [y1, ..., yn], [z1,
..., zn]). Named as in: Haskell *)
val unzip3: list ('a * 'b * 'c) -> Tot (list 'a * list 'b * list 'c)
let rec unzip3 l = match l with
| [] -> ([],[],[])
| (hd1,hd2,hd3)::tl ->
let (tl1,tl2,tl3) = unzip3 tl in
(hd1::tl1,hd2::tl2,hd3::tl3)
(** Splitting a list at some index **)
(** [splitAt] takes a natural number n and a list and returns a pair
of the maximal prefix of l of size smaller than n and the rest of
the list *)
let rec splitAt (#a:Type) (n:nat) (l:list a) : Tot (list a * list a) =
if n = 0 then [], l
else
match l with
| [] -> [], l
| x :: xs -> let l1, l2 = splitAt (n-1) xs in x :: l1, l2
let rec lemma_splitAt_snd_length (#a:Type) (n:nat) (l:list a) :
Lemma
(requires (n <= length l))
(ensures (length (snd (splitAt n l)) = length l - n)) =
match n, l with
| 0, _ -> ()
| _, [] -> ()
| _, _ :: l' -> lemma_splitAt_snd_length (n - 1) l'
(** [unsnoc] is an inverse of [snoc]. It splits a list into
all-elements-except-last and last element. *)
val unsnoc: #a:Type -> l:list a{length l > 0} -> Tot (list a * a)
let unsnoc #a l =
let l1, l2 = splitAt (length l - 1) l in
lemma_splitAt_snd_length (length l - 1) l;
l1, hd l2
(** [split3] splits a list into 3 parts. This allows easy access to
the part of the list before and after the element, as well as the
element itself. *)
val split3: #a:Type -> l:list a -> i:nat{i < length l} -> Tot (list a * a * list a)
let split3 #a l i =
let a, rest = splitAt i l in
lemma_splitAt_snd_length i l;
let b :: c = rest in
a, b, c
(** Sorting (implemented as quicksort) **)
(** [partition] splits a list [l] into two lists, the sum of whose
lengths is the length of [l]. *)
val partition_length: f:('a -> Tot bool)
-> l:list 'a
-> Lemma (requires True)
(ensures (length (fst (partition f l))
+ length (snd (partition f l)) = length l))
let rec partition_length f l = match l with
| [] -> ()
| hd::tl -> partition_length f tl
(** [bool_of_compare] turns a comparison function into a strict
order. More precisely, [bool_of_compare compare x y] returns true
if, and only if, [compare x y] is negative, meaning [x] precedes
[y] in the ordering defined by compare.
This is used in sorting, and is defined to be consistent with
OCaml and F#, where sorting is performed in ascending order.
*)
val bool_of_compare : #a:Type -> (a -> a -> Tot int) -> a -> a -> Tot bool
let bool_of_compare #a f x y = f x y < 0
(** [compare_of_bool] turns a strict order into a comparison
function. More precisely, [compare_of_bool rel x y] returns a positive
number if, and only if, x `rel` y holds. Inspired from OCaml, where
polymorphic comparison using both the [compare] function and the (>)
infix operator are such that [compare x y] is positive if, and only
if, x > y. Requires, at type-checking time, [rel] to be a pure total
function. *)
val compare_of_bool : #a:eqtype -> (a -> a -> Tot bool) -> a -> a -> Tot int
let compare_of_bool #a rel x y =
if x `rel` y then -1
else if x = y then 0
else 1
let compare_of_bool_of_compare (#a:eqtype) (f:a -> a -> Tot bool)
: Lemma (forall x y. bool_of_compare (compare_of_bool f) x y == f x y)
= ()
(** [sortWith compare l] returns the list [l'] containing the elements
of [l] sorted along the comparison function [compare], in such a
way that if [compare x y > 0], then [x] appears before [y] in
[l']. Sorts in ascending order *) | false | false | FStar.List.Tot.Base.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 sortWith: ('a -> 'a -> Tot int) -> l:list 'a -> Tot (list 'a) (decreases (length l)) | [
"recursion"
] | FStar.List.Tot.Base.sortWith | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: 'a -> _: 'a -> Prims.int) -> l: Prims.list 'a -> Prims.Tot (Prims.list 'a) | {
"end_col": 50,
"end_line": 528,
"start_col": 21,
"start_line": 523
} |
Prims.Tot | val split: list ('a * 'b) -> Tot (list 'a * list 'b) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec split l = match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = split tl in
(hd1::tl1,hd2::tl2) | val split: list ('a * 'b) -> Tot (list 'a * list 'b)
let rec split l = | false | null | false | match l with
| [] -> ([], [])
| (hd1, hd2) :: tl ->
let tl1, tl2 = split tl in
(hd1 :: tl1, hd2 :: tl2) | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Prims.Nil",
"Prims.Cons",
"FStar.List.Tot.Base.split"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl
(** [no_repeats_p l] valid if, and only if, no element of [l]
appears in [l] more than once. *)
val no_repeats_p : #a:Type -> list a -> Tot prop
let rec no_repeats_p #a la =
match la with
| [] -> True
| h :: tl -> ~(memP h tl) /\ no_repeats_p tl
(** List of tuples **)
(** [assoc x l] returns [Some y] where [(x, y)] is the first element
of [l] whose first element is [x], or [None] only if no such element
exists. Requires, at type-checking time, the type of [x] to have
decidable equality. Named as in: OCaml. *)
val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b)
let rec assoc #a #b x = function
| [] -> None
| (x', y)::tl -> if x=x' then Some y else assoc x tl
(** [split] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
OCaml *) | false | false | FStar.List.Tot.Base.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 split: list ('a * 'b) -> Tot (list 'a * list 'b) | [
"recursion"
] | FStar.List.Tot.Base.split | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list ('a * 'b) -> Prims.list 'a * Prims.list 'b | {
"end_col": 26,
"end_line": 421,
"start_col": 18,
"start_line": 417
} |
Prims.Tot | val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl | val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = | false | null | false | match l with
| [] -> None
| hd :: tl -> if p hd then Some hd else tryFind p tl | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.bool",
"Prims.list",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.Some",
"FStar.List.Tot.Base.tryFind",
"FStar.Pervasives.Native.option"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *) | false | false | FStar.List.Tot.Base.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 tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a) | [
"recursion"
] | FStar.List.Tot.Base.tryFind | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | p: (_: 'a -> Prims.bool) -> l: Prims.list 'a -> FStar.Pervasives.Native.option 'a | {
"end_col": 54,
"end_line": 336,
"start_col": 22,
"start_line": 334
} |
Prims.Tot | val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl | val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = | false | null | false | match l with
| [] -> None
| hd :: tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.option",
"Prims.list",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.Some",
"FStar.List.Tot.Base.tryPick"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *) | false | false | FStar.List.Tot.Base.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 tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b) | [
"recursion"
] | FStar.List.Tot.Base.tryPick | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: 'a -> FStar.Pervasives.Native.option 'b) -> l: Prims.list 'a
-> FStar.Pervasives.Native.option 'b | {
"end_col": 31,
"end_line": 348,
"start_col": 22,
"start_line": 343
} |
FStar.Pervasives.Lemma | val lemma_splitAt_snd_length (#a: Type) (n: nat) (l: list a)
: Lemma (requires (n <= length l)) (ensures (length (snd (splitAt n l)) = length l - n)) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec lemma_splitAt_snd_length (#a:Type) (n:nat) (l:list a) :
Lemma
(requires (n <= length l))
(ensures (length (snd (splitAt n l)) = length l - n)) =
match n, l with
| 0, _ -> ()
| _, [] -> ()
| _, _ :: l' -> lemma_splitAt_snd_length (n - 1) l' | val lemma_splitAt_snd_length (#a: Type) (n: nat) (l: list a)
: Lemma (requires (n <= length l)) (ensures (length (snd (splitAt n l)) = length l - n))
let rec lemma_splitAt_snd_length (#a: Type) (n: nat) (l: list a)
: Lemma (requires (n <= length l)) (ensures (length (snd (splitAt n l)) = length l - n)) = | false | null | true | match n, l with
| 0, _ -> ()
| _, [] -> ()
| _, _ :: l' -> lemma_splitAt_snd_length (n - 1) l' | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Prims.list",
"FStar.Pervasives.Native.Mktuple2",
"Prims.int",
"FStar.List.Tot.Base.lemma_splitAt_snd_length",
"Prims.op_Subtraction",
"Prims.unit",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.List.Tot.Base.length",
"Prims.squash",
"Prims.op_Equality",
"FStar.Pervasives.Native.snd",
"FStar.List.Tot.Base.splitAt",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl
(** [no_repeats_p l] valid if, and only if, no element of [l]
appears in [l] more than once. *)
val no_repeats_p : #a:Type -> list a -> Tot prop
let rec no_repeats_p #a la =
match la with
| [] -> True
| h :: tl -> ~(memP h tl) /\ no_repeats_p tl
(** List of tuples **)
(** [assoc x l] returns [Some y] where [(x, y)] is the first element
of [l] whose first element is [x], or [None] only if no such element
exists. Requires, at type-checking time, the type of [x] to have
decidable equality. Named as in: OCaml. *)
val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b)
let rec assoc #a #b x = function
| [] -> None
| (x', y)::tl -> if x=x' then Some y else assoc x tl
(** [split] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
OCaml *)
val split: list ('a * 'b) -> Tot (list 'a * list 'b)
let rec split l = match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = split tl in
(hd1::tl1,hd2::tl2)
(** [unzip] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
Haskell *)
let unzip l = split l
(** [unzip3] takes a list of triples [(x1, y1, z1), ..., (xn, yn, zn)]
and returns the triple of lists ([x1, ..., xn], [y1, ..., yn], [z1,
..., zn]). Named as in: Haskell *)
val unzip3: list ('a * 'b * 'c) -> Tot (list 'a * list 'b * list 'c)
let rec unzip3 l = match l with
| [] -> ([],[],[])
| (hd1,hd2,hd3)::tl ->
let (tl1,tl2,tl3) = unzip3 tl in
(hd1::tl1,hd2::tl2,hd3::tl3)
(** Splitting a list at some index **)
(** [splitAt] takes a natural number n and a list and returns a pair
of the maximal prefix of l of size smaller than n and the rest of
the list *)
let rec splitAt (#a:Type) (n:nat) (l:list a) : Tot (list a * list a) =
if n = 0 then [], l
else
match l with
| [] -> [], l
| x :: xs -> let l1, l2 = splitAt (n-1) xs in x :: l1, l2
let rec lemma_splitAt_snd_length (#a:Type) (n:nat) (l:list a) :
Lemma
(requires (n <= length l)) | false | false | FStar.List.Tot.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_splitAt_snd_length (#a: Type) (n: nat) (l: list a)
: Lemma (requires (n <= length l)) (ensures (length (snd (splitAt n l)) = length l - n)) | [
"recursion"
] | FStar.List.Tot.Base.lemma_splitAt_snd_length | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | n: Prims.nat -> l: Prims.list a
-> FStar.Pervasives.Lemma (requires n <= FStar.List.Tot.Base.length l)
(ensures
FStar.List.Tot.Base.length (FStar.Pervasives.Native.snd (FStar.List.Tot.Base.splitAt n l)) =
FStar.List.Tot.Base.length l - n) | {
"end_col": 53,
"end_line": 457,
"start_col": 2,
"start_line": 454
} |
Prims.Tot | val list_unref : #a:Type -> #p:(a -> Type0) -> list (x:a{p x}) -> Tot (list a) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec list_unref #a #p l =
match l with
| [] -> []
| x::xs -> x :: list_unref xs | val list_unref : #a:Type -> #p:(a -> Type0) -> list (x:a{p x}) -> Tot (list a)
let rec list_unref #a #p l = | false | null | false | match l with
| [] -> []
| x :: xs -> x :: list_unref xs | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.Nil",
"Prims.Cons",
"FStar.List.Tot.Base.list_unref"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl
(** [no_repeats_p l] valid if, and only if, no element of [l]
appears in [l] more than once. *)
val no_repeats_p : #a:Type -> list a -> Tot prop
let rec no_repeats_p #a la =
match la with
| [] -> True
| h :: tl -> ~(memP h tl) /\ no_repeats_p tl
(** List of tuples **)
(** [assoc x l] returns [Some y] where [(x, y)] is the first element
of [l] whose first element is [x], or [None] only if no such element
exists. Requires, at type-checking time, the type of [x] to have
decidable equality. Named as in: OCaml. *)
val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b)
let rec assoc #a #b x = function
| [] -> None
| (x', y)::tl -> if x=x' then Some y else assoc x tl
(** [split] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
OCaml *)
val split: list ('a * 'b) -> Tot (list 'a * list 'b)
let rec split l = match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = split tl in
(hd1::tl1,hd2::tl2)
(** [unzip] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
Haskell *)
let unzip l = split l
(** [unzip3] takes a list of triples [(x1, y1, z1), ..., (xn, yn, zn)]
and returns the triple of lists ([x1, ..., xn], [y1, ..., yn], [z1,
..., zn]). Named as in: Haskell *)
val unzip3: list ('a * 'b * 'c) -> Tot (list 'a * list 'b * list 'c)
let rec unzip3 l = match l with
| [] -> ([],[],[])
| (hd1,hd2,hd3)::tl ->
let (tl1,tl2,tl3) = unzip3 tl in
(hd1::tl1,hd2::tl2,hd3::tl3)
(** Splitting a list at some index **)
(** [splitAt] takes a natural number n and a list and returns a pair
of the maximal prefix of l of size smaller than n and the rest of
the list *)
let rec splitAt (#a:Type) (n:nat) (l:list a) : Tot (list a * list a) =
if n = 0 then [], l
else
match l with
| [] -> [], l
| x :: xs -> let l1, l2 = splitAt (n-1) xs in x :: l1, l2
let rec lemma_splitAt_snd_length (#a:Type) (n:nat) (l:list a) :
Lemma
(requires (n <= length l))
(ensures (length (snd (splitAt n l)) = length l - n)) =
match n, l with
| 0, _ -> ()
| _, [] -> ()
| _, _ :: l' -> lemma_splitAt_snd_length (n - 1) l'
(** [unsnoc] is an inverse of [snoc]. It splits a list into
all-elements-except-last and last element. *)
val unsnoc: #a:Type -> l:list a{length l > 0} -> Tot (list a * a)
let unsnoc #a l =
let l1, l2 = splitAt (length l - 1) l in
lemma_splitAt_snd_length (length l - 1) l;
l1, hd l2
(** [split3] splits a list into 3 parts. This allows easy access to
the part of the list before and after the element, as well as the
element itself. *)
val split3: #a:Type -> l:list a -> i:nat{i < length l} -> Tot (list a * a * list a)
let split3 #a l i =
let a, rest = splitAt i l in
lemma_splitAt_snd_length i l;
let b :: c = rest in
a, b, c
(** Sorting (implemented as quicksort) **)
(** [partition] splits a list [l] into two lists, the sum of whose
lengths is the length of [l]. *)
val partition_length: f:('a -> Tot bool)
-> l:list 'a
-> Lemma (requires True)
(ensures (length (fst (partition f l))
+ length (snd (partition f l)) = length l))
let rec partition_length f l = match l with
| [] -> ()
| hd::tl -> partition_length f tl
(** [bool_of_compare] turns a comparison function into a strict
order. More precisely, [bool_of_compare compare x y] returns true
if, and only if, [compare x y] is negative, meaning [x] precedes
[y] in the ordering defined by compare.
This is used in sorting, and is defined to be consistent with
OCaml and F#, where sorting is performed in ascending order.
*)
val bool_of_compare : #a:Type -> (a -> a -> Tot int) -> a -> a -> Tot bool
let bool_of_compare #a f x y = f x y < 0
(** [compare_of_bool] turns a strict order into a comparison
function. More precisely, [compare_of_bool rel x y] returns a positive
number if, and only if, x `rel` y holds. Inspired from OCaml, where
polymorphic comparison using both the [compare] function and the (>)
infix operator are such that [compare x y] is positive if, and only
if, x > y. Requires, at type-checking time, [rel] to be a pure total
function. *)
val compare_of_bool : #a:eqtype -> (a -> a -> Tot bool) -> a -> a -> Tot int
let compare_of_bool #a rel x y =
if x `rel` y then -1
else if x = y then 0
else 1
let compare_of_bool_of_compare (#a:eqtype) (f:a -> a -> Tot bool)
: Lemma (forall x y. bool_of_compare (compare_of_bool f) x y == f x y)
= ()
(** [sortWith compare l] returns the list [l'] containing the elements
of [l] sorted along the comparison function [compare], in such a
way that if [compare x y > 0], then [x] appears before [y] in
[l']. Sorts in ascending order *)
val sortWith: ('a -> 'a -> Tot int) -> l:list 'a -> Tot (list 'a) (decreases (length l))
let rec sortWith f = function
| [] -> []
| pivot::tl ->
let hi, lo = partition (bool_of_compare f pivot) tl in
partition_length (bool_of_compare f pivot) tl;
append (sortWith f lo) (pivot::sortWith f hi)
(** A l1 is a strict suffix of l2. *)
let rec strict_suffix_of (#a: Type) (l1 l2: list a)
: Pure Type0
(requires True)
(ensures (fun _ -> True))
(decreases l2)
= match l2 with
| [] -> False
| _ :: q -> l1 == q \/ l1 `strict_suffix_of` q
[@@deprecated "This function was misnamed: Please use 'strict_suffix_of'"]
let strict_prefix_of = strict_suffix_of
val list_unref : #a:Type -> #p:(a -> Type0) -> list (x:a{p x}) -> Tot (list a) | false | false | FStar.List.Tot.Base.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 list_unref : #a:Type -> #p:(a -> Type0) -> list (x:a{p x}) -> Tot (list a) | [
"recursion"
] | FStar.List.Tot.Base.list_unref | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list (x: a{p x}) -> Prims.list a | {
"end_col": 33,
"end_line": 547,
"start_col": 4,
"start_line": 545
} |
Prims.Tot | val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2 | val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = | false | null | false | function
| [] -> [], []
| hd :: tl ->
let l1, l2 = partition f tl in
if f hd then hd :: l1, l2 else l1, hd :: l2 | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.bool",
"Prims.list",
"FStar.Pervasives.Native.Mktuple2",
"Prims.Nil",
"Prims.Cons",
"FStar.Pervasives.Native.tuple2",
"FStar.List.Tot.Base.partition"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *) | false | false | FStar.List.Tot.Base.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 partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a) | [
"recursion"
] | FStar.List.Tot.Base.partition | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: 'a -> Prims.bool) -> _: Prims.list 'a -> Prims.list 'a * Prims.list 'a | {
"end_col": 20,
"end_line": 373,
"start_col": 22,
"start_line": 367
} |
FStar.Pervasives.Lemma | val for_all_mem (#a: Type) (f: (a -> Tot bool)) (l: list a)
: Lemma (for_all f l <==> (forall x. memP x l ==> f x)) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q | val for_all_mem (#a: Type) (f: (a -> Tot bool)) (l: list a)
: Lemma (for_all f l <==> (forall x. memP x l ==> f x))
let rec for_all_mem (#a: Type) (f: (a -> Tot bool)) (l: list a)
: Lemma (for_all f l <==> (forall x. memP x l ==> f x)) = | false | null | true | match l with
| [] -> ()
| _ :: q -> for_all_mem f q | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"lemma"
] | [
"Prims.bool",
"Prims.list",
"FStar.List.Tot.Base.for_all_mem",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_iff",
"Prims.b2t",
"FStar.List.Tot.Base.for_all",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.List.Tot.Base.memP",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma | false | false | FStar.List.Tot.Base.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 for_all_mem (#a: Type) (f: (a -> Tot bool)) (l: list a)
: Lemma (for_all f l <==> (forall x. memP x l ==> f x)) | [
"recursion"
] | FStar.List.Tot.Base.for_all_mem | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> Prims.bool) -> l: Prims.list a
-> FStar.Pervasives.Lemma
(ensures
FStar.List.Tot.Base.for_all f l <==> (forall (x: a). FStar.List.Tot.Base.memP x l ==> f x)) | {
"end_col": 29,
"end_line": 316,
"start_col": 2,
"start_line": 314
} |
Prims.Tot | val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x) | val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = | false | null | false | match l with
| [] -> x
| hd :: tl -> f hd (fold_right f tl x) | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"FStar.List.Tot.Base.fold_right"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *) | false | false | FStar.List.Tot.Base.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 fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b | [
"recursion"
] | FStar.List.Tot.Base.fold_right | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: 'a -> _: 'b -> 'b) -> l: Prims.list 'a -> x: 'b -> 'b | {
"end_col": 38,
"end_line": 197,
"start_col": 27,
"start_line": 195
} |
Prims.Tot | val rev_acc: list 'a -> list 'a -> Tot (list 'a) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc) | val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = | false | null | false | match l with
| [] -> acc
| hd :: tl -> rev_acc tl (hd :: acc) | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"FStar.List.Tot.Base.rev_acc",
"Prims.Cons"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *) | false | false | FStar.List.Tot.Base.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 rev_acc: list 'a -> list 'a -> Tot (list 'a) | [
"recursion"
] | FStar.List.Tot.Base.rev_acc | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list 'a -> acc: Prims.list 'a -> Prims.list 'a | {
"end_col": 36,
"end_line": 110,
"start_col": 24,
"start_line": 108
} |
Prims.Tot | val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl | val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = | false | null | false | match l with
| [] -> false
| hd :: tl -> if f hd then true else existsb f tl | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.bool",
"Prims.list",
"FStar.List.Tot.Base.existsb"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a | false | false | FStar.List.Tot.Base.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 existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool | [
"recursion"
] | FStar.List.Tot.Base.existsb | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> Prims.bool) -> l: Prims.list a -> Prims.bool | {
"end_col": 48,
"end_line": 258,
"start_col": 25,
"start_line": 256
} |
Prims.Tot | val memP (#a: Type) (x: a) (l: list a) : Tot Type0 | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q | val memP (#a: Type) (x: a) (l: list a) : Tot Type0
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 = | false | null | false | match l with
| [] -> False
| y :: q -> x == y \/ memP x q | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.l_False",
"Prims.l_or",
"Prims.eq2",
"FStar.List.Tot.Base.memP"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *) | false | false | FStar.List.Tot.Base.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 memP (#a: Type) (x: a) (l: list a) : Tot Type0 | [
"recursion"
] | FStar.List.Tot.Base.memP | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: a -> l: Prims.list a -> Type0 | {
"end_col": 32,
"end_line": 231,
"start_col": 2,
"start_line": 229
} |
Prims.Tot | val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x}) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl | val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = | false | null | false | function
| [] -> []
| hd :: tl -> if f hd then hd :: filter f tl else filter f tl | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.bool",
"Prims.list",
"Prims.Nil",
"Prims.Cons",
"FStar.List.Tot.Base.filter",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.List.Tot.Base.memP",
"Prims.b2t"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *) | false | false | FStar.List.Tot.Base.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 filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x}) | [
"recursion"
] | FStar.List.Tot.Base.filter | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> Prims.bool) -> l: Prims.list a
-> m: Prims.list a {forall (x: a). FStar.List.Tot.Base.memP x m ==> f x} | {
"end_col": 59,
"end_line": 279,
"start_col": 22,
"start_line": 277
} |
Prims.Tot | val list_refb: #a:eqtype -> #p:(a -> Tot bool) ->
l:list a { for_all p l } ->
Tot (l':list (x:a{ p x }) {
length l = length l' /\
(forall i. {:pattern (index l i) } index l i = index l' i) }) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec list_refb #a #p l =
match l with
| hd :: tl -> hd :: list_refb #a #p tl
| [] -> [] | val list_refb: #a:eqtype -> #p:(a -> Tot bool) ->
l:list a { for_all p l } ->
Tot (l':list (x:a{ p x }) {
length l = length l' /\
(forall i. {:pattern (index l i) } index l i = index l' i) })
let rec list_refb #a #p l = | false | null | false | match l with
| hd :: tl -> hd :: list_refb #a #p tl
| [] -> [] | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.eqtype",
"Prims.bool",
"Prims.list",
"Prims.b2t",
"FStar.List.Tot.Base.for_all",
"Prims.Cons",
"FStar.List.Tot.Base.list_refb",
"Prims.Nil",
"Prims.l_and",
"Prims.op_Equality",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Prims.l_Forall",
"Prims.op_LessThan",
"FStar.List.Tot.Base.index"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl
(** [no_repeats_p l] valid if, and only if, no element of [l]
appears in [l] more than once. *)
val no_repeats_p : #a:Type -> list a -> Tot prop
let rec no_repeats_p #a la =
match la with
| [] -> True
| h :: tl -> ~(memP h tl) /\ no_repeats_p tl
(** List of tuples **)
(** [assoc x l] returns [Some y] where [(x, y)] is the first element
of [l] whose first element is [x], or [None] only if no such element
exists. Requires, at type-checking time, the type of [x] to have
decidable equality. Named as in: OCaml. *)
val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b)
let rec assoc #a #b x = function
| [] -> None
| (x', y)::tl -> if x=x' then Some y else assoc x tl
(** [split] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
OCaml *)
val split: list ('a * 'b) -> Tot (list 'a * list 'b)
let rec split l = match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = split tl in
(hd1::tl1,hd2::tl2)
(** [unzip] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
Haskell *)
let unzip l = split l
(** [unzip3] takes a list of triples [(x1, y1, z1), ..., (xn, yn, zn)]
and returns the triple of lists ([x1, ..., xn], [y1, ..., yn], [z1,
..., zn]). Named as in: Haskell *)
val unzip3: list ('a * 'b * 'c) -> Tot (list 'a * list 'b * list 'c)
let rec unzip3 l = match l with
| [] -> ([],[],[])
| (hd1,hd2,hd3)::tl ->
let (tl1,tl2,tl3) = unzip3 tl in
(hd1::tl1,hd2::tl2,hd3::tl3)
(** Splitting a list at some index **)
(** [splitAt] takes a natural number n and a list and returns a pair
of the maximal prefix of l of size smaller than n and the rest of
the list *)
let rec splitAt (#a:Type) (n:nat) (l:list a) : Tot (list a * list a) =
if n = 0 then [], l
else
match l with
| [] -> [], l
| x :: xs -> let l1, l2 = splitAt (n-1) xs in x :: l1, l2
let rec lemma_splitAt_snd_length (#a:Type) (n:nat) (l:list a) :
Lemma
(requires (n <= length l))
(ensures (length (snd (splitAt n l)) = length l - n)) =
match n, l with
| 0, _ -> ()
| _, [] -> ()
| _, _ :: l' -> lemma_splitAt_snd_length (n - 1) l'
(** [unsnoc] is an inverse of [snoc]. It splits a list into
all-elements-except-last and last element. *)
val unsnoc: #a:Type -> l:list a{length l > 0} -> Tot (list a * a)
let unsnoc #a l =
let l1, l2 = splitAt (length l - 1) l in
lemma_splitAt_snd_length (length l - 1) l;
l1, hd l2
(** [split3] splits a list into 3 parts. This allows easy access to
the part of the list before and after the element, as well as the
element itself. *)
val split3: #a:Type -> l:list a -> i:nat{i < length l} -> Tot (list a * a * list a)
let split3 #a l i =
let a, rest = splitAt i l in
lemma_splitAt_snd_length i l;
let b :: c = rest in
a, b, c
(** Sorting (implemented as quicksort) **)
(** [partition] splits a list [l] into two lists, the sum of whose
lengths is the length of [l]. *)
val partition_length: f:('a -> Tot bool)
-> l:list 'a
-> Lemma (requires True)
(ensures (length (fst (partition f l))
+ length (snd (partition f l)) = length l))
let rec partition_length f l = match l with
| [] -> ()
| hd::tl -> partition_length f tl
(** [bool_of_compare] turns a comparison function into a strict
order. More precisely, [bool_of_compare compare x y] returns true
if, and only if, [compare x y] is negative, meaning [x] precedes
[y] in the ordering defined by compare.
This is used in sorting, and is defined to be consistent with
OCaml and F#, where sorting is performed in ascending order.
*)
val bool_of_compare : #a:Type -> (a -> a -> Tot int) -> a -> a -> Tot bool
let bool_of_compare #a f x y = f x y < 0
(** [compare_of_bool] turns a strict order into a comparison
function. More precisely, [compare_of_bool rel x y] returns a positive
number if, and only if, x `rel` y holds. Inspired from OCaml, where
polymorphic comparison using both the [compare] function and the (>)
infix operator are such that [compare x y] is positive if, and only
if, x > y. Requires, at type-checking time, [rel] to be a pure total
function. *)
val compare_of_bool : #a:eqtype -> (a -> a -> Tot bool) -> a -> a -> Tot int
let compare_of_bool #a rel x y =
if x `rel` y then -1
else if x = y then 0
else 1
let compare_of_bool_of_compare (#a:eqtype) (f:a -> a -> Tot bool)
: Lemma (forall x y. bool_of_compare (compare_of_bool f) x y == f x y)
= ()
(** [sortWith compare l] returns the list [l'] containing the elements
of [l] sorted along the comparison function [compare], in such a
way that if [compare x y > 0], then [x] appears before [y] in
[l']. Sorts in ascending order *)
val sortWith: ('a -> 'a -> Tot int) -> l:list 'a -> Tot (list 'a) (decreases (length l))
let rec sortWith f = function
| [] -> []
| pivot::tl ->
let hi, lo = partition (bool_of_compare f pivot) tl in
partition_length (bool_of_compare f pivot) tl;
append (sortWith f lo) (pivot::sortWith f hi)
(** A l1 is a strict suffix of l2. *)
let rec strict_suffix_of (#a: Type) (l1 l2: list a)
: Pure Type0
(requires True)
(ensures (fun _ -> True))
(decreases l2)
= match l2 with
| [] -> False
| _ :: q -> l1 == q \/ l1 `strict_suffix_of` q
[@@deprecated "This function was misnamed: Please use 'strict_suffix_of'"]
let strict_prefix_of = strict_suffix_of
val list_unref : #a:Type -> #p:(a -> Type0) -> list (x:a{p x}) -> Tot (list a)
let rec list_unref #a #p l =
match l with
| [] -> []
| x::xs -> x :: list_unref xs
val list_refb: #a:eqtype -> #p:(a -> Tot bool) ->
l:list a { for_all p l } ->
Tot (l':list (x:a{ p x }) {
length l = length l' /\
(forall i. {:pattern (index l i) } index l i = index l' i) }) | false | false | FStar.List.Tot.Base.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 list_refb: #a:eqtype -> #p:(a -> Tot bool) ->
l:list a { for_all p l } ->
Tot (l':list (x:a{ p x }) {
length l = length l' /\
(forall i. {:pattern (index l i) } index l i = index l' i) }) | [
"recursion"
] | FStar.List.Tot.Base.list_refb | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list a {FStar.List.Tot.Base.for_all p l}
-> l':
Prims.list (x: a{p x})
{ FStar.List.Tot.Base.length l = FStar.List.Tot.Base.length l' /\
(forall (i:
Prims.nat{i < FStar.List.Tot.Base.length l /\ i < FStar.List.Tot.Base.length l'}).
{:pattern FStar.List.Tot.Base.index l i}
FStar.List.Tot.Base.index l i = FStar.List.Tot.Base.index l' i) } | {
"end_col": 12,
"end_line": 557,
"start_col": 2,
"start_line": 555
} |
Prims.Tot | val list_ref: #a:eqtype -> #p:(a -> Tot prop) -> l:list a {
forall x. {:pattern mem x l} mem x l ==> p x
} -> Tot (l':list (x:a{ p x }) {
length l = length l' /\
(forall i. {:pattern (index l i) } index l i = index l' i) }) | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec list_ref #a #p l =
match l with
| hd :: tl ->
assert (mem hd l);
assert (p hd);
assert (forall x. {:pattern mem x tl} mem x tl ==> mem x l);
hd :: list_ref #a #p tl
| [] -> [] | val list_ref: #a:eqtype -> #p:(a -> Tot prop) -> l:list a {
forall x. {:pattern mem x l} mem x l ==> p x
} -> Tot (l':list (x:a{ p x }) {
length l = length l' /\
(forall i. {:pattern (index l i) } index l i = index l' i) })
let rec list_ref #a #p l = | false | null | false | match l with
| hd :: tl ->
assert (mem hd l);
assert (p hd);
assert (forall x. {:pattern mem x tl} mem x tl ==> mem x l);
hd :: list_ref #a #p tl
| [] -> [] | {
"checked_file": "FStar.List.Tot.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.List.Tot.Base.fst"
} | [
"total"
] | [
"Prims.eqtype",
"Prims.prop",
"Prims.list",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.b2t",
"FStar.List.Tot.Base.mem",
"Prims.Cons",
"FStar.List.Tot.Base.list_ref",
"Prims.unit",
"Prims._assert",
"Prims.Nil",
"Prims.l_and",
"Prims.op_Equality",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Prims.op_LessThan",
"FStar.List.Tot.Base.index"
] | [] | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(**
This module defines all pure and total operations on lists that can be
used in specifications. It is implemented by FStar_List_Tot_Base.ml, any
functional change and/or the addition of new functions MUST be reflected
there.
@summary Pure total operations on lists
*)
module FStar.List.Tot.Base
(**
Base operations
*)
(** [isEmpty l] returns [true] if and only if [l] is empty *)
val isEmpty: list 'a -> Tot bool
let isEmpty l = match l with
| [] -> true
| _ -> false
(** [hd l] returns the first element of [l]. Requires [l] to be
nonempty, at type-checking time. Named as in: OCaml, F#, Coq *)
val hd: l:list 'a{Cons? l} -> Tot 'a
let hd = function
| hd::_ -> hd
(** [tail l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Similar to: tl in OCaml, F#, Coq
*)
val tail: l:list 'a {Cons? l} -> Tot (list 'a)
let tail = function
| _::tl -> tl
(** [tl l] returns [l] without its first element. Requires, at
type-checking time, that [l] be nonempty. Named as in: OCaml, F#, Coq
*)
val tl: l:list 'a {Cons? l} -> Tot (list 'a)
let tl = tail
(** [last l] returns the last element of [l]. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val last: l:list 'a {Cons? l} -> Tot 'a
let rec last = function
| [hd] -> hd
| _::tl -> last tl
(** [init l] returns [l] without its last element. Requires, at
type-checking time, that [l] be nonempty. Named as in: Haskell
*)
val init: l:list 'a {Cons? l} -> Tot (list 'a)
let rec init = function
| [_] -> []
| hd::tl -> hd::(init tl)
(** [length l] returns the total number of elements in [l]. Named as
in: OCaml, F#, Coq *)
val length: list 'a -> Tot nat
let rec length = function
| [] -> 0
| _::tl -> 1 + length tl
(** [nth l n] returns the [n]-th element in list [l] (with the first
element being the 0-th) if [l] is long enough, or [None]
otherwise. Named as in: OCaml, F#, Coq *)
val nth: list 'a -> nat -> Tot (option 'a)
let rec nth l n = match l with
| [] -> None
| hd::tl -> if n = 0 then Some hd else nth tl (n - 1)
(** [index l n] returns the [n]-th element in list [l] (with the first
element being the 0-th). Requires, at type-checking time, that [l] be
of length at least [n+1]. *)
val index: #a:Type -> l:list a -> i:nat{i < length l} -> Tot a
let rec index #a (l: list a) (i:nat{i < length l}): Tot a =
if i = 0 then
hd l
else
index (tl l) (i - 1)
(** [count x l] returns the number of occurrences of [x] in
[l]. Requires, at type-checking time, the type of [a] to have equality
defined. Similar to: [List.count_occ] in Coq. *)
val count: #a:eqtype -> a -> list a -> Tot nat
let rec count #a x = function
| [] -> 0
| hd::tl -> if x=hd then 1 + count x tl else count x tl
(** [rev_acc l1 l2] appends the elements of [l1] to the beginning of
[l2], in reverse order. It is equivalent to [append (rev l1) l2], but
is tail-recursive. Similar to: [List.rev_append] in OCaml, Coq. *)
val rev_acc: list 'a -> list 'a -> Tot (list 'a)
let rec rev_acc l acc = match l with
| [] -> acc
| hd::tl -> rev_acc tl (hd::acc)
(** [rev l] returns the list [l] in reverse order. Named as in: OCaml,
F#, Coq. *)
val rev: list 'a -> Tot (list 'a)
let rev l = rev_acc l []
(** [append l1 l2] appends the elements of [l2] to the end of [l1]. Named as: OCaml, F#. Similar to: [List.app] in Coq. *)
val append: list 'a -> list 'a -> Tot (list 'a)
let rec append x y = match x with
| [] -> y
| a::tl -> a::append tl y
(** Defines notation [@@] for [append], as in OCaml, F# . *)
let op_At x y = append x y
(** [snoc (l, x)] adds [x] to the end of the list [l].
Note: We use an uncurried [snoc (l, x)] instead of the curried
[snoc l x]. This is intentional. If [snoc] takes a pair instead
of 2 arguments, it allows for a better pattern on
[lemma_unsnoc_snoc], which connects [snoc] and [unsnoc]. In
particular, if we had two arguments, then either the pattern would
either be too restrictive or would lead to over-triggering. More
context for this can be seen in the (collapsed and uncollapsed)
comments at https://github.com/FStarLang/FStar/pull/1560 *)
val snoc: (list 'a * 'a) -> Tot (list 'a)
let snoc (l, x) = append l [x]
(** [flatten l], where [l] is a list of lists, returns the list of the
elements of the lists in [l], preserving their order. Named as in:
OCaml, Coq. *)
val flatten: list (list 'a) -> Tot (list 'a)
let rec flatten l = match l with
| [] -> []
| hd::tl -> append hd (flatten tl)
(** [map f l] applies [f] to each element of [l] and returns the list
of results, in the order of the original elements in [l]. Requires, at
type-checking time, [f] to be a pure total function. Named as in: OCaml, Coq, F# *)
val map: ('a -> Tot 'b) -> list 'a -> Tot (list 'b)
let rec map f x = match x with
| [] -> []
| a::tl -> f a::map f tl
(** [mapi_init f l n] applies, for each [k], [f (n+k)] to the [k]-th
element of [l] and returns the list of results, in the order of the
original elements in [l]. Requires, at type-checking time, [f] to be a
pure total function. *)
val mapi_init: (int -> 'a -> Tot 'b) -> list 'a -> int -> Tot (list 'b)
let rec mapi_init f l i = match l with
| [] -> []
| hd::tl -> (f i hd)::(mapi_init f tl (i+1))
(** [mapi f l] applies, for each [k], [f k] to the [k]-th element of
[l] and returns the list of results, in the order of the original
elements in [l]. Requires, at type-checking time, [f] to be a pure
total function. Named as in: OCaml *)
val mapi: (int -> 'a -> Tot 'b) -> list 'a -> Tot (list 'b)
let mapi f l = mapi_init f l 0
(** [concatMap f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. This is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. *)
val concatMap: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec concatMap f = function
| [] -> []
| a::tl ->
let fa = f a in
let ftl = concatMap f tl in
append fa ftl
(** [fold_left f x [y1; y2; ...; yn]] computes (f (... (f x y1) y2)
... yn). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq. *)
val fold_left: ('a -> 'b -> Tot 'a) -> 'a -> l:list 'b -> Tot 'a (decreases l)
let rec fold_left f x l = match l with
| [] -> x
| hd::tl -> fold_left f (f x hd) tl
(** [fold_right f [x1; x2; ...; xn] y] computes (f x1 (f x2 (... (f xn
y)) ... )). Requires, at type-checking time, [f] to be a pure total
function. Named as in: OCaml, Coq *)
val fold_right: ('a -> 'b -> Tot 'b) -> list 'a -> 'b -> Tot 'b
let rec fold_right f l x = match l with
| [] -> x
| hd::tl -> f hd (fold_right f tl x)
(** [fold_right_gtot] is just like [fold_right], except `f` is
a ghost function **)
let rec fold_right_gtot (#a:Type) (#b:Type) (l:list a) (f:a -> b -> GTot b) (x:b)
: GTot b
= match l with
| [] -> x
| hd::tl -> f hd (fold_right_gtot tl f x)
(* We define map in terms of fold, to share simple lemmas *)
let map_gtot #a #b (f:a -> GTot b) (x:list a)
: GTot (list b)
= fold_right_gtot x (fun x tl -> f x :: tl) []
(** [fold_left2 f x [y1; y2; ...; yn] [z1; z2; ...; zn]] computes (f
(... (f x y1 z1) y2 z2) ... yn zn). Requires, at type-checking time,
[f] to be a pure total function, and the lists [y1; y2; ...; yn] and
[z1; z2; ...; zn] to have the same lengths. Named as in: OCaml *)
val fold_left2 : f:('a -> 'b -> 'c -> Tot 'a) -> accu:'a -> l1:(list 'b) -> l2:(list 'c) ->
Pure 'a (requires (length l1 == length l2)) (ensures (fun _ -> True)) (decreases l1)
let rec fold_left2 f accu l1 l2 =
match (l1, l2) with
| ([], []) -> accu
| (a1::l1, a2::l2) -> fold_left2 f (f accu a1 a2) l1 l2
(** Propositional membership (as in Coq). Does not require decidable
equality. *)
(** [memP x l] holds if, and only if, [x] appears as an
element of [l]. Similar to: List.In in Coq. *)
let rec memP (#a: Type) (x: a) (l: list a) : Tot Type0 =
match l with
| [] -> False
| y :: q -> x == y \/ memP x q
(** List searching **)
(** [mem x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. Named as in: OCaml. See also:
List.In in Coq, which is propositional. *)
val mem: #a:eqtype -> a -> list a -> Tot bool
let rec mem #a x = function
| [] -> false
| hd::tl -> if hd = x then true else mem x tl
(** [contains x l] returns [true] if, and only if, [x] appears as an
element of [l]. Requires, at type-checking time, the type of elements
of [l] to have decidable equality. It is equivalent to: [mem x
l]. TODO: should we rather swap the order of arguments? *)
let contains : #a:eqtype -> a -> list a -> Tot bool = mem
(** [existsb f l] returns [true] if, and only if, there exists some
element [x] in [l] such that [f x] holds. *)
val existsb: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot bool
let rec existsb #a f l = match l with
| [] -> false
| hd::tl -> if f hd then true else existsb f tl
(** [find f l] returns [Some x] for some element [x] appearing in [l]
such that [f x] holds, or [None] only if no such [x] exists. *)
val find: #a:Type
-> f:(a -> Tot bool)
-> list a
-> Tot (option (x:a{f x}))
let rec find #a f l = match l with
| [] -> None #(x:a{f x}) //These type annotations are only present because it makes bootstrapping go much faster
| hd::tl -> if f hd then Some #(x:a{f x}) hd else find f tl
(** Filtering elements of a list [l] through a Boolean pure total
predicate [f] *)
(** [filter f l] returns [l] with all elements [x] such that [f x]
does not hold removed. Requires, at type-checking time, [f] to be a
pure total function. Named as in: OCaml, Coq *)
val filter : #a: Type -> f:(a -> Tot bool) -> l: list a -> Tot (m:list a{forall x. memP x m ==> f x})
let rec filter #a f = function
| [] -> []
| hd::tl -> if f hd then hd::filter f tl else filter f tl
(** Postcondition on [filter f l]: for any element [x] of [filter f l],
[f x] holds. Requires, at type-checking time, [f] to be a pure total
function.*)
val mem_filter (#a:Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma
(requires (memP x (filter f l)))
(ensures (f x))
let mem_filter f l x = ()
(** Postcondition on [filter f l]: stated with [forall]: for any element
[x] of [filter f l], [f x] holds. Requires, at type-checking time, [f]
to be a pure total function. *)
val mem_filter_forall (#a:Type) (f: (a -> Tot bool)) (l: list a) : Lemma
(requires True)
(ensures (forall x . memP x (filter f l) ==> f x))
[SMTPat (filter f l)]
let mem_filter_forall f l = FStar.Classical.ghost_lemma (mem_filter f l)
(** [for_all f l] returns [true] if, and only if, for all elements [x]
appearing in [l], [f x] holds. Requires, at type-checking time, [f] to
be a pure total function. Named as in: OCaml. Similar to: List.forallb
in Coq *)
val for_all: ('a -> Tot bool) -> list 'a -> Tot bool
let rec for_all f l = match l with
| [] -> true
| hd::tl -> if f hd then for_all f tl else false
(** Specification for [for_all f l] vs. mem *)
let rec for_all_mem
(#a: Type)
(f: (a -> Tot bool))
(l: list a)
: Lemma
(for_all f l <==> (forall x . memP x l ==> f x))
= match l with
| [] -> ()
| _ :: q -> for_all_mem f q
(** [collect f l] applies [f] to each element of [l] and returns the
concatenation of the results, in the order of the original elements of
[l]. It is equivalent to [flatten (map f l)]. Requires, at
type-checking time, [f] to be a pure total function. TODO: what is
the difference with [concatMap]? *)
val collect: ('a -> Tot (list 'b)) -> list 'a -> Tot (list 'b)
let rec collect f l = match l with
| [] -> []
| hd::tl -> append (f hd) (collect f tl)
(** [tryFind f l] returns [Some x] for some element [x] appearing in
[l] such that [f x] holds, or [None] only if no such [x]
exists. Requires, at type-checking time, [f] to be a pure total
function. Contrary to [find], [tryFind] provides no postcondition on
its result. *)
val tryFind: ('a -> Tot bool) -> list 'a -> Tot (option 'a)
let rec tryFind p l = match l with
| [] -> None
| hd::tl -> if p hd then Some hd else tryFind p tl
(** [tryPick f l] returns [y] for some element [x] appearing in [l]
such that [f x = Some y] for some y, or [None] only if [f x = None]
for all elements [x] of [l]. Requires, at type-checking time, [f] to
be a pure total function. *)
val tryPick: ('a -> Tot (option 'b)) -> list 'a -> Tot (option 'b)
let rec tryPick f l = match l with
| [] -> None
| hd::tl ->
match f hd with
| Some x -> Some x
| None -> tryPick f tl
(** [choose f l] returns the list of [y] for all elements [x]
appearing in [l] such that [f x = Some y] for some [y]. Requires, at
type-checking time, [f] to be a pure total function. *)
val choose: ('a -> Tot (option 'b)) -> list 'a -> Tot (list 'b)
let rec choose f l = match l with
| [] -> []
| hd::tl ->
match f hd with
| Some x -> x::(choose f tl)
| None -> choose f tl
(** [partition f l] returns the pair of lists [(l1, l2)] where all
elements [x] of [l] are in [l1] if [f x] holds, and in [l2]
otherwise. Both [l1] and [l2] retain the original order of
[l]. Requires, at type-checking time, [f] to be a pure total
function. *)
val partition: f:('a -> Tot bool) -> list 'a -> Tot (list 'a * list 'a)
let rec partition f = function
| [] -> [], []
| hd::tl ->
let l1, l2 = partition f tl in
if f hd
then hd::l1, l2
else l1, hd::l2
(** [subset la lb] is true if and only if all the elements from [la]
are also in [lb]. Requires, at type-checking time, the type of
elements of [la] and [lb] to have decidable equality. *)
val subset: #a:eqtype -> list a -> list a -> Tot bool
let rec subset #a la lb =
match la with
| [] -> true
| h :: tl -> mem h lb && subset tl lb
(** [noRepeats l] returns [true] if, and only if, no element of [l]
appears in [l] more than once. Requires, at type-checking time, the
type of elements of [la] and [lb] to have decidable equality. *)
val noRepeats : #a:eqtype -> list a -> Tot bool
let rec noRepeats #a la =
match la with
| [] -> true
| h :: tl -> not(mem h tl) && noRepeats tl
(** [no_repeats_p l] valid if, and only if, no element of [l]
appears in [l] more than once. *)
val no_repeats_p : #a:Type -> list a -> Tot prop
let rec no_repeats_p #a la =
match la with
| [] -> True
| h :: tl -> ~(memP h tl) /\ no_repeats_p tl
(** List of tuples **)
(** [assoc x l] returns [Some y] where [(x, y)] is the first element
of [l] whose first element is [x], or [None] only if no such element
exists. Requires, at type-checking time, the type of [x] to have
decidable equality. Named as in: OCaml. *)
val assoc: #a:eqtype -> #b:Type -> a -> list (a * b) -> Tot (option b)
let rec assoc #a #b x = function
| [] -> None
| (x', y)::tl -> if x=x' then Some y else assoc x tl
(** [split] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
OCaml *)
val split: list ('a * 'b) -> Tot (list 'a * list 'b)
let rec split l = match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = split tl in
(hd1::tl1,hd2::tl2)
(** [unzip] takes a list of pairs [(x1, y1), ..., (xn, yn)] and
returns the pair of lists ([x1, ..., xn], [y1, ..., yn]). Named as in:
Haskell *)
let unzip l = split l
(** [unzip3] takes a list of triples [(x1, y1, z1), ..., (xn, yn, zn)]
and returns the triple of lists ([x1, ..., xn], [y1, ..., yn], [z1,
..., zn]). Named as in: Haskell *)
val unzip3: list ('a * 'b * 'c) -> Tot (list 'a * list 'b * list 'c)
let rec unzip3 l = match l with
| [] -> ([],[],[])
| (hd1,hd2,hd3)::tl ->
let (tl1,tl2,tl3) = unzip3 tl in
(hd1::tl1,hd2::tl2,hd3::tl3)
(** Splitting a list at some index **)
(** [splitAt] takes a natural number n and a list and returns a pair
of the maximal prefix of l of size smaller than n and the rest of
the list *)
let rec splitAt (#a:Type) (n:nat) (l:list a) : Tot (list a * list a) =
if n = 0 then [], l
else
match l with
| [] -> [], l
| x :: xs -> let l1, l2 = splitAt (n-1) xs in x :: l1, l2
let rec lemma_splitAt_snd_length (#a:Type) (n:nat) (l:list a) :
Lemma
(requires (n <= length l))
(ensures (length (snd (splitAt n l)) = length l - n)) =
match n, l with
| 0, _ -> ()
| _, [] -> ()
| _, _ :: l' -> lemma_splitAt_snd_length (n - 1) l'
(** [unsnoc] is an inverse of [snoc]. It splits a list into
all-elements-except-last and last element. *)
val unsnoc: #a:Type -> l:list a{length l > 0} -> Tot (list a * a)
let unsnoc #a l =
let l1, l2 = splitAt (length l - 1) l in
lemma_splitAt_snd_length (length l - 1) l;
l1, hd l2
(** [split3] splits a list into 3 parts. This allows easy access to
the part of the list before and after the element, as well as the
element itself. *)
val split3: #a:Type -> l:list a -> i:nat{i < length l} -> Tot (list a * a * list a)
let split3 #a l i =
let a, rest = splitAt i l in
lemma_splitAt_snd_length i l;
let b :: c = rest in
a, b, c
(** Sorting (implemented as quicksort) **)
(** [partition] splits a list [l] into two lists, the sum of whose
lengths is the length of [l]. *)
val partition_length: f:('a -> Tot bool)
-> l:list 'a
-> Lemma (requires True)
(ensures (length (fst (partition f l))
+ length (snd (partition f l)) = length l))
let rec partition_length f l = match l with
| [] -> ()
| hd::tl -> partition_length f tl
(** [bool_of_compare] turns a comparison function into a strict
order. More precisely, [bool_of_compare compare x y] returns true
if, and only if, [compare x y] is negative, meaning [x] precedes
[y] in the ordering defined by compare.
This is used in sorting, and is defined to be consistent with
OCaml and F#, where sorting is performed in ascending order.
*)
val bool_of_compare : #a:Type -> (a -> a -> Tot int) -> a -> a -> Tot bool
let bool_of_compare #a f x y = f x y < 0
(** [compare_of_bool] turns a strict order into a comparison
function. More precisely, [compare_of_bool rel x y] returns a positive
number if, and only if, x `rel` y holds. Inspired from OCaml, where
polymorphic comparison using both the [compare] function and the (>)
infix operator are such that [compare x y] is positive if, and only
if, x > y. Requires, at type-checking time, [rel] to be a pure total
function. *)
val compare_of_bool : #a:eqtype -> (a -> a -> Tot bool) -> a -> a -> Tot int
let compare_of_bool #a rel x y =
if x `rel` y then -1
else if x = y then 0
else 1
let compare_of_bool_of_compare (#a:eqtype) (f:a -> a -> Tot bool)
: Lemma (forall x y. bool_of_compare (compare_of_bool f) x y == f x y)
= ()
(** [sortWith compare l] returns the list [l'] containing the elements
of [l] sorted along the comparison function [compare], in such a
way that if [compare x y > 0], then [x] appears before [y] in
[l']. Sorts in ascending order *)
val sortWith: ('a -> 'a -> Tot int) -> l:list 'a -> Tot (list 'a) (decreases (length l))
let rec sortWith f = function
| [] -> []
| pivot::tl ->
let hi, lo = partition (bool_of_compare f pivot) tl in
partition_length (bool_of_compare f pivot) tl;
append (sortWith f lo) (pivot::sortWith f hi)
(** A l1 is a strict suffix of l2. *)
let rec strict_suffix_of (#a: Type) (l1 l2: list a)
: Pure Type0
(requires True)
(ensures (fun _ -> True))
(decreases l2)
= match l2 with
| [] -> False
| _ :: q -> l1 == q \/ l1 `strict_suffix_of` q
[@@deprecated "This function was misnamed: Please use 'strict_suffix_of'"]
let strict_prefix_of = strict_suffix_of
val list_unref : #a:Type -> #p:(a -> Type0) -> list (x:a{p x}) -> Tot (list a)
let rec list_unref #a #p l =
match l with
| [] -> []
| x::xs -> x :: list_unref xs
val list_refb: #a:eqtype -> #p:(a -> Tot bool) ->
l:list a { for_all p l } ->
Tot (l':list (x:a{ p x }) {
length l = length l' /\
(forall i. {:pattern (index l i) } index l i = index l' i) })
let rec list_refb #a #p l =
match l with
| hd :: tl -> hd :: list_refb #a #p tl
| [] -> []
val list_ref: #a:eqtype -> #p:(a -> Tot prop) -> l:list a {
forall x. {:pattern mem x l} mem x l ==> p x
} -> Tot (l':list (x:a{ p x }) {
length l = length l' /\
(forall i. {:pattern (index l i) } index l i = index l' i) }) | false | false | FStar.List.Tot.Base.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 list_ref: #a:eqtype -> #p:(a -> Tot prop) -> l:list a {
forall x. {:pattern mem x l} mem x l ==> p x
} -> Tot (l':list (x:a{ p x }) {
length l = length l' /\
(forall i. {:pattern (index l i) } index l i = index l' i) }) | [
"recursion"
] | FStar.List.Tot.Base.list_ref | {
"file_name": "ulib/FStar.List.Tot.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
l:
Prims.list a
{forall (x: a). {:pattern FStar.List.Tot.Base.mem x l} FStar.List.Tot.Base.mem x l ==> p x}
-> l':
Prims.list (x: a{p x})
{ FStar.List.Tot.Base.length l = FStar.List.Tot.Base.length l' /\
(forall (i:
Prims.nat{i < FStar.List.Tot.Base.length l /\ i < FStar.List.Tot.Base.length l'}).
{:pattern FStar.List.Tot.Base.index l i}
FStar.List.Tot.Base.index l i = FStar.List.Tot.Base.index l' i) } | {
"end_col": 12,
"end_line": 571,
"start_col": 2,
"start_line": 565
} |
Subsets and Splits