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_qcode_Check_avx_xcr0_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_avx_xcr0_support ()))
[ { "abbrev": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.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_qcode_Check_avx_xcr0_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx_xcr0_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 358 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 359 column 15 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Xgetbv_Avx ()) (fun (va_s:va_state) _ -> let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 360 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg19 1) (let (va_arg18:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 361 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg18 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 362 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 364 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 366 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2 == Prims.pow2 1)) (fun _ -> (fun (p:prop) -> p) (2 == Prims.pow2 1)) (fun (_:unit) -> assert_normalize (2 == Prims.pow2 1)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 367 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (4 == Prims.pow2 2)) (fun _ -> (fun (p:prop) -> p) (4 == Prims.pow2 2)) (fun (_:unit) -> assert_normalize (4 == Prims.pow2 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 369 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 370 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 2) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 371 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 1) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 373 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (fun (va_s:va_state) _ -> let (va_arg17:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg16:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 374 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg16 va_arg17 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 375 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QEmpty (())))))))))))))))))
val va_qcode_Check_avx_xcr0_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_avx_xcr0_support ())) let va_qcode_Check_avx_xcr0_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_avx_xcr0_support ())) =
false
null
false
(qblock va_mods (fun (va_s: va_state) -> let va_old_s:va_state = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 358 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 359 column 15 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Xgetbv_Avx ()) (fun (va_s: va_state) _ -> let va_arg19:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 360 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg19 1) (let va_arg18:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 361 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg18 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 362 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 364 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4)) (fun (va_s: va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 366 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p: prop) -> normalize p) (2 == Prims.pow2 1)) (fun _ -> (fun (p: prop) -> p) (2 == Prims.pow2 1)) (fun (_: unit) -> assert_normalize (2 == Prims.pow2 1)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 367 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p: prop) -> normalize p) (4 == Prims.pow2 2)) (fun _ -> (fun (p: prop) -> p) (4 == Prims.pow2 2)) (fun (_: unit) -> assert_normalize (4 == Prims.pow2 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 369 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (fun (va_s: va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 370 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 2) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 371 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 1 ) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 373 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx ) (va_const_opr64 2)) (fun (va_s: va_state) _ -> let va_arg17:Vale.Def.Types_s.nat64 = va_get_reg64 rRcx va_s in let va_arg16:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 374 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg16 va_arg17 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 375 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QEmpty (())))))))))))))))) )
{ "checked_file": "Vale.Lib.X64.Cpuid.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.X64.Cpuid.fst" }
[ "total" ]
[ "Vale.X64.QuickCode.va_mods_t", "Vale.X64.QuickCodes.qblock", "Prims.unit", "Prims.Cons", "Vale.X64.Decls.va_code", "Vale.X64.InsBasic.va_code_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rRcx", "Vale.X64.Decls.va_const_opr64", "Vale.X64.InsBasic.va_code_Xgetbv_Avx", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.Machine_s.rRax", "Vale.X64.InsBasic.va_code_And64", "Vale.X64.InsBasic.va_code_Shr64", "Vale.X64.Decls.va_const_shift_amt64", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_QSeq", "Vale.X64.QuickCodes.va_range1", "Vale.X64.InsBasic.va_quick_Mov64", "Vale.X64.QuickCodes.va_QBind", "Vale.X64.InsBasic.va_quick_Xgetbv_Avx", "Vale.X64.QuickCodes.va_qPURE", "Prims.pure_post", "Prims.l_and", "Prims.l_True", "Prims.l_Forall", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.l_or", "Prims.eq2", "Prims.int", "Vale.Def.Types_s.iand", "Prims.op_GreaterThan", "Prims.op_GreaterThanOrEqual", "Vale.Arch.TypesNative.lemma_iand_pow2_64", "Vale.X64.InsBasic.va_quick_And64", "Vale.X64.QuickCodes.va_QLemma", "FStar.Pervasives.normalize", "Prims.squash", "Vale.Lib.Basic.assert_normalize", "Vale.X64.InsBasic.va_quick_Shr64", "Prims.op_LessThanOrEqual", "Vale.Def.Types_s.ishr", "Prims.op_Subtraction", "Vale.Arch.TypesNative.lemma_ishr_pow2_diff64", "Vale.Arch.TypesNative.lemma_ishr_zero64", "Prims.l_iff", "Prims.op_Negation", "Prims.op_Equality", "Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64", "Vale.X64.QuickCodes.va_QEmpty", "Vale.Def.Words_s.nat64", "Vale.X64.Decls.va_get_reg64", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.va_quickCode", "Vale.Lib.X64.Cpuid.va_code_Check_avx_xcr0_support" ]
[]
module Vale.Lib.X64.Cpuid open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s //let pow2_values (u:unit) : Lemma // (pow2 29 == 0x20000000 /\ // pow2 25 == 0x2000000 /\ // pow2 1 == 0x2) // = // assert_norm (pow2 29 == 0x20000000); // assert_norm (0x2000000 == pow2 25); // assert_norm (0x2 == pow2 1); // () open Vale.Lib.Basic //-- Check_aesni_support [@ "opaque_to_smt" va_qattr] let va_code_Check_aesni_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_AES ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_aesni_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_AES ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_aesni_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_aesni_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 42 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 44 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 45 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 46 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_AES ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 47 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 25) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 48 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 49 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 50 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 51 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (33554432 == Prims.pow2 25)) (fun _ -> (fun (p:prop) -> p) (33554432 == Prims.pow2 25)) (fun (_:unit) -> assert_normalize (33554432 == Prims.pow2 25)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 52 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2 == Prims.pow2 1)) (fun _ -> (fun (p:prop) -> p) (2 == Prims.pow2 1)) (fun (_:unit) -> assert_normalize (2 == Prims.pow2 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 54 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 55 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 25) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 56 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 24) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 58 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 59 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 60 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 66 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_aesni_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_aesni_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_aesni_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 34 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 39 column 56 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> aesni_enabled /\ pclmulqdq_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 40 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_aesni_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_aesni_support (va_code_Check_aesni_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sha_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sha_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Sha ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sha_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Sha ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sha_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sha_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 79 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 80 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 81 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sha ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 29) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 83 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (536870912 == Prims.pow2 29)) (fun _ -> (fun (p:prop) -> p) (536870912 == Prims.pow2 29)) (fun (_:unit) -> assert_normalize (536870912 == Prims.pow2 29)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 85 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 87 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sha_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sha_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sha_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 69 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 74 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sha_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 75 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sha_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sha_support (va_code_Check_sha_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_adx_bmi2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_adx_bmi2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Adx_Bmi2 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_adx_bmi2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Adx_Bmi2 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_adx_bmi2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_adx_bmi2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 98 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 100 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 101 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 102 column 19 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Adx_Bmi2 ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 103 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 8) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 104 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 107 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 109 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (256 == Prims.pow2 8)) (fun _ -> (fun (p:prop) -> p) (256 == Prims.pow2 8)) (fun (_:unit) -> assert_normalize (256 == Prims.pow2 8)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 110 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 112 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 113 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 8 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 114 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 11) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 116 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 117 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 8) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 118 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 120 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_adx_bmi2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_adx_bmi2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_adx_bmi2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 90 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 95 column 49 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> adx_enabled /\ bmi2_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 96 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_adx_bmi2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_adx_bmi2_support (va_code_Check_adx_bmi2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Avx ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Avx ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 131 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 133 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 134 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 135 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 136 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 25) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 137 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 138 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 139 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (268435456 == Prims.pow2 28)) (fun _ -> (fun (p:prop) -> p) (268435456 == Prims.pow2 28)) (fun (_:unit) -> assert_normalize (268435456 == Prims.pow2 28)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 141 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 142 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 28) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 143 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 27) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 123 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 128 column 39 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 129 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx_support (va_code_Check_avx_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Avx2 ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Avx2 ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 156 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 158 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 160 column 15 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx2 ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 161 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 5) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 162 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 163 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (32 == Prims.pow2 5)) (fun _ -> (fun (p:prop) -> p) (32 == Prims.pow2 5)) (fun (_:unit) -> assert_normalize (32 == Prims.pow2 5)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 164 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 166 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 148 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 153 column 40 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx2_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 154 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx2_support (va_code_Check_avx2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_movbe_support [@ "opaque_to_smt" va_qattr] let va_code_Check_movbe_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Movbe ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_movbe_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Movbe ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_movbe_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_movbe_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 177 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 179 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 180 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 181 column 16 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Movbe ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 182 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 22) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 183 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 184 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 185 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (4194304 == Prims.pow2 22)) (fun _ -> (fun (p:prop) -> p) (4194304 == Prims.pow2 22)) (fun (_:unit) -> assert_normalize (4194304 == Prims.pow2 22)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 187 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 22) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 189 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 21) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 191 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_movbe_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_movbe_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_movbe_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 169 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 174 column 35 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> movbe_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 175 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_movbe_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_movbe_support (va_code_Check_movbe_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sse_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sse_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Sse ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sse_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Sse ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sse_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sse_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 202 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 204 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 205 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 206 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sse ()) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 209 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (fun (va_s:va_state) _ -> let (va_arg35:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 211 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg35 9) (let (va_arg34:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg34 26) (let (va_arg33:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg33 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 215 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 216 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 217 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 219 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (512 == Prims.pow2 9)) (fun _ -> (fun (p:prop) -> p) (512 == Prims.pow2 9)) (fun (_:unit) -> assert_normalize (512 == Prims.pow2 9)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 220 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 221 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (67108864 == Prims.pow2 26)) (fun _ -> (fun (p:prop) -> p) (67108864 == Prims.pow2 26)) (fun (_:unit) -> assert_normalize (67108864 == Prims.pow2 26)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 223 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 224 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 10) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 227 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 228 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 26) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 17) (let (va_arg32:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg31:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 231 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg31 va_arg32 9) (let (va_arg30:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg30 9) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 233 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (fun (va_s:va_state) _ -> let (va_arg29:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg28:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 234 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg28 va_arg29 9) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 235 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 237 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sse_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sse_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sse_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 194 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 199 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 200 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sse_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sse_support (va_code_Check_sse_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_rdrand_support [@ "opaque_to_smt" va_qattr] let va_code_Check_rdrand_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Rdrand ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_rdrand_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Rdrand ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_rdrand_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_rdrand_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 248 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 250 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 251 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 252 column 17 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Rdrand ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 253 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 30) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 254 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 255 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 256 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (1073741824 == Prims.pow2 30)) (fun _ -> (fun (p:prop) -> p) (1073741824 == Prims.pow2 30)) (fun (_:unit) -> assert_normalize (1073741824 == Prims.pow2 30)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 258 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 259 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 30) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 260 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 29) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 262 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_rdrand_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_rdrand_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_rdrand_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 240 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 245 column 36 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> rdrand_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 246 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_rdrand_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_rdrand_support (va_code_Check_rdrand_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx512_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx512_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Avx512 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 131072)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 14)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 2147483648)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rR11) (va_const_shift_amt64 15)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx512_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Avx512 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 131072)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 14)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 2147483648)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rR11) (va_const_shift_amt64 15)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx512_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx512_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 273 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx512 ()) (fun (va_s:va_state) _ -> let (va_arg49:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 278 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg49 16) (let (va_arg48:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 279 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg48 17) (let (va_arg47:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 280 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg47 30) (let (va_arg46:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 281 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg46 31) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 284 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 285 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 286 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 288 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 289 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 131072)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 290 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 292 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (65536 == Prims.pow2 16)) (fun _ -> (fun (p:prop) -> p) (65536 == Prims.pow2 16)) (fun (_:unit) -> assert_normalize (65536 == Prims.pow2 16)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 293 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (131072 == Prims.pow2 17)) (fun _ -> (fun (p:prop) -> p) (131072 == Prims.pow2 17)) (fun (_:unit) -> assert_normalize (131072 == Prims.pow2 17)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 294 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (1073741824 == Prims.pow2 30)) (fun _ -> (fun (p:prop) -> p) (1073741824 == Prims.pow2 30)) (fun (_:unit) -> assert_normalize (1073741824 == Prims.pow2 30)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 295 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2147483648 == Prims.pow2 31)) (fun _ -> (fun (p:prop) -> p) (2147483648 == Prims.pow2 31)) (fun (_:unit) -> assert_normalize (2147483648 == Prims.pow2 31)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 297 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 298 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 17) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 299 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 1) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 301 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 14)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 302 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 30) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 303 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 14) (let (va_arg45:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg44:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 305 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg44 va_arg45 16) (let (va_arg43:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 306 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg43 16) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 307 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 310 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 2147483648)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 311 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 312 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rR11) (va_const_shift_amt64 15)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 313 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 31) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 314 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 15) (let (va_arg42:Vale.Def.Types_s.nat64) = va_get_reg64 rR10 va_s in let (va_arg41:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 316 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg41 va_arg42 16) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 317 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (fun (va_s:va_state) _ -> let (va_arg40:Vale.Def.Types_s.nat64) = va_get_reg64 rR11 va_s in let (va_arg39:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 318 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg39 va_arg40 16) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 319 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 321 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))))))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx512_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx512_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx512_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 265 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 270 column 42 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx512_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 271 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx512_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx512_support (va_code_Check_avx512_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; 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) //-- //-- Check_osxsave_support [@ "opaque_to_smt" va_qattr] let va_code_Check_osxsave_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Osxsave ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 134217728)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 26)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_osxsave_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Osxsave ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 134217728)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 26)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_osxsave_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_osxsave_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 332 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 334 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 335 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 336 column 18 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Osxsave ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 337 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 27) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 338 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 339 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 134217728)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 340 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (134217728 == Prims.pow2 27)) (fun _ -> (fun (p:prop) -> p) (134217728 == Prims.pow2 27)) (fun (_:unit) -> assert_normalize (134217728 == Prims.pow2 27)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 342 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 26)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 343 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 27) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 344 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 26) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 346 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_osxsave_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_osxsave_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_osxsave_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 324 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 329 column 37 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> osxsave_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 330 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_osxsave_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_osxsave_support (va_code_Check_osxsave_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx_xcr0_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx_xcr0_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Xgetbv_Avx ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx_xcr0_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Xgetbv_Avx ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx_xcr0_support (va_mods:va_mods_t) : (va_quickCode unit
false
false
Vale.Lib.X64.Cpuid.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_qcode_Check_avx_xcr0_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_avx_xcr0_support ()))
[]
Vale.Lib.X64.Cpuid.va_qcode_Check_avx_xcr0_support
{ "file_name": "obj/Vale.Lib.X64.Cpuid.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_mods: Vale.X64.QuickCode.va_mods_t -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.Lib.X64.Cpuid.va_code_Check_avx_xcr0_support ())
{ "end_col": 24, "end_line": 1151, "start_col": 2, "start_line": 1113 }
Prims.Tot
val va_qcode_Check_adx_bmi2_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_adx_bmi2_support ()))
[ { "abbrev": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.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_qcode_Check_adx_bmi2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_adx_bmi2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 98 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 100 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 101 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 102 column 19 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Adx_Bmi2 ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 103 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 8) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 104 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 107 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 109 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (256 == Prims.pow2 8)) (fun _ -> (fun (p:prop) -> p) (256 == Prims.pow2 8)) (fun (_:unit) -> assert_normalize (256 == Prims.pow2 8)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 110 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 112 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 113 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 8 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 114 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 11) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 116 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 117 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 8) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 118 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 120 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))))))))
val va_qcode_Check_adx_bmi2_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_adx_bmi2_support ())) let va_qcode_Check_adx_bmi2_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_adx_bmi2_support ())) =
false
null
false
(qblock va_mods (fun (va_s: va_state) -> let va_old_s:va_state = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 98 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 100 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 101 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 102 column 19 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Adx_Bmi2 ()) (fun (va_s: va_state) _ -> let va_arg22:Vale.Def.Types_s.nat64 = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 103 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 8) (let va_arg21:Vale.Def.Types_s.nat64 = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 104 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 107 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (fun (va_s: va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 109 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p: prop) -> normalize p) (256 == Prims.pow2 8)) (fun _ -> (fun (p: prop) -> p) (256 == Prims.pow2 8)) (fun (_: unit) -> assert_normalize (256 == Prims.pow2 8)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 110 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p: prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p: prop) -> p) (524288 == Prims.pow2 19) ) (fun (_: unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 112 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (fun (va_s: va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 113 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 8 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 114 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 11) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 116 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (fun (va_s: va_state) _ -> let va_arg20:Vale.Def.Types_s.nat64 = va_get_reg64 rRbx va_s in let va_arg19:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 117 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 8) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 118 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 120 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))) ))))))))))))))))
{ "checked_file": "Vale.Lib.X64.Cpuid.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.X64.Cpuid.fst" }
[ "total" ]
[ "Vale.X64.QuickCode.va_mods_t", "Vale.X64.QuickCodes.qblock", "Prims.unit", "Prims.Cons", "Vale.X64.Decls.va_code", "Vale.X64.InsBasic.va_code_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rR9", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRax", "Vale.X64.Decls.va_const_opr64", "Vale.X64.Machine_s.rRcx", "Vale.X64.InsBasic.va_code_Cpuid_Adx_Bmi2", "Vale.X64.InsBasic.va_code_And64", "Vale.X64.InsBasic.va_code_Shr64", "Vale.X64.Decls.va_const_shift_amt64", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_QSeq", "Vale.X64.QuickCodes.va_range1", "Vale.X64.InsBasic.va_quick_Mov64", "Vale.X64.QuickCodes.va_QBind", "Vale.X64.InsBasic.va_quick_Cpuid_Adx_Bmi2", "Vale.X64.QuickCodes.va_qPURE", "Prims.pure_post", "Prims.l_and", "Prims.l_True", "Prims.l_Forall", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.l_or", "Prims.eq2", "Prims.int", "Vale.Def.Types_s.iand", "Prims.op_GreaterThan", "Prims.op_GreaterThanOrEqual", "Vale.Arch.TypesNative.lemma_iand_pow2_64", "Vale.X64.InsBasic.va_quick_And64", "Vale.X64.QuickCodes.va_QLemma", "FStar.Pervasives.normalize", "Prims.squash", "Vale.Lib.Basic.assert_normalize", "Vale.X64.InsBasic.va_quick_Shr64", "Prims.op_LessThanOrEqual", "Vale.Def.Types_s.ishr", "Prims.op_Subtraction", "Vale.Arch.TypesNative.lemma_ishr_pow2_diff64", "Vale.Arch.TypesNative.lemma_ishr_zero64", "Prims.l_iff", "Prims.op_Negation", "Prims.op_Equality", "Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64", "Vale.X64.QuickCodes.va_QEmpty", "Vale.Def.Words_s.nat64", "Vale.X64.Decls.va_get_reg64", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.va_quickCode", "Vale.Lib.X64.Cpuid.va_code_Check_adx_bmi2_support" ]
[]
module Vale.Lib.X64.Cpuid open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s //let pow2_values (u:unit) : Lemma // (pow2 29 == 0x20000000 /\ // pow2 25 == 0x2000000 /\ // pow2 1 == 0x2) // = // assert_norm (pow2 29 == 0x20000000); // assert_norm (0x2000000 == pow2 25); // assert_norm (0x2 == pow2 1); // () open Vale.Lib.Basic //-- Check_aesni_support [@ "opaque_to_smt" va_qattr] let va_code_Check_aesni_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_AES ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_aesni_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_AES ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_aesni_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_aesni_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 42 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 44 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 45 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 46 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_AES ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 47 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 25) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 48 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 49 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 50 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 51 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (33554432 == Prims.pow2 25)) (fun _ -> (fun (p:prop) -> p) (33554432 == Prims.pow2 25)) (fun (_:unit) -> assert_normalize (33554432 == Prims.pow2 25)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 52 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2 == Prims.pow2 1)) (fun _ -> (fun (p:prop) -> p) (2 == Prims.pow2 1)) (fun (_:unit) -> assert_normalize (2 == Prims.pow2 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 54 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 55 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 25) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 56 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 24) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 58 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 59 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 60 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 66 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_aesni_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_aesni_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_aesni_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 34 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 39 column 56 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> aesni_enabled /\ pclmulqdq_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 40 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_aesni_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_aesni_support (va_code_Check_aesni_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sha_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sha_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Sha ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sha_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Sha ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sha_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sha_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 79 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 80 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 81 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sha ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 29) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 83 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (536870912 == Prims.pow2 29)) (fun _ -> (fun (p:prop) -> p) (536870912 == Prims.pow2 29)) (fun (_:unit) -> assert_normalize (536870912 == Prims.pow2 29)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 85 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 87 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sha_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sha_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sha_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 69 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 74 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sha_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 75 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sha_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sha_support (va_code_Check_sha_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_adx_bmi2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_adx_bmi2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Adx_Bmi2 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_adx_bmi2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Adx_Bmi2 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_adx_bmi2_support (va_mods:va_mods_t) : (va_quickCode unit
false
false
Vale.Lib.X64.Cpuid.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_qcode_Check_adx_bmi2_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_adx_bmi2_support ()))
[]
Vale.Lib.X64.Cpuid.va_qcode_Check_adx_bmi2_support
{ "file_name": "obj/Vale.Lib.X64.Cpuid.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_mods: Vale.X64.QuickCode.va_mods_t -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.Lib.X64.Cpuid.va_code_Check_adx_bmi2_support ())
{ "end_col": 27, "end_line": 288, "start_col": 2, "start_line": 243 }
Prims.Tot
val va_qcode_Check_avx512_xcr0_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_avx512_xcr0_support ()))
[ { "abbrev": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.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_qcode_Check_avx512_xcr0_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx512_xcr0_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 389 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 390 column 18 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Xgetbv_Avx512 ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 392 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 393 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRax)) (fun (va_s:va_state) _ -> let (va_arg33:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 395 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg33 5) (let (va_arg32:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 396 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg32 6) (let (va_arg31:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 397 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg31 7) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 399 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 32)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 400 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 64)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 401 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 128)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 403 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (32 == Prims.pow2 5)) (fun _ -> (fun (p:prop) -> p) (32 == Prims.pow2 5)) (fun (_:unit) -> assert_normalize (32 == Prims.pow2 5)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 404 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (64 == Prims.pow2 6)) (fun _ -> (fun (p:prop) -> p) (64 == Prims.pow2 6)) (fun (_:unit) -> assert_normalize (64 == Prims.pow2 6)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 405 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (128 == Prims.pow2 7)) (fun _ -> (fun (p:prop) -> p) (128 == Prims.pow2 7)) (fun (_:unit) -> assert_normalize (128 == Prims.pow2 7)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 407 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 2)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 408 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 5 7) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 409 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 2) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 411 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRcx) (va_const_shift_amt64 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 412 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 5 6) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 413 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 1) (let (va_arg30:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg29:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 415 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg29 va_arg30 5) (let (va_arg28:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 416 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg28 5) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 417 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (fun (va_s:va_state) _ -> let (va_arg27:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg26:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 418 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg26 va_arg27 5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 419 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QEmpty (())))))))))))))))))))))))))))
val va_qcode_Check_avx512_xcr0_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_avx512_xcr0_support ())) let va_qcode_Check_avx512_xcr0_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_avx512_xcr0_support ())) =
false
null
false
(qblock va_mods (fun (va_s: va_state) -> let va_old_s:va_state = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 389 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 390 column 18 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Xgetbv_Avx512 ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 392 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 393 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRax)) (fun (va_s: va_state) _ -> let va_arg33:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 395 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg33 5) (let va_arg32:Vale.Def.Types_s.nat64 = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 396 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg32 6) (let va_arg31:Vale.Def.Types_s.nat64 = va_get_reg64 rRdx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 397 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg31 7) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 399 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 32)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 400 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 64)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 401 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 128)) (fun (va_s: va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 403 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p: prop) -> normalize p) (32 == Prims.pow2 5)) (fun _ -> (fun (p: prop) -> p) (32 == Prims.pow2 5)) (fun (_: unit) -> assert_normalize (32 == Prims.pow2 5)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 404 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p: prop) -> normalize p) (64 == Prims.pow2 6)) (fun _ -> (fun (p: prop) -> p) (64 == Prims.pow2 6)) (fun (_: unit) -> assert_normalize (64 == Prims.pow2 6)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 405 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p: prop) -> normalize p) (128 == Prims.pow2 7)) (fun _ -> (fun (p: prop) -> p) (128 == Prims.pow2 7)) (fun (_: unit) -> assert_normalize (128 == Prims.pow2 7)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 407 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 2)) (fun (va_s: va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 408 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 5 7) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 409 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 2) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 411 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRcx) (va_const_shift_amt64 1)) (fun (va_s: va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 412 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 5 6) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 413 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit ) -> Vale.Arch.TypesNative.lemma_ishr_zero64 1) (let va_arg30:Vale.Def.Types_s.nat64 = va_get_reg64 rRdx va_s in let va_arg29:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 415 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit ) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg29 va_arg30 5 ) (let va_arg28:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 416 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun ( _: unit ) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg28 5 ) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 417 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( va_quick_And64 ( va_op_dst_opr64_reg64 rRax ) ( va_op_opr64_reg64 rRdx ) ) ( fun ( va_s: va_state ) _ -> let va_arg27:Vale.Def.Types_s.nat64 = va_get_reg64 rRcx va_s in let va_arg26:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 418 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( fun ( _: unit ) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg26 va_arg27 5 ) ( va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 419 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( va_quick_And64 ( va_op_dst_opr64_reg64 rRax ) ( va_op_opr64_reg64 rRcx ) ) ( va_QEmpty ( () ) ) ) ) )) )))))))))) )))))))))))
{ "checked_file": "Vale.Lib.X64.Cpuid.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.X64.Cpuid.fst" }
[ "total" ]
[ "Vale.X64.QuickCode.va_mods_t", "Vale.X64.QuickCodes.qblock", "Prims.unit", "Prims.Cons", "Vale.X64.Decls.va_code", "Vale.X64.InsBasic.va_code_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rRcx", "Vale.X64.Decls.va_const_opr64", "Vale.X64.InsBasic.va_code_Xgetbv_Avx512", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.Machine_s.rRax", "Vale.X64.Machine_s.rRdx", "Vale.X64.InsBasic.va_code_And64", "Vale.X64.InsBasic.va_code_Shr64", "Vale.X64.Decls.va_const_shift_amt64", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_QSeq", "Vale.X64.QuickCodes.va_range1", "Vale.X64.InsBasic.va_quick_Mov64", "Vale.X64.InsBasic.va_quick_Xgetbv_Avx512", "Vale.X64.QuickCodes.va_QBind", "Vale.X64.QuickCodes.va_qPURE", "Prims.pure_post", "Prims.l_and", "Prims.l_True", "Prims.l_Forall", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.l_or", "Prims.eq2", "Prims.int", "Vale.Def.Types_s.iand", "Prims.op_GreaterThan", "Prims.op_GreaterThanOrEqual", "Vale.Arch.TypesNative.lemma_iand_pow2_64", "Vale.X64.InsBasic.va_quick_And64", "Vale.X64.QuickCodes.va_QLemma", "FStar.Pervasives.normalize", "Prims.squash", "Vale.Lib.Basic.assert_normalize", "Vale.X64.InsBasic.va_quick_Shr64", "Prims.op_LessThanOrEqual", "Vale.Def.Types_s.ishr", "Prims.op_Subtraction", "Vale.Arch.TypesNative.lemma_ishr_pow2_diff64", "Vale.Arch.TypesNative.lemma_ishr_zero64", "Prims.l_iff", "Prims.op_Negation", "Prims.op_Equality", "Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64", "Vale.X64.QuickCodes.va_QEmpty", "Vale.Def.Words_s.nat64", "Vale.X64.Decls.va_get_reg64", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.va_quickCode", "Vale.Lib.X64.Cpuid.va_code_Check_avx512_xcr0_support" ]
[]
module Vale.Lib.X64.Cpuid open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s //let pow2_values (u:unit) : Lemma // (pow2 29 == 0x20000000 /\ // pow2 25 == 0x2000000 /\ // pow2 1 == 0x2) // = // assert_norm (pow2 29 == 0x20000000); // assert_norm (0x2000000 == pow2 25); // assert_norm (0x2 == pow2 1); // () open Vale.Lib.Basic //-- Check_aesni_support [@ "opaque_to_smt" va_qattr] let va_code_Check_aesni_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_AES ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_aesni_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_AES ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_aesni_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_aesni_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 42 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 44 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 45 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 46 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_AES ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 47 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 25) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 48 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 49 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 50 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 51 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (33554432 == Prims.pow2 25)) (fun _ -> (fun (p:prop) -> p) (33554432 == Prims.pow2 25)) (fun (_:unit) -> assert_normalize (33554432 == Prims.pow2 25)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 52 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2 == Prims.pow2 1)) (fun _ -> (fun (p:prop) -> p) (2 == Prims.pow2 1)) (fun (_:unit) -> assert_normalize (2 == Prims.pow2 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 54 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 55 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 25) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 56 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 24) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 58 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 59 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 60 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 66 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_aesni_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_aesni_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_aesni_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 34 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 39 column 56 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> aesni_enabled /\ pclmulqdq_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 40 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_aesni_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_aesni_support (va_code_Check_aesni_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sha_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sha_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Sha ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sha_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Sha ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sha_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sha_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 79 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 80 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 81 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sha ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 29) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 83 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (536870912 == Prims.pow2 29)) (fun _ -> (fun (p:prop) -> p) (536870912 == Prims.pow2 29)) (fun (_:unit) -> assert_normalize (536870912 == Prims.pow2 29)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 85 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 87 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sha_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sha_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sha_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 69 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 74 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sha_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 75 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sha_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sha_support (va_code_Check_sha_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_adx_bmi2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_adx_bmi2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Adx_Bmi2 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_adx_bmi2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Adx_Bmi2 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_adx_bmi2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_adx_bmi2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 98 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 100 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 101 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 102 column 19 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Adx_Bmi2 ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 103 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 8) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 104 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 107 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 109 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (256 == Prims.pow2 8)) (fun _ -> (fun (p:prop) -> p) (256 == Prims.pow2 8)) (fun (_:unit) -> assert_normalize (256 == Prims.pow2 8)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 110 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 112 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 113 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 8 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 114 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 11) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 116 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 117 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 8) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 118 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 120 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_adx_bmi2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_adx_bmi2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_adx_bmi2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 90 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 95 column 49 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> adx_enabled /\ bmi2_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 96 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_adx_bmi2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_adx_bmi2_support (va_code_Check_adx_bmi2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Avx ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Avx ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 131 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 133 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 134 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 135 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 136 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 25) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 137 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 138 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 139 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (268435456 == Prims.pow2 28)) (fun _ -> (fun (p:prop) -> p) (268435456 == Prims.pow2 28)) (fun (_:unit) -> assert_normalize (268435456 == Prims.pow2 28)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 141 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 142 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 28) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 143 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 27) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 123 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 128 column 39 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 129 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx_support (va_code_Check_avx_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Avx2 ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Avx2 ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 156 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 158 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 160 column 15 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx2 ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 161 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 5) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 162 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 163 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (32 == Prims.pow2 5)) (fun _ -> (fun (p:prop) -> p) (32 == Prims.pow2 5)) (fun (_:unit) -> assert_normalize (32 == Prims.pow2 5)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 164 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 166 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 148 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 153 column 40 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx2_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 154 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx2_support (va_code_Check_avx2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_movbe_support [@ "opaque_to_smt" va_qattr] let va_code_Check_movbe_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Movbe ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_movbe_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Movbe ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_movbe_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_movbe_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 177 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 179 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 180 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 181 column 16 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Movbe ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 182 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 22) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 183 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 184 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 185 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (4194304 == Prims.pow2 22)) (fun _ -> (fun (p:prop) -> p) (4194304 == Prims.pow2 22)) (fun (_:unit) -> assert_normalize (4194304 == Prims.pow2 22)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 187 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 22) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 189 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 21) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 191 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_movbe_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_movbe_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_movbe_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 169 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 174 column 35 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> movbe_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 175 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_movbe_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_movbe_support (va_code_Check_movbe_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sse_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sse_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Sse ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sse_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Sse ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sse_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sse_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 202 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 204 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 205 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 206 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sse ()) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 209 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (fun (va_s:va_state) _ -> let (va_arg35:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 211 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg35 9) (let (va_arg34:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg34 26) (let (va_arg33:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg33 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 215 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 216 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 217 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 219 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (512 == Prims.pow2 9)) (fun _ -> (fun (p:prop) -> p) (512 == Prims.pow2 9)) (fun (_:unit) -> assert_normalize (512 == Prims.pow2 9)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 220 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 221 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (67108864 == Prims.pow2 26)) (fun _ -> (fun (p:prop) -> p) (67108864 == Prims.pow2 26)) (fun (_:unit) -> assert_normalize (67108864 == Prims.pow2 26)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 223 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 224 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 10) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 227 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 228 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 26) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 17) (let (va_arg32:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg31:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 231 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg31 va_arg32 9) (let (va_arg30:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg30 9) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 233 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (fun (va_s:va_state) _ -> let (va_arg29:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg28:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 234 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg28 va_arg29 9) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 235 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 237 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sse_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sse_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sse_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 194 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 199 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 200 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sse_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sse_support (va_code_Check_sse_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_rdrand_support [@ "opaque_to_smt" va_qattr] let va_code_Check_rdrand_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Rdrand ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_rdrand_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Rdrand ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_rdrand_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_rdrand_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 248 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 250 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 251 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 252 column 17 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Rdrand ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 253 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 30) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 254 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 255 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 256 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (1073741824 == Prims.pow2 30)) (fun _ -> (fun (p:prop) -> p) (1073741824 == Prims.pow2 30)) (fun (_:unit) -> assert_normalize (1073741824 == Prims.pow2 30)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 258 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 259 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 30) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 260 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 29) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 262 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_rdrand_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_rdrand_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_rdrand_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 240 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 245 column 36 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> rdrand_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 246 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_rdrand_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_rdrand_support (va_code_Check_rdrand_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx512_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx512_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Avx512 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 131072)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 14)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 2147483648)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rR11) (va_const_shift_amt64 15)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx512_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Avx512 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 131072)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 14)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 2147483648)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rR11) (va_const_shift_amt64 15)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx512_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx512_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 273 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx512 ()) (fun (va_s:va_state) _ -> let (va_arg49:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 278 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg49 16) (let (va_arg48:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 279 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg48 17) (let (va_arg47:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 280 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg47 30) (let (va_arg46:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 281 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg46 31) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 284 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 285 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 286 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 288 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 289 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 131072)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 290 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 292 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (65536 == Prims.pow2 16)) (fun _ -> (fun (p:prop) -> p) (65536 == Prims.pow2 16)) (fun (_:unit) -> assert_normalize (65536 == Prims.pow2 16)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 293 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (131072 == Prims.pow2 17)) (fun _ -> (fun (p:prop) -> p) (131072 == Prims.pow2 17)) (fun (_:unit) -> assert_normalize (131072 == Prims.pow2 17)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 294 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (1073741824 == Prims.pow2 30)) (fun _ -> (fun (p:prop) -> p) (1073741824 == Prims.pow2 30)) (fun (_:unit) -> assert_normalize (1073741824 == Prims.pow2 30)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 295 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2147483648 == Prims.pow2 31)) (fun _ -> (fun (p:prop) -> p) (2147483648 == Prims.pow2 31)) (fun (_:unit) -> assert_normalize (2147483648 == Prims.pow2 31)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 297 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 298 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 17) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 299 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 1) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 301 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 14)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 302 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 30) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 303 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 14) (let (va_arg45:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg44:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 305 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg44 va_arg45 16) (let (va_arg43:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 306 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg43 16) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 307 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 310 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 2147483648)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 311 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 312 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rR11) (va_const_shift_amt64 15)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 313 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 31) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 314 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 15) (let (va_arg42:Vale.Def.Types_s.nat64) = va_get_reg64 rR10 va_s in let (va_arg41:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 316 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg41 va_arg42 16) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 317 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (fun (va_s:va_state) _ -> let (va_arg40:Vale.Def.Types_s.nat64) = va_get_reg64 rR11 va_s in let (va_arg39:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 318 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg39 va_arg40 16) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 319 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 321 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))))))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx512_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx512_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx512_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 265 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 270 column 42 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx512_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 271 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx512_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx512_support (va_code_Check_avx512_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; 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) //-- //-- Check_osxsave_support [@ "opaque_to_smt" va_qattr] let va_code_Check_osxsave_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Osxsave ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 134217728)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 26)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_osxsave_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Osxsave ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 134217728)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 26)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_osxsave_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_osxsave_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 332 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 334 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 335 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 336 column 18 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Osxsave ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 337 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 27) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 338 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 339 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 134217728)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 340 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (134217728 == Prims.pow2 27)) (fun _ -> (fun (p:prop) -> p) (134217728 == Prims.pow2 27)) (fun (_:unit) -> assert_normalize (134217728 == Prims.pow2 27)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 342 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 26)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 343 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 27) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 344 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 26) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 346 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_osxsave_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_osxsave_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_osxsave_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 324 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 329 column 37 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> osxsave_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 330 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_osxsave_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_osxsave_support (va_code_Check_osxsave_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx_xcr0_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx_xcr0_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Xgetbv_Avx ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx_xcr0_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Xgetbv_Avx ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx_xcr0_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx_xcr0_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 358 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 359 column 15 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Xgetbv_Avx ()) (fun (va_s:va_state) _ -> let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 360 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg19 1) (let (va_arg18:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 361 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg18 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 362 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 364 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 366 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2 == Prims.pow2 1)) (fun _ -> (fun (p:prop) -> p) (2 == Prims.pow2 1)) (fun (_:unit) -> assert_normalize (2 == Prims.pow2 1)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 367 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (4 == Prims.pow2 2)) (fun _ -> (fun (p:prop) -> p) (4 == Prims.pow2 2)) (fun (_:unit) -> assert_normalize (4 == Prims.pow2 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 369 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 370 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 2) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 371 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 1) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 373 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (fun (va_s:va_state) _ -> let (va_arg17:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg16:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 374 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg16 va_arg17 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 375 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QEmpty (()))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx_xcr0_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx_xcr0_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx_xcr0_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 349 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 356 column 30 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx_xcr0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx_xcr0_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx_xcr0_support (va_code_Check_avx_xcr0_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRax]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Check_avx512_xcr0_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx512_xcr0_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Xgetbv_Avx512 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 32)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 64)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 128)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 2)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRcx) (va_const_shift_amt64 1)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CNil ()))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx512_xcr0_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Xgetbv_Avx512 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 32)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 64)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 128)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 2)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRcx) (va_const_shift_amt64 1)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_ttrue ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx512_xcr0_support (va_mods:va_mods_t) : (va_quickCode unit
false
false
Vale.Lib.X64.Cpuid.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_qcode_Check_avx512_xcr0_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_avx512_xcr0_support ()))
[]
Vale.Lib.X64.Cpuid.va_qcode_Check_avx512_xcr0_support
{ "file_name": "obj/Vale.Lib.X64.Cpuid.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_mods: Vale.X64.QuickCode.va_mods_t -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.Lib.X64.Cpuid.va_code_Check_avx512_xcr0_support ())
{ "end_col": 34, "end_line": 1278, "start_col": 2, "start_line": 1214 }
Prims.Tot
val va_qcode_Check_sse_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_sse_support ()))
[ { "abbrev": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.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_qcode_Check_sse_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sse_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 202 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 204 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 205 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 206 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sse ()) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 209 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (fun (va_s:va_state) _ -> let (va_arg35:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 211 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg35 9) (let (va_arg34:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg34 26) (let (va_arg33:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg33 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 215 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 216 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 217 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 219 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (512 == Prims.pow2 9)) (fun _ -> (fun (p:prop) -> p) (512 == Prims.pow2 9)) (fun (_:unit) -> assert_normalize (512 == Prims.pow2 9)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 220 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 221 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (67108864 == Prims.pow2 26)) (fun _ -> (fun (p:prop) -> p) (67108864 == Prims.pow2 26)) (fun (_:unit) -> assert_normalize (67108864 == Prims.pow2 26)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 223 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 224 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 10) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 227 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 228 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 26) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 17) (let (va_arg32:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg31:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 231 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg31 va_arg32 9) (let (va_arg30:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg30 9) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 233 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (fun (va_s:va_state) _ -> let (va_arg29:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg28:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 234 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg28 va_arg29 9) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 235 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 237 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))))))))))))
val va_qcode_Check_sse_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_sse_support ())) let va_qcode_Check_sse_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_sse_support ())) =
false
null
false
(qblock va_mods (fun (va_s: va_state) -> let va_old_s:va_state = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 202 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 204 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 205 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 206 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sse ()) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 209 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (fun (va_s: va_state) _ -> let va_arg35:Vale.Def.Types_s.nat64 = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 211 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg35 9) (let va_arg34:Vale.Def.Types_s.nat64 = va_get_reg64 rRdx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg34 26) (let va_arg33:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg33 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 215 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 216 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 217 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (fun (va_s: va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 219 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p: prop) -> normalize p) (512 == Prims.pow2 9)) (fun _ -> (fun (p: prop) -> p) (512 == Prims.pow2 9)) (fun (_: unit) -> assert_normalize (512 == Prims.pow2 9) ) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 220 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p: prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p: prop) -> p) (524288 == Prims.pow2 19)) (fun (_: unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 221 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p: prop) -> normalize p) (67108864 == Prims.pow2 26)) (fun _ -> (fun (p: prop) -> p) (67108864 == Prims.pow2 26)) (fun (_: unit) -> assert_normalize (67108864 == Prims.pow2 26)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 223 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (fun (va_s: va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 224 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 10) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 227 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 ( va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (fun (va_s: va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 228 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit ) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 26) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit ) -> Vale.Arch.TypesNative.lemma_ishr_zero64 17 ) (let va_arg32:Vale.Def.Types_s.nat64 = va_get_reg64 rRdx va_s in let va_arg31:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 231 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun ( _: unit ) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg31 va_arg32 9 ) (let va_arg30:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( fun ( _: unit ) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg30 9 ) ( va_QBind va_range1 "***** PRECONDITION NOT MET AT line 233 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( va_quick_And64 ( va_op_dst_opr64_reg64 rRax ) ( va_op_opr64_reg64 rRdx ) ) ( fun ( va_s: va_state ) _ -> let va_arg29:Vale.Def.Types_s.nat64 = va_get_reg64 rRcx va_s in let va_arg28:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 234 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( fun ( _: unit ) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg28 va_arg29 9 ) ( va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 235 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( va_quick_And64 ( va_op_dst_opr64_reg64 rRax ) ( va_op_opr64_reg64 rRcx ) ) ( va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 237 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( va_quick_Mov64 ( va_op_dst_opr64_reg64 rRbx ) ( va_op_opr64_reg64 rR9 ) ) ( va_QEmpty ( () ) ) ) ) ) ) )) )))))))))) )))))))))))
{ "checked_file": "Vale.Lib.X64.Cpuid.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.X64.Cpuid.fst" }
[ "total" ]
[ "Vale.X64.QuickCode.va_mods_t", "Vale.X64.QuickCodes.qblock", "Prims.unit", "Prims.Cons", "Vale.X64.Decls.va_code", "Vale.X64.InsBasic.va_code_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rR9", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRcx", "Vale.X64.Decls.va_const_opr64", "Vale.X64.Machine_s.rRax", "Vale.X64.InsBasic.va_code_Cpuid_Sse", "Vale.X64.InsBasic.va_code_And64", "Vale.X64.Machine_s.rRdx", "Vale.X64.InsBasic.va_code_Shr64", "Vale.X64.Decls.va_const_shift_amt64", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_QSeq", "Vale.X64.QuickCodes.va_range1", "Vale.X64.InsBasic.va_quick_Mov64", "Vale.X64.InsBasic.va_quick_Cpuid_Sse", "Vale.X64.QuickCodes.va_QBind", "Vale.X64.QuickCodes.va_qPURE", "Prims.pure_post", "Prims.l_and", "Prims.l_True", "Prims.l_Forall", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.l_or", "Prims.eq2", "Prims.int", "Vale.Def.Types_s.iand", "Prims.op_GreaterThan", "Prims.op_GreaterThanOrEqual", "Vale.Arch.TypesNative.lemma_iand_pow2_64", "Vale.X64.InsBasic.va_quick_And64", "Vale.X64.QuickCodes.va_QLemma", "FStar.Pervasives.normalize", "Prims.squash", "Vale.Lib.Basic.assert_normalize", "Vale.X64.InsBasic.va_quick_Shr64", "Prims.op_LessThanOrEqual", "Vale.Def.Types_s.ishr", "Prims.op_Subtraction", "Vale.Arch.TypesNative.lemma_ishr_pow2_diff64", "Vale.Arch.TypesNative.lemma_ishr_zero64", "Prims.l_iff", "Prims.op_Negation", "Prims.op_Equality", "Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64", "Vale.X64.QuickCodes.va_QEmpty", "Vale.Def.Words_s.nat64", "Vale.X64.Decls.va_get_reg64", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.va_quickCode", "Vale.Lib.X64.Cpuid.va_code_Check_sse_support" ]
[]
module Vale.Lib.X64.Cpuid open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s //let pow2_values (u:unit) : Lemma // (pow2 29 == 0x20000000 /\ // pow2 25 == 0x2000000 /\ // pow2 1 == 0x2) // = // assert_norm (pow2 29 == 0x20000000); // assert_norm (0x2000000 == pow2 25); // assert_norm (0x2 == pow2 1); // () open Vale.Lib.Basic //-- Check_aesni_support [@ "opaque_to_smt" va_qattr] let va_code_Check_aesni_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_AES ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_aesni_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_AES ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_aesni_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_aesni_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 42 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 44 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 45 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 46 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_AES ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 47 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 25) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 48 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 49 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 50 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 51 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (33554432 == Prims.pow2 25)) (fun _ -> (fun (p:prop) -> p) (33554432 == Prims.pow2 25)) (fun (_:unit) -> assert_normalize (33554432 == Prims.pow2 25)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 52 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2 == Prims.pow2 1)) (fun _ -> (fun (p:prop) -> p) (2 == Prims.pow2 1)) (fun (_:unit) -> assert_normalize (2 == Prims.pow2 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 54 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 55 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 25) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 56 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 24) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 58 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 59 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 60 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 66 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_aesni_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_aesni_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_aesni_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 34 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 39 column 56 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> aesni_enabled /\ pclmulqdq_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 40 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_aesni_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_aesni_support (va_code_Check_aesni_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sha_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sha_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Sha ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sha_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Sha ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sha_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sha_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 79 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 80 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 81 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sha ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 29) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 83 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (536870912 == Prims.pow2 29)) (fun _ -> (fun (p:prop) -> p) (536870912 == Prims.pow2 29)) (fun (_:unit) -> assert_normalize (536870912 == Prims.pow2 29)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 85 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 87 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sha_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sha_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sha_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 69 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 74 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sha_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 75 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sha_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sha_support (va_code_Check_sha_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_adx_bmi2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_adx_bmi2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Adx_Bmi2 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_adx_bmi2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Adx_Bmi2 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_adx_bmi2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_adx_bmi2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 98 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 100 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 101 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 102 column 19 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Adx_Bmi2 ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 103 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 8) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 104 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 107 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 109 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (256 == Prims.pow2 8)) (fun _ -> (fun (p:prop) -> p) (256 == Prims.pow2 8)) (fun (_:unit) -> assert_normalize (256 == Prims.pow2 8)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 110 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 112 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 113 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 8 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 114 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 11) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 116 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 117 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 8) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 118 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 120 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_adx_bmi2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_adx_bmi2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_adx_bmi2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 90 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 95 column 49 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> adx_enabled /\ bmi2_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 96 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_adx_bmi2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_adx_bmi2_support (va_code_Check_adx_bmi2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Avx ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Avx ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 131 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 133 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 134 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 135 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 136 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 25) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 137 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 138 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 139 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (268435456 == Prims.pow2 28)) (fun _ -> (fun (p:prop) -> p) (268435456 == Prims.pow2 28)) (fun (_:unit) -> assert_normalize (268435456 == Prims.pow2 28)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 141 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 142 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 28) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 143 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 27) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 123 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 128 column 39 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 129 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx_support (va_code_Check_avx_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Avx2 ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Avx2 ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 156 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 158 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 160 column 15 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx2 ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 161 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 5) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 162 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 163 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (32 == Prims.pow2 5)) (fun _ -> (fun (p:prop) -> p) (32 == Prims.pow2 5)) (fun (_:unit) -> assert_normalize (32 == Prims.pow2 5)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 164 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 166 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 148 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 153 column 40 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx2_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 154 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx2_support (va_code_Check_avx2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_movbe_support [@ "opaque_to_smt" va_qattr] let va_code_Check_movbe_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Movbe ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_movbe_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Movbe ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_movbe_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_movbe_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 177 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 179 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 180 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 181 column 16 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Movbe ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 182 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 22) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 183 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 184 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 185 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (4194304 == Prims.pow2 22)) (fun _ -> (fun (p:prop) -> p) (4194304 == Prims.pow2 22)) (fun (_:unit) -> assert_normalize (4194304 == Prims.pow2 22)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 187 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 22) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 189 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 21) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 191 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_movbe_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_movbe_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_movbe_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 169 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 174 column 35 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> movbe_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 175 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_movbe_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_movbe_support (va_code_Check_movbe_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sse_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sse_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Sse ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sse_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Sse ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sse_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sse_support
false
false
Vale.Lib.X64.Cpuid.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_qcode_Check_sse_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_sse_support ()))
[]
Vale.Lib.X64.Cpuid.va_qcode_Check_sse_support
{ "file_name": "obj/Vale.Lib.X64.Cpuid.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_mods: Vale.X64.QuickCode.va_mods_t -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.Lib.X64.Cpuid.va_code_Check_sse_support ())
{ "end_col": 36, "end_line": 688, "start_col": 2, "start_line": 618 }
Prims.Ghost
val va_wpProof_Check_adx_bmi2_support : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Check_adx_bmi2_support va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Check_adx_bmi2_support ()) ([va_Mod_flags; va_Mod_reg64 rR9; 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": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.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_Check_adx_bmi2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_adx_bmi2_support (va_code_Check_adx_bmi2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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_Check_adx_bmi2_support : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Check_adx_bmi2_support va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Check_adx_bmi2_support ()) ([va_Mod_flags; va_Mod_reg64 rR9; 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_Check_adx_bmi2_support va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_Check_adx_bmi2_support (va_code_Check_adx_bmi2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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.Lib.X64.Cpuid.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.X64.Cpuid.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_flags", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR9", "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_flags", "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.Lib.X64.Cpuid.va_lemma_Check_adx_bmi2_support", "Vale.Lib.X64.Cpuid.va_code_Check_adx_bmi2_support" ]
[]
module Vale.Lib.X64.Cpuid open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s //let pow2_values (u:unit) : Lemma // (pow2 29 == 0x20000000 /\ // pow2 25 == 0x2000000 /\ // pow2 1 == 0x2) // = // assert_norm (pow2 29 == 0x20000000); // assert_norm (0x2000000 == pow2 25); // assert_norm (0x2 == pow2 1); // () open Vale.Lib.Basic //-- Check_aesni_support [@ "opaque_to_smt" va_qattr] let va_code_Check_aesni_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_AES ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_aesni_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_AES ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_aesni_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_aesni_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 42 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 44 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 45 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 46 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_AES ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 47 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 25) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 48 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 49 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 50 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 51 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (33554432 == Prims.pow2 25)) (fun _ -> (fun (p:prop) -> p) (33554432 == Prims.pow2 25)) (fun (_:unit) -> assert_normalize (33554432 == Prims.pow2 25)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 52 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2 == Prims.pow2 1)) (fun _ -> (fun (p:prop) -> p) (2 == Prims.pow2 1)) (fun (_:unit) -> assert_normalize (2 == Prims.pow2 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 54 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 55 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 25) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 56 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 24) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 58 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 59 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 60 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 66 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_aesni_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_aesni_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_aesni_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 34 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 39 column 56 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> aesni_enabled /\ pclmulqdq_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 40 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_aesni_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_aesni_support (va_code_Check_aesni_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sha_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sha_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Sha ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sha_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Sha ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sha_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sha_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 79 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 80 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 81 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sha ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 29) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 83 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (536870912 == Prims.pow2 29)) (fun _ -> (fun (p:prop) -> p) (536870912 == Prims.pow2 29)) (fun (_:unit) -> assert_normalize (536870912 == Prims.pow2 29)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 85 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 87 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sha_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sha_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sha_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 69 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 74 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sha_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 75 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sha_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sha_support (va_code_Check_sha_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_adx_bmi2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_adx_bmi2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Adx_Bmi2 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_adx_bmi2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Adx_Bmi2 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_adx_bmi2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_adx_bmi2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 98 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 100 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 101 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 102 column 19 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Adx_Bmi2 ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 103 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 8) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 104 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 107 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 109 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (256 == Prims.pow2 8)) (fun _ -> (fun (p:prop) -> p) (256 == Prims.pow2 8)) (fun (_:unit) -> assert_normalize (256 == Prims.pow2 8)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 110 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 112 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 113 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 8 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 114 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 11) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 116 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 117 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 8) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 118 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 120 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_adx_bmi2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_adx_bmi2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_adx_bmi2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 90 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 95 column 49 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> adx_enabled /\ bmi2_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 96 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
false
false
Vale.Lib.X64.Cpuid.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_Check_adx_bmi2_support : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Check_adx_bmi2_support va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Check_adx_bmi2_support ()) ([va_Mod_flags; va_Mod_reg64 rR9; 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.Lib.X64.Cpuid.va_wpProof_Check_adx_bmi2_support
{ "file_name": "obj/Vale.Lib.X64.Cpuid.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": 319, "start_col": 50, "start_line": 310 }
Prims.Ghost
val va_wpProof_Check_avx_support : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Check_avx_support va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Check_avx_support ()) ([va_Mod_flags; va_Mod_reg64 rR9; 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": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.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_Check_avx_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx_support (va_code_Check_avx_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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_Check_avx_support : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Check_avx_support va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Check_avx_support ()) ([va_Mod_flags; va_Mod_reg64 rR9; 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_Check_avx_support va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_Check_avx_support (va_code_Check_avx_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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.Lib.X64.Cpuid.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.X64.Cpuid.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_flags", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR9", "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_flags", "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.Lib.X64.Cpuid.va_lemma_Check_avx_support", "Vale.Lib.X64.Cpuid.va_code_Check_avx_support" ]
[]
module Vale.Lib.X64.Cpuid open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s //let pow2_values (u:unit) : Lemma // (pow2 29 == 0x20000000 /\ // pow2 25 == 0x2000000 /\ // pow2 1 == 0x2) // = // assert_norm (pow2 29 == 0x20000000); // assert_norm (0x2000000 == pow2 25); // assert_norm (0x2 == pow2 1); // () open Vale.Lib.Basic //-- Check_aesni_support [@ "opaque_to_smt" va_qattr] let va_code_Check_aesni_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_AES ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_aesni_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_AES ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_aesni_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_aesni_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 42 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 44 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 45 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 46 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_AES ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 47 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 25) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 48 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 49 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 50 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 51 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (33554432 == Prims.pow2 25)) (fun _ -> (fun (p:prop) -> p) (33554432 == Prims.pow2 25)) (fun (_:unit) -> assert_normalize (33554432 == Prims.pow2 25)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 52 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2 == Prims.pow2 1)) (fun _ -> (fun (p:prop) -> p) (2 == Prims.pow2 1)) (fun (_:unit) -> assert_normalize (2 == Prims.pow2 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 54 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 55 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 25) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 56 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 24) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 58 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 59 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 60 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 66 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_aesni_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_aesni_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_aesni_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 34 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 39 column 56 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> aesni_enabled /\ pclmulqdq_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 40 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_aesni_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_aesni_support (va_code_Check_aesni_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sha_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sha_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Sha ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sha_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Sha ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sha_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sha_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 79 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 80 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 81 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sha ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 29) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 83 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (536870912 == Prims.pow2 29)) (fun _ -> (fun (p:prop) -> p) (536870912 == Prims.pow2 29)) (fun (_:unit) -> assert_normalize (536870912 == Prims.pow2 29)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 85 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 87 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sha_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sha_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sha_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 69 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 74 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sha_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 75 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sha_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sha_support (va_code_Check_sha_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_adx_bmi2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_adx_bmi2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Adx_Bmi2 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_adx_bmi2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Adx_Bmi2 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_adx_bmi2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_adx_bmi2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 98 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 100 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 101 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 102 column 19 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Adx_Bmi2 ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 103 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 8) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 104 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 107 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 109 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (256 == Prims.pow2 8)) (fun _ -> (fun (p:prop) -> p) (256 == Prims.pow2 8)) (fun (_:unit) -> assert_normalize (256 == Prims.pow2 8)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 110 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 112 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 113 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 8 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 114 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 11) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 116 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 117 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 8) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 118 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 120 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_adx_bmi2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_adx_bmi2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_adx_bmi2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 90 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 95 column 49 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> adx_enabled /\ bmi2_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 96 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_adx_bmi2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_adx_bmi2_support (va_code_Check_adx_bmi2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Avx ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Avx ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 131 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 133 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 134 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 135 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 136 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 25) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 137 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 138 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 139 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (268435456 == Prims.pow2 28)) (fun _ -> (fun (p:prop) -> p) (268435456 == Prims.pow2 28)) (fun (_:unit) -> assert_normalize (268435456 == Prims.pow2 28)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 141 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 142 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 28) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 143 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 27) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 123 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 128 column 39 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 129 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
false
false
Vale.Lib.X64.Cpuid.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_Check_avx_support : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Check_avx_support va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Check_avx_support ()) ([va_Mod_flags; va_Mod_reg64 rR9; 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.Lib.X64.Cpuid.va_wpProof_Check_avx_support
{ "file_name": "obj/Vale.Lib.X64.Cpuid.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": 410, "start_col": 45, "start_line": 401 }
Prims.Ghost
val va_lemma_Check_adx_bmi2_support : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Check_adx_bmi2_support ()) 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_get_reg64 rRax va_sM =!= 0 ==> adx_enabled /\ bmi2_enabled) /\ va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.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_Check_adx_bmi2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_adx_bmi2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_adx_bmi2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 90 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 95 column 49 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> adx_enabled /\ bmi2_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 96 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
val va_lemma_Check_adx_bmi2_support : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Check_adx_bmi2_support ()) 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_get_reg64 rRax va_sM =!= 0 ==> adx_enabled /\ bmi2_enabled) /\ va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_Check_adx_bmi2_support va_b0 va_s0 =
false
null
false
let va_mods:va_mods_t = [ va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok ] in let va_qc = va_qcode_Check_adx_bmi2_support va_mods in let va_sM, va_fM, va_g = va_wp_sound_code_norm (va_code_Check_adx_bmi2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 90 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 95 column 49 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> adx_enabled /\ bmi2_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 96 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([ va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok ]) va_sM va_s0; (va_sM, va_fM)
{ "checked_file": "Vale.Lib.X64.Cpuid.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.X64.Cpuid.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.fuel", "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR9", "Vale.X64.Machine_s.rRdx", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRax", "Vale.X64.QuickCode.va_Mod_ok", "Prims.Nil", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.Lib.X64.Cpuid.va_code_Check_adx_bmi2_support", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.va_wp_sound_code_norm", "Prims.l_and", "Vale.X64.QuickCodes.label", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Prims.l_imp", "Prims.l_not", "Prims.int", "Vale.X64.Decls.va_get_reg64", "Vale.X64.CPU_Features_s.adx_enabled", "Vale.X64.CPU_Features_s.bmi2_enabled", "Vale.Def.Types_s.nat64", "Vale.X64.QuickCode.quickCode", "Vale.Lib.X64.Cpuid.va_qcode_Check_adx_bmi2_support" ]
[]
module Vale.Lib.X64.Cpuid open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s //let pow2_values (u:unit) : Lemma // (pow2 29 == 0x20000000 /\ // pow2 25 == 0x2000000 /\ // pow2 1 == 0x2) // = // assert_norm (pow2 29 == 0x20000000); // assert_norm (0x2000000 == pow2 25); // assert_norm (0x2 == pow2 1); // () open Vale.Lib.Basic //-- Check_aesni_support [@ "opaque_to_smt" va_qattr] let va_code_Check_aesni_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_AES ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_aesni_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_AES ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_aesni_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_aesni_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 42 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 44 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 45 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 46 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_AES ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 47 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 25) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 48 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 49 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 50 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 51 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (33554432 == Prims.pow2 25)) (fun _ -> (fun (p:prop) -> p) (33554432 == Prims.pow2 25)) (fun (_:unit) -> assert_normalize (33554432 == Prims.pow2 25)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 52 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2 == Prims.pow2 1)) (fun _ -> (fun (p:prop) -> p) (2 == Prims.pow2 1)) (fun (_:unit) -> assert_normalize (2 == Prims.pow2 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 54 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 55 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 25) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 56 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 24) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 58 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 59 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 60 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 66 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_aesni_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_aesni_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_aesni_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 34 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 39 column 56 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> aesni_enabled /\ pclmulqdq_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 40 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_aesni_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_aesni_support (va_code_Check_aesni_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sha_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sha_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Sha ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sha_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Sha ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sha_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sha_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 79 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 80 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 81 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sha ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 29) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 83 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (536870912 == Prims.pow2 29)) (fun _ -> (fun (p:prop) -> p) (536870912 == Prims.pow2 29)) (fun (_:unit) -> assert_normalize (536870912 == Prims.pow2 29)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 85 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 87 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sha_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sha_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sha_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 69 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 74 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sha_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 75 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sha_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sha_support (va_code_Check_sha_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_adx_bmi2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_adx_bmi2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Adx_Bmi2 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_adx_bmi2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Adx_Bmi2 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_adx_bmi2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_adx_bmi2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 98 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 100 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 101 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 102 column 19 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Adx_Bmi2 ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 103 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 8) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 104 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 107 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 109 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (256 == Prims.pow2 8)) (fun _ -> (fun (p:prop) -> p) (256 == Prims.pow2 8)) (fun (_:unit) -> assert_normalize (256 == Prims.pow2 8)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 110 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 112 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 113 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 8 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 114 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 11) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 116 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 117 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 8) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 118 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 120 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))))))))
false
false
Vale.Lib.X64.Cpuid.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_Check_adx_bmi2_support : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Check_adx_bmi2_support ()) 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_get_reg64 rRax va_sM =!= 0 ==> adx_enabled /\ bmi2_enabled) /\ va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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.Lib.X64.Cpuid.va_lemma_Check_adx_bmi2_support
{ "file_name": "obj/Vale.Lib.X64.Cpuid.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": 306, "start_col": 49, "start_line": 291 }
Prims.Ghost
val va_lemma_Check_rdrand_support : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Check_rdrand_support ()) 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_get_reg64 rRax va_sM =!= 0 ==> rdrand_enabled) /\ va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.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_Check_rdrand_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_rdrand_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_rdrand_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 240 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 245 column 36 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> rdrand_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 246 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
val va_lemma_Check_rdrand_support : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Check_rdrand_support ()) 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_get_reg64 rRax va_sM =!= 0 ==> rdrand_enabled) /\ va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_Check_rdrand_support va_b0 va_s0 =
false
null
false
let va_mods:va_mods_t = [ va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok ] in let va_qc = va_qcode_Check_rdrand_support va_mods in let va_sM, va_fM, va_g = va_wp_sound_code_norm (va_code_Check_rdrand_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 240 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 245 column 36 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> rdrand_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 246 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([ va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok ]) va_sM va_s0; (va_sM, va_fM)
{ "checked_file": "Vale.Lib.X64.Cpuid.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.X64.Cpuid.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.fuel", "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR9", "Vale.X64.Machine_s.rRdx", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRax", "Vale.X64.QuickCode.va_Mod_ok", "Prims.Nil", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.Lib.X64.Cpuid.va_code_Check_rdrand_support", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.va_wp_sound_code_norm", "Prims.l_and", "Vale.X64.QuickCodes.label", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Prims.l_imp", "Prims.l_not", "Prims.int", "Vale.X64.Decls.va_get_reg64", "Vale.X64.CPU_Features_s.rdrand_enabled", "Vale.Def.Types_s.nat64", "Vale.X64.QuickCode.quickCode", "Vale.Lib.X64.Cpuid.va_qcode_Check_rdrand_support" ]
[]
module Vale.Lib.X64.Cpuid open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s //let pow2_values (u:unit) : Lemma // (pow2 29 == 0x20000000 /\ // pow2 25 == 0x2000000 /\ // pow2 1 == 0x2) // = // assert_norm (pow2 29 == 0x20000000); // assert_norm (0x2000000 == pow2 25); // assert_norm (0x2 == pow2 1); // () open Vale.Lib.Basic //-- Check_aesni_support [@ "opaque_to_smt" va_qattr] let va_code_Check_aesni_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_AES ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_aesni_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_AES ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_aesni_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_aesni_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 42 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 44 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 45 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 46 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_AES ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 47 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 25) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 48 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 49 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 50 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 51 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (33554432 == Prims.pow2 25)) (fun _ -> (fun (p:prop) -> p) (33554432 == Prims.pow2 25)) (fun (_:unit) -> assert_normalize (33554432 == Prims.pow2 25)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 52 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2 == Prims.pow2 1)) (fun _ -> (fun (p:prop) -> p) (2 == Prims.pow2 1)) (fun (_:unit) -> assert_normalize (2 == Prims.pow2 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 54 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 55 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 25) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 56 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 24) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 58 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 59 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 60 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 66 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_aesni_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_aesni_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_aesni_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 34 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 39 column 56 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> aesni_enabled /\ pclmulqdq_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 40 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_aesni_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_aesni_support (va_code_Check_aesni_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sha_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sha_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Sha ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sha_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Sha ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sha_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sha_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 79 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 80 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 81 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sha ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 29) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 83 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (536870912 == Prims.pow2 29)) (fun _ -> (fun (p:prop) -> p) (536870912 == Prims.pow2 29)) (fun (_:unit) -> assert_normalize (536870912 == Prims.pow2 29)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 85 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 87 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sha_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sha_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sha_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 69 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 74 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sha_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 75 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sha_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sha_support (va_code_Check_sha_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_adx_bmi2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_adx_bmi2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Adx_Bmi2 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_adx_bmi2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Adx_Bmi2 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_adx_bmi2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_adx_bmi2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 98 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 100 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 101 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 102 column 19 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Adx_Bmi2 ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 103 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 8) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 104 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 107 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 109 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (256 == Prims.pow2 8)) (fun _ -> (fun (p:prop) -> p) (256 == Prims.pow2 8)) (fun (_:unit) -> assert_normalize (256 == Prims.pow2 8)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 110 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 112 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 113 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 8 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 114 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 11) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 116 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 117 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 8) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 118 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 120 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_adx_bmi2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_adx_bmi2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_adx_bmi2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 90 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 95 column 49 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> adx_enabled /\ bmi2_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 96 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_adx_bmi2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_adx_bmi2_support (va_code_Check_adx_bmi2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Avx ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Avx ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 131 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 133 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 134 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 135 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 136 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 25) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 137 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 138 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 139 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (268435456 == Prims.pow2 28)) (fun _ -> (fun (p:prop) -> p) (268435456 == Prims.pow2 28)) (fun (_:unit) -> assert_normalize (268435456 == Prims.pow2 28)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 141 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 142 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 28) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 143 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 27) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 123 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 128 column 39 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 129 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx_support (va_code_Check_avx_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Avx2 ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Avx2 ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 156 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 158 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 160 column 15 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx2 ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 161 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 5) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 162 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 163 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (32 == Prims.pow2 5)) (fun _ -> (fun (p:prop) -> p) (32 == Prims.pow2 5)) (fun (_:unit) -> assert_normalize (32 == Prims.pow2 5)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 164 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 166 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 148 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 153 column 40 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx2_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 154 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx2_support (va_code_Check_avx2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_movbe_support [@ "opaque_to_smt" va_qattr] let va_code_Check_movbe_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Movbe ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_movbe_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Movbe ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_movbe_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_movbe_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 177 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 179 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 180 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 181 column 16 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Movbe ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 182 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 22) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 183 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 184 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 185 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (4194304 == Prims.pow2 22)) (fun _ -> (fun (p:prop) -> p) (4194304 == Prims.pow2 22)) (fun (_:unit) -> assert_normalize (4194304 == Prims.pow2 22)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 187 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 22) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 189 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 21) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 191 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_movbe_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_movbe_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_movbe_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 169 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 174 column 35 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> movbe_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 175 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_movbe_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_movbe_support (va_code_Check_movbe_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sse_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sse_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Sse ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sse_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Sse ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sse_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sse_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 202 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 204 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 205 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 206 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sse ()) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 209 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (fun (va_s:va_state) _ -> let (va_arg35:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 211 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg35 9) (let (va_arg34:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg34 26) (let (va_arg33:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg33 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 215 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 216 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 217 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 219 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (512 == Prims.pow2 9)) (fun _ -> (fun (p:prop) -> p) (512 == Prims.pow2 9)) (fun (_:unit) -> assert_normalize (512 == Prims.pow2 9)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 220 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 221 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (67108864 == Prims.pow2 26)) (fun _ -> (fun (p:prop) -> p) (67108864 == Prims.pow2 26)) (fun (_:unit) -> assert_normalize (67108864 == Prims.pow2 26)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 223 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 224 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 10) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 227 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 228 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 26) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 17) (let (va_arg32:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg31:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 231 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg31 va_arg32 9) (let (va_arg30:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg30 9) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 233 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (fun (va_s:va_state) _ -> let (va_arg29:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg28:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 234 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg28 va_arg29 9) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 235 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 237 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sse_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sse_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sse_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 194 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 199 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 200 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sse_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sse_support (va_code_Check_sse_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_rdrand_support [@ "opaque_to_smt" va_qattr] let va_code_Check_rdrand_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Rdrand ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_rdrand_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Rdrand ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_rdrand_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_rdrand_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 248 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 250 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 251 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 252 column 17 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Rdrand ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 253 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 30) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 254 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 255 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 256 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (1073741824 == Prims.pow2 30)) (fun _ -> (fun (p:prop) -> p) (1073741824 == Prims.pow2 30)) (fun (_:unit) -> assert_normalize (1073741824 == Prims.pow2 30)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 258 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 259 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 30) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 260 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 29) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 262 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))
false
false
Vale.Lib.X64.Cpuid.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_Check_rdrand_support : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Check_rdrand_support ()) 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_get_reg64 rRax va_sM =!= 0 ==> rdrand_enabled) /\ va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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.Lib.X64.Cpuid.va_lemma_Check_rdrand_support
{ "file_name": "obj/Vale.Lib.X64.Cpuid.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": 797, "start_col": 47, "start_line": 782 }
Prims.Ghost
val va_lemma_Check_avx_xcr0_support : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Check_avx_xcr0_support ()) va_s0 /\ va_get_ok va_s0 /\ osxsave_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (va_get_reg64 rRax va_sM =!= 0 ==> avx_xcr0) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0)))))))
[ { "abbrev": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.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_Check_avx_xcr0_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx_xcr0_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx_xcr0_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 349 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 356 column 30 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx_xcr0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
val va_lemma_Check_avx_xcr0_support : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Check_avx_xcr0_support ()) va_s0 /\ va_get_ok va_s0 /\ osxsave_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (va_get_reg64 rRax va_sM =!= 0 ==> avx_xcr0) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))) let va_lemma_Check_avx_xcr0_support va_b0 va_s0 =
false
null
false
let va_mods:va_mods_t = [va_Mod_flags; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx_xcr0_support va_mods in let va_sM, va_fM, va_g = va_wp_sound_code_norm (va_code_Check_avx_xcr0_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 349 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 356 column 30 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx_xcr0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([ va_Mod_flags; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok ]) va_sM va_s0; (va_sM, va_fM)
{ "checked_file": "Vale.Lib.X64.Cpuid.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.X64.Cpuid.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.fuel", "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRdx", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rRax", "Vale.X64.QuickCode.va_Mod_ok", "Prims.Nil", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.Lib.X64.Cpuid.va_code_Check_avx_xcr0_support", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.va_wp_sound_code_norm", "Prims.l_and", "Vale.X64.QuickCodes.label", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Prims.l_imp", "Prims.l_not", "Prims.int", "Vale.X64.Decls.va_get_reg64", "Vale.X64.CPU_Features_s.avx_xcr0", "Vale.X64.QuickCode.quickCode", "Vale.Lib.X64.Cpuid.va_qcode_Check_avx_xcr0_support" ]
[]
module Vale.Lib.X64.Cpuid open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s //let pow2_values (u:unit) : Lemma // (pow2 29 == 0x20000000 /\ // pow2 25 == 0x2000000 /\ // pow2 1 == 0x2) // = // assert_norm (pow2 29 == 0x20000000); // assert_norm (0x2000000 == pow2 25); // assert_norm (0x2 == pow2 1); // () open Vale.Lib.Basic //-- Check_aesni_support [@ "opaque_to_smt" va_qattr] let va_code_Check_aesni_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_AES ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_aesni_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_AES ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_aesni_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_aesni_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 42 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 44 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 45 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 46 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_AES ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 47 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 25) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 48 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 49 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 50 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 51 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (33554432 == Prims.pow2 25)) (fun _ -> (fun (p:prop) -> p) (33554432 == Prims.pow2 25)) (fun (_:unit) -> assert_normalize (33554432 == Prims.pow2 25)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 52 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2 == Prims.pow2 1)) (fun _ -> (fun (p:prop) -> p) (2 == Prims.pow2 1)) (fun (_:unit) -> assert_normalize (2 == Prims.pow2 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 54 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 55 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 25) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 56 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 24) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 58 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 59 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 60 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 66 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_aesni_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_aesni_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_aesni_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 34 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 39 column 56 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> aesni_enabled /\ pclmulqdq_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 40 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_aesni_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_aesni_support (va_code_Check_aesni_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sha_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sha_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Sha ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sha_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Sha ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sha_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sha_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 79 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 80 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 81 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sha ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 29) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 83 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (536870912 == Prims.pow2 29)) (fun _ -> (fun (p:prop) -> p) (536870912 == Prims.pow2 29)) (fun (_:unit) -> assert_normalize (536870912 == Prims.pow2 29)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 85 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 87 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sha_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sha_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sha_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 69 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 74 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sha_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 75 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sha_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sha_support (va_code_Check_sha_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_adx_bmi2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_adx_bmi2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Adx_Bmi2 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_adx_bmi2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Adx_Bmi2 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_adx_bmi2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_adx_bmi2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 98 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 100 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 101 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 102 column 19 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Adx_Bmi2 ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 103 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 8) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 104 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 107 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 109 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (256 == Prims.pow2 8)) (fun _ -> (fun (p:prop) -> p) (256 == Prims.pow2 8)) (fun (_:unit) -> assert_normalize (256 == Prims.pow2 8)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 110 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 112 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 113 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 8 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 114 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 11) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 116 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 117 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 8) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 118 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 120 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_adx_bmi2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_adx_bmi2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_adx_bmi2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 90 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 95 column 49 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> adx_enabled /\ bmi2_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 96 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_adx_bmi2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_adx_bmi2_support (va_code_Check_adx_bmi2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Avx ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Avx ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 131 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 133 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 134 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 135 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 136 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 25) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 137 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 138 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 139 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (268435456 == Prims.pow2 28)) (fun _ -> (fun (p:prop) -> p) (268435456 == Prims.pow2 28)) (fun (_:unit) -> assert_normalize (268435456 == Prims.pow2 28)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 141 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 142 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 28) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 143 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 27) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 123 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 128 column 39 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 129 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx_support (va_code_Check_avx_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Avx2 ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Avx2 ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 156 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 158 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 160 column 15 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx2 ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 161 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 5) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 162 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 163 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (32 == Prims.pow2 5)) (fun _ -> (fun (p:prop) -> p) (32 == Prims.pow2 5)) (fun (_:unit) -> assert_normalize (32 == Prims.pow2 5)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 164 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 166 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 148 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 153 column 40 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx2_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 154 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx2_support (va_code_Check_avx2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_movbe_support [@ "opaque_to_smt" va_qattr] let va_code_Check_movbe_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Movbe ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_movbe_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Movbe ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_movbe_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_movbe_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 177 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 179 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 180 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 181 column 16 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Movbe ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 182 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 22) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 183 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 184 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 185 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (4194304 == Prims.pow2 22)) (fun _ -> (fun (p:prop) -> p) (4194304 == Prims.pow2 22)) (fun (_:unit) -> assert_normalize (4194304 == Prims.pow2 22)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 187 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 22) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 189 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 21) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 191 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_movbe_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_movbe_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_movbe_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 169 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 174 column 35 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> movbe_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 175 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_movbe_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_movbe_support (va_code_Check_movbe_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sse_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sse_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Sse ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sse_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Sse ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sse_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sse_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 202 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 204 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 205 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 206 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sse ()) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 209 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (fun (va_s:va_state) _ -> let (va_arg35:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 211 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg35 9) (let (va_arg34:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg34 26) (let (va_arg33:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg33 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 215 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 216 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 217 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 219 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (512 == Prims.pow2 9)) (fun _ -> (fun (p:prop) -> p) (512 == Prims.pow2 9)) (fun (_:unit) -> assert_normalize (512 == Prims.pow2 9)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 220 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 221 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (67108864 == Prims.pow2 26)) (fun _ -> (fun (p:prop) -> p) (67108864 == Prims.pow2 26)) (fun (_:unit) -> assert_normalize (67108864 == Prims.pow2 26)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 223 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 224 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 10) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 227 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 228 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 26) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 17) (let (va_arg32:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg31:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 231 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg31 va_arg32 9) (let (va_arg30:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg30 9) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 233 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (fun (va_s:va_state) _ -> let (va_arg29:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg28:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 234 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg28 va_arg29 9) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 235 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 237 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sse_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sse_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sse_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 194 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 199 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 200 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sse_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sse_support (va_code_Check_sse_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_rdrand_support [@ "opaque_to_smt" va_qattr] let va_code_Check_rdrand_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Rdrand ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_rdrand_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Rdrand ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_rdrand_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_rdrand_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 248 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 250 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 251 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 252 column 17 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Rdrand ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 253 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 30) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 254 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 255 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 256 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (1073741824 == Prims.pow2 30)) (fun _ -> (fun (p:prop) -> p) (1073741824 == Prims.pow2 30)) (fun (_:unit) -> assert_normalize (1073741824 == Prims.pow2 30)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 258 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 259 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 30) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 260 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 29) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 262 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_rdrand_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_rdrand_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_rdrand_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 240 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 245 column 36 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> rdrand_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 246 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_rdrand_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_rdrand_support (va_code_Check_rdrand_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx512_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx512_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Avx512 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 131072)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 14)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 2147483648)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rR11) (va_const_shift_amt64 15)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx512_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Avx512 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 131072)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 14)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 2147483648)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rR11) (va_const_shift_amt64 15)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx512_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx512_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 273 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx512 ()) (fun (va_s:va_state) _ -> let (va_arg49:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 278 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg49 16) (let (va_arg48:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 279 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg48 17) (let (va_arg47:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 280 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg47 30) (let (va_arg46:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 281 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg46 31) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 284 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 285 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 286 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 288 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 289 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 131072)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 290 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 292 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (65536 == Prims.pow2 16)) (fun _ -> (fun (p:prop) -> p) (65536 == Prims.pow2 16)) (fun (_:unit) -> assert_normalize (65536 == Prims.pow2 16)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 293 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (131072 == Prims.pow2 17)) (fun _ -> (fun (p:prop) -> p) (131072 == Prims.pow2 17)) (fun (_:unit) -> assert_normalize (131072 == Prims.pow2 17)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 294 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (1073741824 == Prims.pow2 30)) (fun _ -> (fun (p:prop) -> p) (1073741824 == Prims.pow2 30)) (fun (_:unit) -> assert_normalize (1073741824 == Prims.pow2 30)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 295 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2147483648 == Prims.pow2 31)) (fun _ -> (fun (p:prop) -> p) (2147483648 == Prims.pow2 31)) (fun (_:unit) -> assert_normalize (2147483648 == Prims.pow2 31)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 297 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 298 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 17) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 299 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 1) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 301 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 14)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 302 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 30) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 303 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 14) (let (va_arg45:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg44:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 305 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg44 va_arg45 16) (let (va_arg43:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 306 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg43 16) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 307 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 310 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 2147483648)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 311 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 312 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rR11) (va_const_shift_amt64 15)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 313 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 31) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 314 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 15) (let (va_arg42:Vale.Def.Types_s.nat64) = va_get_reg64 rR10 va_s in let (va_arg41:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 316 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg41 va_arg42 16) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 317 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (fun (va_s:va_state) _ -> let (va_arg40:Vale.Def.Types_s.nat64) = va_get_reg64 rR11 va_s in let (va_arg39:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 318 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg39 va_arg40 16) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 319 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 321 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))))))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx512_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx512_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx512_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 265 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 270 column 42 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx512_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 271 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx512_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx512_support (va_code_Check_avx512_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; 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) //-- //-- Check_osxsave_support [@ "opaque_to_smt" va_qattr] let va_code_Check_osxsave_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Osxsave ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 134217728)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 26)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_osxsave_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Osxsave ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 134217728)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 26)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_osxsave_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_osxsave_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 332 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 334 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 335 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 336 column 18 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Osxsave ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 337 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 27) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 338 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 339 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 134217728)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 340 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (134217728 == Prims.pow2 27)) (fun _ -> (fun (p:prop) -> p) (134217728 == Prims.pow2 27)) (fun (_:unit) -> assert_normalize (134217728 == Prims.pow2 27)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 342 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 26)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 343 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 27) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 344 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 26) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 346 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_osxsave_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_osxsave_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_osxsave_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 324 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 329 column 37 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> osxsave_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 330 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_osxsave_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_osxsave_support (va_code_Check_osxsave_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx_xcr0_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx_xcr0_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Xgetbv_Avx ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx_xcr0_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Xgetbv_Avx ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx_xcr0_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx_xcr0_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 358 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 359 column 15 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Xgetbv_Avx ()) (fun (va_s:va_state) _ -> let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 360 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg19 1) (let (va_arg18:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 361 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg18 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 362 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 364 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 366 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2 == Prims.pow2 1)) (fun _ -> (fun (p:prop) -> p) (2 == Prims.pow2 1)) (fun (_:unit) -> assert_normalize (2 == Prims.pow2 1)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 367 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (4 == Prims.pow2 2)) (fun _ -> (fun (p:prop) -> p) (4 == Prims.pow2 2)) (fun (_:unit) -> assert_normalize (4 == Prims.pow2 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 369 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 370 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 2) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 371 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 1) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 373 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (fun (va_s:va_state) _ -> let (va_arg17:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg16:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 374 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg16 va_arg17 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 375 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QEmpty (())))))))))))))))))
false
false
Vale.Lib.X64.Cpuid.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_Check_avx_xcr0_support : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Check_avx_xcr0_support ()) va_s0 /\ va_get_ok va_s0 /\ osxsave_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (va_get_reg64 rRax va_sM =!= 0 ==> avx_xcr0) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0)))))))
[]
Vale.Lib.X64.Cpuid.va_lemma_Check_avx_xcr0_support
{ "file_name": "obj/Vale.Lib.X64.Cpuid.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": 1167, "start_col": 49, "start_line": 1154 }
Prims.Ghost
val va_lemma_Check_osxsave_support : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Check_osxsave_support ()) 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_get_reg64 rRax va_sM =!= 0 ==> osxsave_enabled) /\ va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.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_Check_osxsave_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_osxsave_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_osxsave_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 324 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 329 column 37 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> osxsave_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 330 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
val va_lemma_Check_osxsave_support : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Check_osxsave_support ()) 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_get_reg64 rRax va_sM =!= 0 ==> osxsave_enabled) /\ va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_Check_osxsave_support va_b0 va_s0 =
false
null
false
let va_mods:va_mods_t = [ va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok ] in let va_qc = va_qcode_Check_osxsave_support va_mods in let va_sM, va_fM, va_g = va_wp_sound_code_norm (va_code_Check_osxsave_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 324 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 329 column 37 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> osxsave_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 330 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([ va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok ]) va_sM va_s0; (va_sM, va_fM)
{ "checked_file": "Vale.Lib.X64.Cpuid.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.X64.Cpuid.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.fuel", "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR9", "Vale.X64.Machine_s.rRdx", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRax", "Vale.X64.QuickCode.va_Mod_ok", "Prims.Nil", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.Lib.X64.Cpuid.va_code_Check_osxsave_support", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.va_wp_sound_code_norm", "Prims.l_and", "Vale.X64.QuickCodes.label", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Prims.l_imp", "Prims.l_not", "Prims.int", "Vale.X64.Decls.va_get_reg64", "Vale.X64.CPU_Features_s.osxsave_enabled", "Vale.Def.Types_s.nat64", "Vale.X64.QuickCode.quickCode", "Vale.Lib.X64.Cpuid.va_qcode_Check_osxsave_support" ]
[]
module Vale.Lib.X64.Cpuid open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s //let pow2_values (u:unit) : Lemma // (pow2 29 == 0x20000000 /\ // pow2 25 == 0x2000000 /\ // pow2 1 == 0x2) // = // assert_norm (pow2 29 == 0x20000000); // assert_norm (0x2000000 == pow2 25); // assert_norm (0x2 == pow2 1); // () open Vale.Lib.Basic //-- Check_aesni_support [@ "opaque_to_smt" va_qattr] let va_code_Check_aesni_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_AES ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_aesni_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_AES ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_aesni_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_aesni_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 42 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 44 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 45 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 46 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_AES ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 47 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 25) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 48 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 49 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 50 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 51 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (33554432 == Prims.pow2 25)) (fun _ -> (fun (p:prop) -> p) (33554432 == Prims.pow2 25)) (fun (_:unit) -> assert_normalize (33554432 == Prims.pow2 25)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 52 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2 == Prims.pow2 1)) (fun _ -> (fun (p:prop) -> p) (2 == Prims.pow2 1)) (fun (_:unit) -> assert_normalize (2 == Prims.pow2 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 54 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 55 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 25) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 56 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 24) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 58 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 59 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 60 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 66 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_aesni_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_aesni_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_aesni_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 34 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 39 column 56 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> aesni_enabled /\ pclmulqdq_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 40 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_aesni_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_aesni_support (va_code_Check_aesni_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sha_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sha_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Sha ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sha_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Sha ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sha_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sha_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 79 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 80 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 81 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sha ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 29) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 83 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (536870912 == Prims.pow2 29)) (fun _ -> (fun (p:prop) -> p) (536870912 == Prims.pow2 29)) (fun (_:unit) -> assert_normalize (536870912 == Prims.pow2 29)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 85 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 87 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sha_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sha_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sha_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 69 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 74 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sha_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 75 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sha_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sha_support (va_code_Check_sha_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_adx_bmi2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_adx_bmi2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Adx_Bmi2 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_adx_bmi2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Adx_Bmi2 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_adx_bmi2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_adx_bmi2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 98 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 100 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 101 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 102 column 19 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Adx_Bmi2 ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 103 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 8) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 104 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 107 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 109 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (256 == Prims.pow2 8)) (fun _ -> (fun (p:prop) -> p) (256 == Prims.pow2 8)) (fun (_:unit) -> assert_normalize (256 == Prims.pow2 8)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 110 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 112 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 113 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 8 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 114 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 11) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 116 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 117 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 8) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 118 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 120 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_adx_bmi2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_adx_bmi2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_adx_bmi2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 90 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 95 column 49 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> adx_enabled /\ bmi2_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 96 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_adx_bmi2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_adx_bmi2_support (va_code_Check_adx_bmi2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Avx ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Avx ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 131 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 133 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 134 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 135 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 136 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 25) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 137 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 138 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 139 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (268435456 == Prims.pow2 28)) (fun _ -> (fun (p:prop) -> p) (268435456 == Prims.pow2 28)) (fun (_:unit) -> assert_normalize (268435456 == Prims.pow2 28)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 141 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 142 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 28) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 143 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 27) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 123 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 128 column 39 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 129 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx_support (va_code_Check_avx_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Avx2 ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Avx2 ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 156 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 158 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 160 column 15 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx2 ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 161 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 5) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 162 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 163 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (32 == Prims.pow2 5)) (fun _ -> (fun (p:prop) -> p) (32 == Prims.pow2 5)) (fun (_:unit) -> assert_normalize (32 == Prims.pow2 5)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 164 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 166 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 148 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 153 column 40 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx2_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 154 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx2_support (va_code_Check_avx2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_movbe_support [@ "opaque_to_smt" va_qattr] let va_code_Check_movbe_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Movbe ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_movbe_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Movbe ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_movbe_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_movbe_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 177 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 179 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 180 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 181 column 16 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Movbe ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 182 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 22) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 183 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 184 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 185 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (4194304 == Prims.pow2 22)) (fun _ -> (fun (p:prop) -> p) (4194304 == Prims.pow2 22)) (fun (_:unit) -> assert_normalize (4194304 == Prims.pow2 22)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 187 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 22) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 189 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 21) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 191 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_movbe_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_movbe_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_movbe_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 169 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 174 column 35 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> movbe_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 175 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_movbe_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_movbe_support (va_code_Check_movbe_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sse_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sse_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Sse ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sse_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Sse ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sse_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sse_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 202 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 204 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 205 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 206 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sse ()) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 209 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (fun (va_s:va_state) _ -> let (va_arg35:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 211 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg35 9) (let (va_arg34:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg34 26) (let (va_arg33:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg33 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 215 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 216 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 217 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 219 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (512 == Prims.pow2 9)) (fun _ -> (fun (p:prop) -> p) (512 == Prims.pow2 9)) (fun (_:unit) -> assert_normalize (512 == Prims.pow2 9)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 220 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 221 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (67108864 == Prims.pow2 26)) (fun _ -> (fun (p:prop) -> p) (67108864 == Prims.pow2 26)) (fun (_:unit) -> assert_normalize (67108864 == Prims.pow2 26)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 223 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 224 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 10) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 227 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 228 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 26) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 17) (let (va_arg32:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg31:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 231 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg31 va_arg32 9) (let (va_arg30:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg30 9) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 233 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (fun (va_s:va_state) _ -> let (va_arg29:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg28:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 234 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg28 va_arg29 9) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 235 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 237 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sse_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sse_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sse_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 194 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 199 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 200 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sse_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sse_support (va_code_Check_sse_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_rdrand_support [@ "opaque_to_smt" va_qattr] let va_code_Check_rdrand_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Rdrand ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_rdrand_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Rdrand ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_rdrand_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_rdrand_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 248 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 250 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 251 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 252 column 17 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Rdrand ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 253 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 30) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 254 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 255 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 256 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (1073741824 == Prims.pow2 30)) (fun _ -> (fun (p:prop) -> p) (1073741824 == Prims.pow2 30)) (fun (_:unit) -> assert_normalize (1073741824 == Prims.pow2 30)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 258 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 259 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 30) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 260 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 29) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 262 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_rdrand_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_rdrand_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_rdrand_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 240 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 245 column 36 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> rdrand_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 246 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_rdrand_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_rdrand_support (va_code_Check_rdrand_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx512_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx512_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Avx512 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 131072)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 14)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 2147483648)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rR11) (va_const_shift_amt64 15)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx512_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Avx512 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 131072)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 14)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 2147483648)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rR11) (va_const_shift_amt64 15)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx512_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx512_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 273 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx512 ()) (fun (va_s:va_state) _ -> let (va_arg49:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 278 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg49 16) (let (va_arg48:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 279 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg48 17) (let (va_arg47:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 280 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg47 30) (let (va_arg46:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 281 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg46 31) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 284 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 285 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 286 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 288 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 289 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 131072)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 290 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 292 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (65536 == Prims.pow2 16)) (fun _ -> (fun (p:prop) -> p) (65536 == Prims.pow2 16)) (fun (_:unit) -> assert_normalize (65536 == Prims.pow2 16)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 293 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (131072 == Prims.pow2 17)) (fun _ -> (fun (p:prop) -> p) (131072 == Prims.pow2 17)) (fun (_:unit) -> assert_normalize (131072 == Prims.pow2 17)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 294 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (1073741824 == Prims.pow2 30)) (fun _ -> (fun (p:prop) -> p) (1073741824 == Prims.pow2 30)) (fun (_:unit) -> assert_normalize (1073741824 == Prims.pow2 30)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 295 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2147483648 == Prims.pow2 31)) (fun _ -> (fun (p:prop) -> p) (2147483648 == Prims.pow2 31)) (fun (_:unit) -> assert_normalize (2147483648 == Prims.pow2 31)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 297 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 298 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 17) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 299 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 1) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 301 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 14)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 302 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 30) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 303 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 14) (let (va_arg45:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg44:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 305 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg44 va_arg45 16) (let (va_arg43:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 306 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg43 16) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 307 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 310 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 2147483648)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 311 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 312 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rR11) (va_const_shift_amt64 15)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 313 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 31) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 314 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 15) (let (va_arg42:Vale.Def.Types_s.nat64) = va_get_reg64 rR10 va_s in let (va_arg41:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 316 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg41 va_arg42 16) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 317 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (fun (va_s:va_state) _ -> let (va_arg40:Vale.Def.Types_s.nat64) = va_get_reg64 rR11 va_s in let (va_arg39:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 318 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg39 va_arg40 16) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 319 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 321 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))))))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx512_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx512_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx512_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 265 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 270 column 42 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx512_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 271 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx512_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx512_support (va_code_Check_avx512_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; 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) //-- //-- Check_osxsave_support [@ "opaque_to_smt" va_qattr] let va_code_Check_osxsave_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Osxsave ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 134217728)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 26)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_osxsave_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Osxsave ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 134217728)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 26)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_osxsave_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_osxsave_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 332 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 334 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 335 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 336 column 18 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Osxsave ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 337 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 27) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 338 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 339 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 134217728)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 340 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (134217728 == Prims.pow2 27)) (fun _ -> (fun (p:prop) -> p) (134217728 == Prims.pow2 27)) (fun (_:unit) -> assert_normalize (134217728 == Prims.pow2 27)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 342 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 26)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 343 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 27) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 344 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 26) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 346 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))
false
false
Vale.Lib.X64.Cpuid.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_Check_osxsave_support : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Check_osxsave_support ()) 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_get_reg64 rRax va_sM =!= 0 ==> osxsave_enabled) /\ va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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.Lib.X64.Cpuid.va_lemma_Check_osxsave_support
{ "file_name": "obj/Vale.Lib.X64.Cpuid.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": 1073, "start_col": 48, "start_line": 1058 }
Prims.Tot
val va_qcode_Check_avx512_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_avx512_support ()))
[ { "abbrev": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "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.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.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_qcode_Check_avx512_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx512_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 273 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx512 ()) (fun (va_s:va_state) _ -> let (va_arg49:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 278 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg49 16) (let (va_arg48:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 279 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg48 17) (let (va_arg47:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 280 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg47 30) (let (va_arg46:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 281 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg46 31) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 284 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 285 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 286 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 288 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 289 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 131072)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 290 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 292 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (65536 == Prims.pow2 16)) (fun _ -> (fun (p:prop) -> p) (65536 == Prims.pow2 16)) (fun (_:unit) -> assert_normalize (65536 == Prims.pow2 16)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 293 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (131072 == Prims.pow2 17)) (fun _ -> (fun (p:prop) -> p) (131072 == Prims.pow2 17)) (fun (_:unit) -> assert_normalize (131072 == Prims.pow2 17)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 294 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (1073741824 == Prims.pow2 30)) (fun _ -> (fun (p:prop) -> p) (1073741824 == Prims.pow2 30)) (fun (_:unit) -> assert_normalize (1073741824 == Prims.pow2 30)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 295 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2147483648 == Prims.pow2 31)) (fun _ -> (fun (p:prop) -> p) (2147483648 == Prims.pow2 31)) (fun (_:unit) -> assert_normalize (2147483648 == Prims.pow2 31)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 297 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 298 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 17) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 299 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 1) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 301 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 14)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 302 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 30) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 303 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 14) (let (va_arg45:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg44:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 305 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg44 va_arg45 16) (let (va_arg43:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 306 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg43 16) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 307 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 310 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 2147483648)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 311 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 312 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rR11) (va_const_shift_amt64 15)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 313 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 31) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 314 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 15) (let (va_arg42:Vale.Def.Types_s.nat64) = va_get_reg64 rR10 va_s in let (va_arg41:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 316 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg41 va_arg42 16) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 317 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (fun (va_s:va_state) _ -> let (va_arg40:Vale.Def.Types_s.nat64) = va_get_reg64 rR11 va_s in let (va_arg39:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 318 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg39 va_arg40 16) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 319 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 321 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))))))))))))))))))))))))))))
val va_qcode_Check_avx512_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_avx512_support ())) let va_qcode_Check_avx512_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_avx512_support ())) =
false
null
false
(qblock va_mods (fun (va_s: va_state) -> let va_old_s:va_state = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 273 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx512 ()) (fun (va_s: va_state) _ -> let va_arg49:Vale.Def.Types_s.nat64 = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 278 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg49 16) (let va_arg48:Vale.Def.Types_s.nat64 = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 279 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg48 17) (let va_arg47:Vale.Def.Types_s.nat64 = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 280 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg47 30) (let va_arg46:Vale.Def.Types_s.nat64 = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 281 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg46 31) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 284 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 285 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 286 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 288 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 289 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax ) (va_const_opr64 131072)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 290 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (fun (va_s: va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 292 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p: prop) -> normalize p ) (65536 == Prims.pow2 16)) (fun _ -> (fun (p: prop) -> p) (65536 == Prims.pow2 16)) (fun (_: unit) -> assert_normalize (65536 == Prims.pow2 16)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 293 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p: prop) -> normalize p) (131072 == Prims.pow2 17)) (fun _ -> (fun (p: prop) -> p) (131072 == Prims.pow2 17)) (fun (_: unit) -> assert_normalize (131072 == Prims.pow2 17)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 294 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p: prop) -> normalize p) (1073741824 == Prims.pow2 30)) (fun _ -> (fun (p: prop) -> p) (1073741824 == Prims.pow2 30) ) (fun (_: unit) -> assert_normalize (1073741824 == Prims.pow2 30) ) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 295 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p: prop) -> normalize p) (2147483648 == Prims.pow2 31 )) (fun _ -> (fun (p: prop) -> p) (2147483648 == Prims.pow2 31)) (fun (_: unit) -> assert_normalize (2147483648 == Prims.pow2 31)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 297 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (fun (va_s: va_state ) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 298 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_: unit ) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 17 ) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 299 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun ( _: unit ) -> Vale.Arch.TypesNative.lemma_ishr_zero64 1 ) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 301 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( va_quick_Shr64 ( va_op_dst_opr64_reg64 rR10 ) ( va_const_shift_amt64 14 ) ) ( fun ( va_s: va_state ) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 302 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( fun ( _: unit ) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 30 ) ( va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 303 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( fun ( _: unit ) -> Vale.Arch.TypesNative.lemma_ishr_zero64 14 ) ( let va_arg45:Vale.Def.Types_s.nat64 = va_get_reg64 rRbx va_s in let va_arg44:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 305 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( fun ( _: unit ) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg44 va_arg45 16 ) ( let va_arg43:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 306 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( fun ( _: unit ) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg43 16 ) ( va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 307 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( va_quick_And64 ( va_op_dst_opr64_reg64 rRax ) ( va_op_opr64_reg64 rRbx ) ) ( va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 310 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( va_quick_Mov64 ( va_op_dst_opr64_reg64 rRbx ) ( va_const_opr64 2147483648 ) ) ( va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 311 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( va_quick_And64 ( va_op_dst_opr64_reg64 rR11 ) ( va_op_opr64_reg64 rRbx ) ) ( va_QBind va_range1 "***** PRECONDITION NOT MET AT line 312 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( va_quick_Shr64 ( va_op_dst_opr64_reg64 rR11 ) ( va_const_shift_amt64 15 ) ) ( fun ( va_s: va_state ) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 313 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( fun ( _: unit ) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 16 31 ) ( va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 314 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( fun ( _: unit ) -> Vale.Arch.TypesNative.lemma_ishr_zero64 15 ) ( let va_arg42:Vale.Def.Types_s.nat64 = va_get_reg64 rR10 va_s in let va_arg41:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 316 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( fun ( _: unit ) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg41 va_arg42 16 ) ( va_QBind va_range1 "***** PRECONDITION NOT MET AT line 317 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( va_quick_And64 ( va_op_dst_opr64_reg64 rRax ) ( va_op_opr64_reg64 rR10 ) ) ( fun ( va_s: va_state ) _ -> let va_arg40:Vale.Def.Types_s.nat64 = va_get_reg64 rR11 va_s in let va_arg39:Vale.Def.Types_s.nat64 = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 318 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( fun ( _: unit ) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg39 va_arg40 16 ) ( va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 319 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( va_quick_And64 ( va_op_dst_opr64_reg64 rRax ) ( va_op_opr64_reg64 rR11 ) ) ( va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 321 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ( va_quick_Mov64 ( va_op_dst_opr64_reg64 rRbx ) ( va_op_opr64_reg64 rR9 ) ) ( va_QEmpty ( () ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )) )))))))))))))) )))))))
{ "checked_file": "Vale.Lib.X64.Cpuid.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.X64.Cpuid.fst" }
[ "total" ]
[ "Vale.X64.QuickCode.va_mods_t", "Vale.X64.QuickCodes.qblock", "Prims.unit", "Prims.Cons", "Vale.X64.Decls.va_code", "Vale.X64.InsBasic.va_code_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rR9", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRax", "Vale.X64.Decls.va_const_opr64", "Vale.X64.Machine_s.rRcx", "Vale.X64.InsBasic.va_code_Cpuid_Avx512", "Vale.X64.Machine_s.rR10", "Vale.X64.Machine_s.rR11", "Vale.X64.InsBasic.va_code_And64", "Vale.X64.InsBasic.va_code_Shr64", "Vale.X64.Decls.va_const_shift_amt64", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_QSeq", "Vale.X64.QuickCodes.va_range1", "Vale.X64.InsBasic.va_quick_Mov64", "Vale.X64.QuickCodes.va_QBind", "Vale.X64.InsBasic.va_quick_Cpuid_Avx512", "Vale.X64.QuickCodes.va_qPURE", "Prims.pure_post", "Prims.l_and", "Prims.l_True", "Prims.l_Forall", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.l_or", "Prims.eq2", "Prims.int", "Vale.Def.Types_s.iand", "Prims.op_GreaterThan", "Prims.op_GreaterThanOrEqual", "Vale.Arch.TypesNative.lemma_iand_pow2_64", "Vale.X64.InsBasic.va_quick_And64", "Vale.X64.QuickCodes.va_QLemma", "FStar.Pervasives.normalize", "Prims.squash", "Vale.Lib.Basic.assert_normalize", "Vale.X64.InsBasic.va_quick_Shr64", "Prims.op_LessThanOrEqual", "Vale.Def.Types_s.ishr", "Prims.op_Subtraction", "Vale.Arch.TypesNative.lemma_ishr_pow2_diff64", "Vale.Arch.TypesNative.lemma_ishr_zero64", "Prims.l_iff", "Prims.op_Negation", "Prims.op_Equality", "Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64", "Vale.X64.QuickCodes.va_QEmpty", "Vale.Def.Words_s.nat64", "Vale.X64.Decls.va_get_reg64", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.va_quickCode", "Vale.Lib.X64.Cpuid.va_code_Check_avx512_support" ]
[]
module Vale.Lib.X64.Cpuid open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s //let pow2_values (u:unit) : Lemma // (pow2 29 == 0x20000000 /\ // pow2 25 == 0x2000000 /\ // pow2 1 == 0x2) // = // assert_norm (pow2 29 == 0x20000000); // assert_norm (0x2000000 == pow2 25); // assert_norm (0x2 == pow2 1); // () open Vale.Lib.Basic //-- Check_aesni_support [@ "opaque_to_smt" va_qattr] let va_code_Check_aesni_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_AES ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_aesni_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_AES ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_aesni_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_aesni_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 42 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 44 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 45 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 46 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_AES ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 47 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 25) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 48 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 49 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 50 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 33554432)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 51 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (33554432 == Prims.pow2 25)) (fun _ -> (fun (p:prop) -> p) (33554432 == Prims.pow2 25)) (fun (_:unit) -> assert_normalize (33554432 == Prims.pow2 25)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 52 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (2 == Prims.pow2 1)) (fun _ -> (fun (p:prop) -> p) (2 == Prims.pow2 1)) (fun (_:unit) -> assert_normalize (2 == Prims.pow2 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 54 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 24)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 55 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 25) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 56 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 24) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 58 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 2)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 59 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 60 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 66 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_aesni_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_aesni_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_aesni_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 34 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 39 column 56 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> aesni_enabled /\ pclmulqdq_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 40 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_aesni_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_aesni_support (va_code_Check_aesni_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sha_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sha_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Sha ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sha_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Sha ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sha_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sha_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 79 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 80 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 81 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sha ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 29) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 83 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 536870912)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (536870912 == Prims.pow2 29)) (fun _ -> (fun (p:prop) -> p) (536870912 == Prims.pow2 29)) (fun (_:unit) -> assert_normalize (536870912 == Prims.pow2 29)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 85 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 87 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sha_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sha_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sha_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 69 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 74 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sha_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 75 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sha_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sha_support (va_code_Check_sha_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_adx_bmi2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_adx_bmi2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Adx_Bmi2 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_adx_bmi2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Adx_Bmi2 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_adx_bmi2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_adx_bmi2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 98 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 100 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 101 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 102 column 19 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Adx_Bmi2 ()) (fun (va_s:va_state) _ -> let (va_arg22:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 103 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg22 8) (let (va_arg21:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 104 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg21 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 107 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 109 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (256 == Prims.pow2 8)) (fun _ -> (fun (p:prop) -> p) (256 == Prims.pow2 8)) (fun (_:unit) -> assert_normalize (256 == Prims.pow2 8)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 110 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 112 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 11)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 113 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 8 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 114 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 11) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 116 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 256)) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg19:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 117 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg19 va_arg20 8) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 118 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 120 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_adx_bmi2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_adx_bmi2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_adx_bmi2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 90 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 95 column 49 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> adx_enabled /\ bmi2_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 96 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_adx_bmi2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_adx_bmi2_support (va_code_Check_adx_bmi2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Avx ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Avx ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 131 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 133 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 134 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 135 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 136 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 25) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 137 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 138 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 268435456)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 139 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (268435456 == Prims.pow2 28)) (fun _ -> (fun (p:prop) -> p) (268435456 == Prims.pow2 28)) (fun (_:unit) -> assert_normalize (268435456 == Prims.pow2 28)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 141 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 27)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 142 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 28) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 143 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 27) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 123 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 128 column 39 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 129 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx_support (va_code_Check_avx_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx2_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx2_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Avx2 ()) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx2_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Avx2 ()) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx2_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_avx2_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 156 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 158 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 160 column 15 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Avx2 ()) (fun (va_s:va_state) _ -> let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 161 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg11 5) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 162 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 32)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 163 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (32 == Prims.pow2 5)) (fun _ -> (fun (p:prop) -> p) (32 == Prims.pow2 5)) (fun (_:unit) -> assert_normalize (32 == Prims.pow2 5)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 164 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 166 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (())))))))))))) [@"opaque_to_smt"] let va_lemma_Check_avx2_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_avx2_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_avx2_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 148 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 153 column 40 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> avx2_cpuid_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 154 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_avx2_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_avx2_support (va_code_Check_avx2_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_movbe_support [@ "opaque_to_smt" va_qattr] let va_code_Check_movbe_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Movbe ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_movbe_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Movbe ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_movbe_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_movbe_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 177 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 179 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 180 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 181 column 16 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Movbe ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 182 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 22) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 183 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 184 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 4194304)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 185 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (4194304 == Prims.pow2 22)) (fun _ -> (fun (p:prop) -> p) (4194304 == Prims.pow2 22)) (fun (_:unit) -> assert_normalize (4194304 == Prims.pow2 22)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 187 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 21)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 22) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 189 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 21) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 191 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_movbe_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_movbe_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_movbe_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 169 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 174 column 35 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> movbe_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 175 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_movbe_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_movbe_support (va_code_Check_movbe_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_sse_support [@ "opaque_to_smt" va_qattr] let va_code_Check_sse_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Sse ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_sse_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Sse ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_sse_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_sse_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 202 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 204 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 205 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 206 column 14 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Sse ()) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 209 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (fun (va_s:va_state) _ -> let (va_arg35:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 211 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg35 9) (let (va_arg34:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg34 26) (let (va_arg33:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg33 19) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 215 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 524288)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 216 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 512)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 217 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 67108864)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 219 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (512 == Prims.pow2 9)) (fun _ -> (fun (p:prop) -> p) (512 == Prims.pow2 9)) (fun (_:unit) -> assert_normalize (512 == Prims.pow2 9)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 220 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (524288 == Prims.pow2 19)) (fun _ -> (fun (p:prop) -> p) (524288 == Prims.pow2 19)) (fun (_:unit) -> assert_normalize (524288 == Prims.pow2 19)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 221 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (67108864 == Prims.pow2 26)) (fun _ -> (fun (p:prop) -> p) (67108864 == Prims.pow2 26)) (fun (_:unit) -> assert_normalize (67108864 == Prims.pow2 26)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 223 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 10)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 224 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 19) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 10) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 227 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 17)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 228 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 9 26) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 17) (let (va_arg32:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg31:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 231 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg31 va_arg32 9) (let (va_arg30:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg30 9) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 233 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (fun (va_s:va_state) _ -> let (va_arg29:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in let (va_arg28:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 234 column 29 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_maybe_pow2_64 va_arg28 va_arg29 9) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 235 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 237 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_sse_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_sse_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_sse_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 194 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 199 column 33 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 200 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_sse_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_sse_support (va_code_Check_sse_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_rdrand_support [@ "opaque_to_smt" va_qattr] let va_code_Check_rdrand_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_Cpuid_Rdrand ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ())))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_rdrand_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Cpuid_Rdrand ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_rdrand_support (va_mods:va_mods_t) : (va_quickCode unit (va_code_Check_rdrand_support ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 248 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 250 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 251 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 252 column 17 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Cpuid_Rdrand ()) (fun (va_s:va_state) _ -> let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRcx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 253 column 23 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_iand_pow2_64 va_arg14 30) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 254 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 255 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1073741824)) (fun (va_s:va_state) _ -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 256 column 21 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" ((fun (p:prop) -> normalize p) (1073741824 == Prims.pow2 30)) (fun _ -> (fun (p:prop) -> p) (1073741824 == Prims.pow2 30)) (fun (_:unit) -> assert_normalize (1073741824 == Prims.pow2 30)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 258 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 29)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 259 column 27 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_pow2_diff64 1 30) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 260 column 22 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (fun (_:unit) -> Vale.Arch.TypesNative.lemma_ishr_zero64 29) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 262 column 10 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))) [@"opaque_to_smt"] let va_lemma_Check_rdrand_support va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Check_rdrand_support va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Check_rdrand_support ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 240 column 1 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 245 column 36 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRax va_sM =!= 0 ==> rdrand_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 246 column 24 of file /home/gebner/everest/hacl-star/vale/code/lib/util/x64/Vale.Lib.X64.Cpuid.vaf *****" (va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rR9; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Check_rdrand_support va_s0 va_k = let (va_sM, va_f0) = va_lemma_Check_rdrand_support (va_code_Check_rdrand_support ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rR9 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_flags; va_Mod_reg64 rR9; 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) //-- //-- Check_avx512_support [@ "opaque_to_smt" va_qattr] let va_code_Check_avx512_support () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_CCons (va_code_Cpuid_Avx512 ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 131072)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 14)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 2147483648)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rR11) (va_const_shift_amt64 15)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Check_avx512_support () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 7)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Cpuid_Avx512 ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 65536)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 131072)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 1073741824)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRax) (va_const_shift_amt64 1)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 14)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 2147483648)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rR11) (va_const_shift_amt64 15)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Check_avx512_support (va_mods:va_mods_t) : (va_quickCode unit
false
false
Vale.Lib.X64.Cpuid.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_qcode_Check_avx512_support (va_mods: va_mods_t) : (va_quickCode unit (va_code_Check_avx512_support ()))
[]
Vale.Lib.X64.Cpuid.va_qcode_Check_avx512_support
{ "file_name": "obj/Vale.Lib.X64.Cpuid.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_mods: Vale.X64.QuickCode.va_mods_t -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.Lib.X64.Cpuid.va_code_Check_avx512_support ())
{ "end_col": 47, "end_line": 962, "start_col": 2, "start_line": 862 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let vale_alg_of_alg (a: alg { a = AES128_GCM \/ a = AES256_GCM }) = match a with | AES128_GCM -> Vale.AES.AES_s.AES_128 | AES256_GCM -> Vale.AES.AES_s.AES_256
let vale_alg_of_alg (a: alg{a = AES128_GCM \/ a = AES256_GCM}) =
false
null
false
match a with | AES128_GCM -> Vale.AES.AES_s.AES_128 | AES256_GCM -> Vale.AES.AES_s.AES_256
{ "checked_file": "Spec.Agile.AEAD.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.AES.GCTR.fst.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "Spec.Chacha20Poly1305.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked" ], "interface_file": true, "source_file": "Spec.Agile.AEAD.fst" }
[ "total" ]
[ "Spec.Agile.AEAD.alg", "Prims.l_or", "Prims.b2t", "Prims.op_Equality", "Spec.Agile.AEAD.AES128_GCM", "Spec.Agile.AEAD.AES256_GCM", "Vale.AES.AES_common_s.AES_128", "Vale.AES.AES_common_s.AES_256", "Vale.AES.AES_common_s.algorithm" ]
[]
module Spec.Agile.AEAD open FStar.Integers module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0"
false
false
Spec.Agile.AEAD.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val vale_alg_of_alg : a: Spec.Agile.AEAD.alg{a = Spec.Agile.AEAD.AES128_GCM \/ a = Spec.Agile.AEAD.AES256_GCM} -> Vale.AES.AES_common_s.algorithm
[]
Spec.Agile.AEAD.vale_alg_of_alg
{ "file_name": "specs/Spec.Agile.AEAD.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.AEAD.alg{a = Spec.Agile.AEAD.AES128_GCM \/ a = Spec.Agile.AEAD.AES256_GCM} -> Vale.AES.AES_common_s.algorithm
{ "end_col": 40, "end_line": 12, "start_col": 2, "start_line": 10 }
Prims.Tot
val encrypt: #(a: supported_alg) -> kv a -> iv a -> ad a -> p:plain a -> encrypted p
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let encrypt #a kv iv ad plain = match a with | CHACHA20_POLY1305 -> Spec.Chacha20Poly1305.aead_encrypt kv iv plain ad | AES128_GCM | AES256_GCM -> // This step needs friend'ing. let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 kv in // The specification of gcm_encrypt_LE takes care of computing a valid // GCM iv from an arbitrary length iv. Hence the iv is the sequence of bytes let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 iv in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 ad in let plain_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 plain in let cipher_nat, tag_nat = Vale.AES.GCM_s.gcm_encrypt_LE (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat in let cipher = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 cipher_nat in let tag = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 tag_nat in gcm_encrypt_tag_length (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat; gcm_encrypt_cipher_length (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat; // one more spec discrepancy: Vale returns the cipher and tag separated, // while HACL* bundles them together; another arbitrary choice here Seq.append cipher tag
val encrypt: #(a: supported_alg) -> kv a -> iv a -> ad a -> p:plain a -> encrypted p let encrypt #a kv iv ad plain =
false
null
false
match a with | CHACHA20_POLY1305 -> Spec.Chacha20Poly1305.aead_encrypt kv iv plain ad | AES128_GCM | AES256_GCM -> let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 kv in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 iv in let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 ad in let plain_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 plain in let cipher_nat, tag_nat = Vale.AES.GCM_s.gcm_encrypt_LE (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat in let cipher = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 cipher_nat in let tag = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 tag_nat in gcm_encrypt_tag_length (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat; gcm_encrypt_cipher_length (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat; Seq.append cipher tag
{ "checked_file": "Spec.Agile.AEAD.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.AES.GCTR.fst.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "Spec.Chacha20Poly1305.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked" ], "interface_file": true, "source_file": "Spec.Agile.AEAD.fst" }
[ "total" ]
[ "Spec.Agile.AEAD.supported_alg", "Spec.Agile.AEAD.kv", "Spec.Agile.AEAD.iv", "Spec.Agile.AEAD.ad", "Spec.Agile.AEAD.plain", "Spec.Chacha20Poly1305.aead_encrypt", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "FStar.Seq.Base.append", "FStar.UInt8.t", "Prims.unit", "Spec.Agile.AEAD.gcm_encrypt_cipher_length", "Spec.Agile.AEAD.vale_alg_of_alg", "Spec.Agile.AEAD.gcm_encrypt_tag_length", "Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8", "Spec.Agile.AEAD.encrypted", "FStar.Pervasives.Native.tuple2", "Vale.Def.Words_s.nat8", "Vale.AES.GCM_s.gcm_encrypt_LE", "Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8" ]
[]
module Spec.Agile.AEAD open FStar.Integers module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0" let vale_alg_of_alg (a: alg { a = AES128_GCM \/ a = AES256_GCM }) = match a with | AES128_GCM -> Vale.AES.AES_s.AES_128 | AES256_GCM -> Vale.AES.AES_s.AES_256 // For gctr_encrypt_recursive and its pattern! friend Vale.AES.GCTR #push-options "--max_ifuel 1" let gcm_encrypt_tag_length alg key iv plain auth: Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures ( let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length t = 16)) = Vale.AES.GCM_s.gcm_encrypt_LE_reveal () let gcm_encrypt_cipher_length alg key iv plain auth: Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures ( let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length c = S.length plain)) = Vale.AES.GCM_s.gcm_encrypt_LE_reveal () #pop-options // TODO remove me once seq_uint8_to_seq_nat8 takes Lib.IntTypes.uint8 friend Lib.IntTypes #push-options "--z3rlimit 20"
false
false
Spec.Agile.AEAD.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val encrypt: #(a: supported_alg) -> kv a -> iv a -> ad a -> p:plain a -> encrypted p
[]
Spec.Agile.AEAD.encrypt
{ "file_name": "specs/Spec.Agile.AEAD.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
kv: Spec.Agile.AEAD.kv a -> iv: Spec.Agile.AEAD.iv a -> ad: Spec.Agile.AEAD.ad a -> p: Spec.Agile.AEAD.plain a -> Spec.Agile.AEAD.encrypted p
{ "end_col": 27, "end_line": 69, "start_col": 2, "start_line": 46 }
Prims.Tot
val decrypt: #(a: supported_alg) -> kv a -> iv a -> ad a -> c:cipher a -> option (decrypted c)
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let decrypt #a kv iv ad cipher = let tag = S.slice cipher (S.length cipher - tag_length a) (S.length cipher) in let cipher = S.slice cipher 0 (S.length cipher - tag_length a) in match a with | CHACHA20_POLY1305 -> Spec.Chacha20Poly1305.aead_decrypt kv iv cipher tag ad | AES128_GCM | AES256_GCM -> let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 kv in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 iv in let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 ad in let cipher_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 cipher in let tag_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 tag in let plain_nat, success = Vale.AES.GCM_s.gcm_decrypt_LE (vale_alg_of_alg a) kv_nat iv_nat cipher_nat ad_nat tag_nat in gcm_decrypt_cipher_length (vale_alg_of_alg a) kv_nat iv_nat cipher_nat ad_nat tag_nat; let plain = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 plain_nat in if success then Some plain else None
val decrypt: #(a: supported_alg) -> kv a -> iv a -> ad a -> c:cipher a -> option (decrypted c) let decrypt #a kv iv ad cipher =
false
null
false
let tag = S.slice cipher (S.length cipher - tag_length a) (S.length cipher) in let cipher = S.slice cipher 0 (S.length cipher - tag_length a) in match a with | CHACHA20_POLY1305 -> Spec.Chacha20Poly1305.aead_decrypt kv iv cipher tag ad | AES128_GCM | AES256_GCM -> let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 kv in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 iv in let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 ad in let cipher_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 cipher in let tag_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 tag in let plain_nat, success = Vale.AES.GCM_s.gcm_decrypt_LE (vale_alg_of_alg a) kv_nat iv_nat cipher_nat ad_nat tag_nat in gcm_decrypt_cipher_length (vale_alg_of_alg a) kv_nat iv_nat cipher_nat ad_nat tag_nat; let plain = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 plain_nat in if success then Some plain else None
{ "checked_file": "Spec.Agile.AEAD.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.AES.GCTR.fst.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "Spec.Chacha20Poly1305.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked" ], "interface_file": true, "source_file": "Spec.Agile.AEAD.fst" }
[ "total" ]
[ "Spec.Agile.AEAD.supported_alg", "Spec.Agile.AEAD.kv", "Spec.Agile.AEAD.iv", "Spec.Agile.AEAD.ad", "Spec.Agile.AEAD.cipher", "Spec.Chacha20Poly1305.aead_decrypt", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Prims.bool", "FStar.Pervasives.Native.Some", "Spec.Agile.AEAD.decrypted", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "FStar.UInt8.t", "Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8", "Prims.unit", "Spec.Agile.AEAD.gcm_decrypt_cipher_length", "Spec.Agile.AEAD.vale_alg_of_alg", "FStar.Pervasives.Native.tuple2", "Vale.Def.Words_s.nat8", "Vale.AES.GCM_s.gcm_decrypt_LE", "Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8", "Spec.Agile.AEAD.uint8", "FStar.Seq.Base.slice", "FStar.Integers.op_Subtraction", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.Seq.Base.length", "Spec.Agile.AEAD.tag_length" ]
[]
module Spec.Agile.AEAD open FStar.Integers module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0" let vale_alg_of_alg (a: alg { a = AES128_GCM \/ a = AES256_GCM }) = match a with | AES128_GCM -> Vale.AES.AES_s.AES_128 | AES256_GCM -> Vale.AES.AES_s.AES_256 // For gctr_encrypt_recursive and its pattern! friend Vale.AES.GCTR #push-options "--max_ifuel 1" let gcm_encrypt_tag_length alg key iv plain auth: Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures ( let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length t = 16)) = Vale.AES.GCM_s.gcm_encrypt_LE_reveal () let gcm_encrypt_cipher_length alg key iv plain auth: Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures ( let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length c = S.length plain)) = Vale.AES.GCM_s.gcm_encrypt_LE_reveal () #pop-options // TODO remove me once seq_uint8_to_seq_nat8 takes Lib.IntTypes.uint8 friend Lib.IntTypes #push-options "--z3rlimit 20" let encrypt #a kv iv ad plain = match a with | CHACHA20_POLY1305 -> Spec.Chacha20Poly1305.aead_encrypt kv iv plain ad | AES128_GCM | AES256_GCM -> // This step needs friend'ing. let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 kv in // The specification of gcm_encrypt_LE takes care of computing a valid // GCM iv from an arbitrary length iv. Hence the iv is the sequence of bytes let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 iv in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 ad in let plain_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 plain in let cipher_nat, tag_nat = Vale.AES.GCM_s.gcm_encrypt_LE (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat in let cipher = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 cipher_nat in let tag = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 tag_nat in gcm_encrypt_tag_length (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat; gcm_encrypt_cipher_length (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat; // one more spec discrepancy: Vale returns the cipher and tag separated, // while HACL* bundles them together; another arbitrary choice here Seq.append cipher tag #pop-options #push-options "--max_ifuel 1" let gcm_decrypt_cipher_length alg key iv plain auth tag: Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures ( let c, t = Vale.AES.GCM_s.gcm_decrypt_LE alg key iv plain auth tag in S.length c = S.length plain)) = Vale.AES.GCM_s.gcm_decrypt_LE_reveal () #pop-options // Note: bundling cipher and tag together is a pain...
false
false
Spec.Agile.AEAD.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val decrypt: #(a: supported_alg) -> kv a -> iv a -> ad a -> c:cipher a -> option (decrypted c)
[]
Spec.Agile.AEAD.decrypt
{ "file_name": "specs/Spec.Agile.AEAD.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
kv: Spec.Agile.AEAD.kv a -> iv: Spec.Agile.AEAD.iv a -> ad: Spec.Agile.AEAD.ad a -> c: Spec.Agile.AEAD.cipher a -> FStar.Pervasives.Native.option (Spec.Agile.AEAD.decrypted c)
{ "end_col": 42, "end_line": 105, "start_col": 32, "start_line": 87 }
FStar.Pervasives.Lemma
val gcm_decrypt_cipher_length (alg key iv plain auth tag: _) : Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures (let c, t = Vale.AES.GCM_s.gcm_decrypt_LE alg key iv plain auth tag in S.length c = S.length plain))
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gcm_decrypt_cipher_length alg key iv plain auth tag: Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures ( let c, t = Vale.AES.GCM_s.gcm_decrypt_LE alg key iv plain auth tag in S.length c = S.length plain)) = Vale.AES.GCM_s.gcm_decrypt_LE_reveal ()
val gcm_decrypt_cipher_length (alg key iv plain auth tag: _) : Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures (let c, t = Vale.AES.GCM_s.gcm_decrypt_LE alg key iv plain auth tag in S.length c = S.length plain)) let gcm_decrypt_cipher_length alg key iv plain auth tag : Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures (let c, t = Vale.AES.GCM_s.gcm_decrypt_LE alg key iv plain auth tag in S.length c = S.length plain)) =
false
null
true
Vale.AES.GCM_s.gcm_decrypt_LE_reveal ()
{ "checked_file": "Spec.Agile.AEAD.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.AES.GCTR.fst.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "Spec.Chacha20Poly1305.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked" ], "interface_file": true, "source_file": "Spec.Agile.AEAD.fst" }
[ "lemma" ]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Vale.AES.GCM_s.supported_iv_LE", "Vale.AES.GCM_s.gcm_decrypt_LE_reveal", "Prims.unit", "Prims.l_and", "Vale.AES.AES_common_s.is_aes_key", "Prims.b2t", "FStar.Integers.op_Less", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.Seq.Base.length", "Vale.Def.Words_s.pow2_32", "Prims.squash", "Prims.bool", "Prims.op_Equality", "Prims.nat", "FStar.Pervasives.Native.tuple2", "Vale.Def.Words_s.nat8", "Vale.AES.GCM_s.gcm_decrypt_LE", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Spec.Agile.AEAD open FStar.Integers module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0" let vale_alg_of_alg (a: alg { a = AES128_GCM \/ a = AES256_GCM }) = match a with | AES128_GCM -> Vale.AES.AES_s.AES_128 | AES256_GCM -> Vale.AES.AES_s.AES_256 // For gctr_encrypt_recursive and its pattern! friend Vale.AES.GCTR #push-options "--max_ifuel 1" let gcm_encrypt_tag_length alg key iv plain auth: Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures ( let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length t = 16)) = Vale.AES.GCM_s.gcm_encrypt_LE_reveal () let gcm_encrypt_cipher_length alg key iv plain auth: Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures ( let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length c = S.length plain)) = Vale.AES.GCM_s.gcm_encrypt_LE_reveal () #pop-options // TODO remove me once seq_uint8_to_seq_nat8 takes Lib.IntTypes.uint8 friend Lib.IntTypes #push-options "--z3rlimit 20" let encrypt #a kv iv ad plain = match a with | CHACHA20_POLY1305 -> Spec.Chacha20Poly1305.aead_encrypt kv iv plain ad | AES128_GCM | AES256_GCM -> // This step needs friend'ing. let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 kv in // The specification of gcm_encrypt_LE takes care of computing a valid // GCM iv from an arbitrary length iv. Hence the iv is the sequence of bytes let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 iv in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 ad in let plain_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 plain in let cipher_nat, tag_nat = Vale.AES.GCM_s.gcm_encrypt_LE (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat in let cipher = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 cipher_nat in let tag = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 tag_nat in gcm_encrypt_tag_length (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat; gcm_encrypt_cipher_length (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat; // one more spec discrepancy: Vale returns the cipher and tag separated, // while HACL* bundles them together; another arbitrary choice here Seq.append cipher tag #pop-options #push-options "--max_ifuel 1" let gcm_decrypt_cipher_length alg key iv plain auth tag: Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures ( let c, t = Vale.AES.GCM_s.gcm_decrypt_LE alg key iv plain auth tag in S.length c = S.length plain))
false
false
Spec.Agile.AEAD.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm_decrypt_cipher_length (alg key iv plain auth tag: _) : Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures (let c, t = Vale.AES.GCM_s.gcm_decrypt_LE alg key iv plain auth tag in S.length c = S.length plain))
[]
Spec.Agile.AEAD.gcm_decrypt_cipher_length
{ "file_name": "specs/Spec.Agile.AEAD.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> iv: Vale.AES.GCM_s.supported_iv_LE -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> tag: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_common_s.is_aes_key alg key /\ FStar.Seq.Base.length plain < Vale.Def.Words_s.pow2_32 /\ FStar.Seq.Base.length auth < Vale.Def.Words_s.pow2_32) (ensures (let _ = Vale.AES.GCM_s.gcm_decrypt_LE alg key iv plain auth tag in (let FStar.Pervasives.Native.Mktuple2 #_ #_ c _ = _ in FStar.Seq.Base.length c = FStar.Seq.Base.length plain) <: Type0))
{ "end_col": 41, "end_line": 82, "start_col": 2, "start_line": 82 }
FStar.Pervasives.Lemma
val gcm_encrypt_cipher_length (alg key iv plain auth: _) : Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures (let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length c = S.length plain))
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gcm_encrypt_cipher_length alg key iv plain auth: Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures ( let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length c = S.length plain)) = Vale.AES.GCM_s.gcm_encrypt_LE_reveal ()
val gcm_encrypt_cipher_length (alg key iv plain auth: _) : Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures (let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length c = S.length plain)) let gcm_encrypt_cipher_length alg key iv plain auth : Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures (let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length c = S.length plain)) =
false
null
true
Vale.AES.GCM_s.gcm_encrypt_LE_reveal ()
{ "checked_file": "Spec.Agile.AEAD.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.AES.GCTR.fst.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "Spec.Chacha20Poly1305.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked" ], "interface_file": true, "source_file": "Spec.Agile.AEAD.fst" }
[ "lemma" ]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Vale.AES.GCM_s.supported_iv_LE", "Vale.AES.GCM_s.gcm_encrypt_LE_reveal", "Prims.unit", "Prims.l_and", "Vale.AES.AES_common_s.is_aes_key", "Prims.b2t", "FStar.Integers.op_Less", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.Seq.Base.length", "Vale.Def.Words_s.pow2_32", "Prims.squash", "Prims.op_Equality", "Prims.nat", "FStar.Pervasives.Native.tuple2", "Vale.Def.Words_s.nat8", "Vale.AES.GCM_s.gcm_encrypt_LE", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Spec.Agile.AEAD open FStar.Integers module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0" let vale_alg_of_alg (a: alg { a = AES128_GCM \/ a = AES256_GCM }) = match a with | AES128_GCM -> Vale.AES.AES_s.AES_128 | AES256_GCM -> Vale.AES.AES_s.AES_256 // For gctr_encrypt_recursive and its pattern! friend Vale.AES.GCTR #push-options "--max_ifuel 1" let gcm_encrypt_tag_length alg key iv plain auth: Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures ( let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length t = 16)) = Vale.AES.GCM_s.gcm_encrypt_LE_reveal () let gcm_encrypt_cipher_length alg key iv plain auth: Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures ( let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length c = S.length plain))
false
false
Spec.Agile.AEAD.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm_encrypt_cipher_length (alg key iv plain auth: _) : Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures (let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length c = S.length plain))
[]
Spec.Agile.AEAD.gcm_encrypt_cipher_length
{ "file_name": "specs/Spec.Agile.AEAD.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> iv: Vale.AES.GCM_s.supported_iv_LE -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_common_s.is_aes_key alg key /\ FStar.Seq.Base.length plain < Vale.Def.Words_s.pow2_32 /\ FStar.Seq.Base.length auth < Vale.Def.Words_s.pow2_32) (ensures (let _ = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in (let FStar.Pervasives.Native.Mktuple2 #_ #_ c _ = _ in FStar.Seq.Base.length c = FStar.Seq.Base.length plain) <: Type0))
{ "end_col": 41, "end_line": 38, "start_col": 2, "start_line": 38 }
FStar.Pervasives.Lemma
val gcm_encrypt_tag_length (alg key iv plain auth: _) : Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures (let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length t = 16))
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gcm_encrypt_tag_length alg key iv plain auth: Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures ( let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length t = 16)) = Vale.AES.GCM_s.gcm_encrypt_LE_reveal ()
val gcm_encrypt_tag_length (alg key iv plain auth: _) : Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures (let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length t = 16)) let gcm_encrypt_tag_length alg key iv plain auth : Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures (let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length t = 16)) =
false
null
true
Vale.AES.GCM_s.gcm_encrypt_LE_reveal ()
{ "checked_file": "Spec.Agile.AEAD.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.AES.GCTR.fst.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "Spec.Chacha20Poly1305.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked" ], "interface_file": true, "source_file": "Spec.Agile.AEAD.fst" }
[ "lemma" ]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Vale.AES.GCM_s.supported_iv_LE", "Vale.AES.GCM_s.gcm_encrypt_LE_reveal", "Prims.unit", "Prims.l_and", "Vale.AES.AES_common_s.is_aes_key", "Prims.b2t", "FStar.Integers.op_Less", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.Seq.Base.length", "Vale.Def.Words_s.pow2_32", "Prims.squash", "Prims.op_Equality", "Prims.int", "FStar.Pervasives.Native.tuple2", "Vale.Def.Words_s.nat8", "Vale.AES.GCM_s.gcm_encrypt_LE", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Spec.Agile.AEAD open FStar.Integers module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0" let vale_alg_of_alg (a: alg { a = AES128_GCM \/ a = AES256_GCM }) = match a with | AES128_GCM -> Vale.AES.AES_s.AES_128 | AES256_GCM -> Vale.AES.AES_s.AES_256 // For gctr_encrypt_recursive and its pattern! friend Vale.AES.GCTR #push-options "--max_ifuel 1" let gcm_encrypt_tag_length alg key iv plain auth: Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures ( let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length t = 16))
false
false
Spec.Agile.AEAD.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm_encrypt_tag_length (alg key iv plain auth: _) : Lemma (requires Vale.AES.AES_s.is_aes_key alg key /\ S.length plain < Vale.Def.Words_s.pow2_32 /\ S.length auth < Vale.Def.Words_s.pow2_32) (ensures (let c, t = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in S.length t = 16))
[]
Spec.Agile.AEAD.gcm_encrypt_tag_length
{ "file_name": "specs/Spec.Agile.AEAD.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> iv: Vale.AES.GCM_s.supported_iv_LE -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_common_s.is_aes_key alg key /\ FStar.Seq.Base.length plain < Vale.Def.Words_s.pow2_32 /\ FStar.Seq.Base.length auth < Vale.Def.Words_s.pow2_32) (ensures (let _ = Vale.AES.GCM_s.gcm_encrypt_LE alg key iv plain auth in (let FStar.Pervasives.Native.Mktuple2 #_ #_ _ t = _ in FStar.Seq.Base.length t = 16) <: Type0))
{ "end_col": 41, "end_line": 27, "start_col": 2, "start_line": 27 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n)
let a_spec (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len {0 < BD.bn_v n}) =
false
null
false
Lib.NatMod.nat_mod (BD.bn_v n)
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Lib.NatMod.nat_mod" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract
false
false
Hacl.Bignum.MontExponentiation.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 a_spec : n: Hacl.Spec.Bignum.Definitions.lbignum t len {0 < Hacl.Spec.Bignum.Definitions.bn_v n} -> Type0
[]
Hacl.Bignum.MontExponentiation.a_spec
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len {0 < Hacl.Spec.Bignum.Definitions.bn_v n} -> Type0
{ "end_col": 32, "end_line": 34, "start_col": 2, "start_line": 34 }
Prims.Tot
val linv (#t: limb_t) (#len: SN.bn_len t) (n a: BD.lbignum t len) : Type0
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n
val linv (#t: limb_t) (#len: SN.bn_len t) (n a: BD.lbignum t len) : Type0 let linv (#t: limb_t) (#len: SN.bn_len t) (n a: BD.lbignum t len) : Type0 =
false
null
false
BD.bn_v a < BD.bn_v n
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract
false
false
Hacl.Bignum.MontExponentiation.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 linv (#t: limb_t) (#len: SN.bn_len t) (n a: BD.lbignum t len) : Type0
[]
Hacl.Bignum.MontExponentiation.linv
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> Type0
{ "end_col": 23, "end_line": 38, "start_col": 2, "start_line": 38 }
Prims.Tot
val refl (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len) (a: BD.lbignum t len {linv n a}) : a_spec n
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a
val refl (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len) (a: BD.lbignum t len {linv n a}) : a_spec n let refl (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len) (a: BD.lbignum t len {linv n a}) : a_spec n =
false
null
false
BD.bn_v a
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Bignum.MontExponentiation.linv", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Bignum.MontExponentiation.a_spec" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract
false
false
Hacl.Bignum.MontExponentiation.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 refl (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len) (a: BD.lbignum t len {linv n a}) : a_spec n
[]
Hacl.Bignum.MontExponentiation.refl
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len {Hacl.Bignum.MontExponentiation.linv n a} -> Hacl.Bignum.MontExponentiation.a_spec n
{ "end_col": 11, "end_line": 42, "start_col": 2, "start_line": 42 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_mont_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> mu:limb t -> r2:lbignum t len -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM == LE.pow k1 (bn_v h0 aM) (bn_v h0 b)))
let bn_exp_mont_st (t: limb_t) (len: BN.meta_len t) =
false
null
false
n: lbignum t len -> mu: limb t -> r2: lbignum t len -> aM: lbignum t len -> bBits: size_t -> b: lbignum t (blocks0 bBits (size (bits t))) -> resM: lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM == LE.pow k1 (bn_v h0 aM) (bn_v h0 b)))
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Hacl.Bignum.MontExponentiation.bn_exp_mont_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq", "Lib.Buffer.modifies", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.loc", "Prims.eq2", "Prims.nat", "Hacl.Bignum.Definitions.bn_v", "Lib.Exponentiation.Definition.pow", "Lib.NatMod.nat_mod", "Lib.Exponentiation.Definition.comm_monoid", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Lib.IntTypes.SEC" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.BM.bn.BN.len in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); BM.bn_mont_one len k.BM.from ctx_n mu ctx_r2 oneM inline_for_extraction noextract val bn_mont_mul: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_mont_sqr: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SM.bn_mont_sqr_lemma n mu (as_seq h0 aM); SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_mont_concrete_ops (t:limb_t) (k:BM.mont t) (n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu; BE.lone = bn_mont_one k n mu; BE.lmul = bn_mont_mul k n mu; BE.lsqr = bn_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n inline_for_extraction noextract
false
false
Hacl.Bignum.MontExponentiation.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_exp_mont_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
[]
Hacl.Bignum.MontExponentiation.bn_exp_mont_st
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
{ "end_col": 56, "end_line": 199, "start_col": 4, "start_line": 183 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n
let bn_exp_mont_pre (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len) (mu: limb t) (r2 aM: BD.lbignum t len) (bBits: size_nat) (b: BD.lbignum t (BD.blocks0 bBits (bits t))) =
false
null
false
SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 ((2 * bits t) * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.blocks0", "Lib.IntTypes.bits", "Prims.l_and", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "Prims.eq2", "Prims.int", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.op_Modulus", "Prims.pow2", "FStar.Mul.op_Star", "Prims.b2t", "Prims.op_LessThan", "Prims.logical" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.BM.bn.BN.len in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); BM.bn_mont_one len k.BM.from ctx_n mu ctx_r2 oneM inline_for_extraction noextract val bn_mont_mul: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_mont_sqr: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SM.bn_mont_sqr_lemma n mu (as_seq h0 aM); SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_mont_concrete_ops (t:limb_t) (k:BM.mont t) (n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu; BE.lone = bn_mont_one k n mu; BE.lmul = bn_mont_mul k n mu; BE.lsqr = bn_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t)))
false
false
Hacl.Bignum.MontExponentiation.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_exp_mont_pre : n: Hacl.Spec.Bignum.Definitions.lbignum t len -> mu: Hacl.Bignum.Definitions.limb t -> r2: Hacl.Spec.Bignum.Definitions.lbignum t len -> aM: Hacl.Spec.Bignum.Definitions.lbignum t len -> bBits: Lib.IntTypes.size_nat -> b: Hacl.Spec.Bignum.Definitions.lbignum t (Hacl.Spec.Bignum.Definitions.blocks0 bBits (Lib.IntTypes.bits t)) -> Prims.logical
[]
Hacl.Bignum.MontExponentiation.bn_exp_mont_pre
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> mu: Hacl.Bignum.Definitions.limb t -> r2: Hacl.Spec.Bignum.Definitions.lbignum t len -> aM: Hacl.Spec.Bignum.Definitions.lbignum t len -> bBits: Lib.IntTypes.size_nat -> b: Hacl.Spec.Bignum.Definitions.lbignum t (Hacl.Spec.Bignum.Definitions.blocks0 bBits (Lib.IntTypes.bits t)) -> Prims.logical
{ "end_col": 25, "end_line": 178, "start_col": 3, "start_line": 175 }
Prims.Tot
val bn_exp_mont_vartime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_mont_vartime #t k n mu r2 aM bBits b resM = if bBits <. size S.bn_exp_mont_vartime_threshold then bn_exp_mont_bm_vartime k n mu r2 aM bBits b resM else bn_exp_mont_fw_vartime k 4ul n mu r2 aM bBits b resM
val bn_exp_mont_vartime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_vartime #t k n mu r2 aM bBits b resM =
false
null
false
if bBits <. size S.bn_exp_mont_vartime_threshold then bn_exp_mont_bm_vartime k n mu r2 aM bBits b resM else bn_exp_mont_fw_vartime k 4ul n mu r2 aM bBits b resM
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Montgomery.mont", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__bn", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.IntTypes.op_Less_Dot", "Lib.IntTypes.U32", "Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_vartime_threshold", "Hacl.Bignum.MontExponentiation.bn_exp_mont_bm_vartime", "Prims.unit", "Prims.bool", "Hacl.Bignum.MontExponentiation.bn_exp_mont_fw_vartime", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.BM.bn.BN.len in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); BM.bn_mont_one len k.BM.from ctx_n mu ctx_r2 oneM inline_for_extraction noextract val bn_mont_mul: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_mont_sqr: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SM.bn_mont_sqr_lemma n mu (as_seq h0 aM); SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_mont_concrete_ops (t:limb_t) (k:BM.mont t) (n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu; BE.lone = bn_mont_one k n mu; BE.lmul = bn_mont_mul k n mu; BE.lsqr = bn_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n inline_for_extraction noextract let bn_exp_mont_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> mu:limb t -> r2:lbignum t len -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM == LE.pow k1 (bn_v h0 aM) (bn_v h0 b))) // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_bm_vartime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_bm_vartime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_rl_vartime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_rl_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_bm_consttime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_bm_consttime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_mont_ladder_swap_consttime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_mont_ladder_swap_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); LE.exp_mont_ladder_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); pop_frame () // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_fw_vartime: #t:limb_t -> k:BM.mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.BM.bn.BN.len <= max_size_t} -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_fw_vartime #t k l n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_vartime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b) (v l); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_fw_consttime: #t:limb_t -> k:BM.mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.BM.bn.BN.len <= max_size_t} -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_fw_consttime #t k l n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_consttime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b) (v l); pop_frame () /////////////////////////////////////////////// // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_vartime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len
false
false
Hacl.Bignum.MontExponentiation.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_exp_mont_vartime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len
[]
Hacl.Bignum.MontExponentiation.bn_exp_mont_vartime
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.Montgomery.mont t -> Hacl.Bignum.MontExponentiation.bn_exp_mont_st t (Mkbn?.len (Mkmont?.bn k))
{ "end_col": 56, "end_line": 290, "start_col": 2, "start_line": 287 }
Prims.Tot
val bn_exp_mont_consttime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_mont_consttime #t k n mu r2 aM bBits b resM = if bBits <. size S.bn_exp_mont_consttime_threshold then bn_exp_mont_bm_consttime k n mu r2 aM bBits b resM else bn_exp_mont_fw_consttime k 4ul n mu r2 aM bBits b resM
val bn_exp_mont_consttime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_consttime #t k n mu r2 aM bBits b resM =
false
null
false
if bBits <. size S.bn_exp_mont_consttime_threshold then bn_exp_mont_bm_consttime k n mu r2 aM bBits b resM else bn_exp_mont_fw_consttime k 4ul n mu r2 aM bBits b resM
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Montgomery.mont", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__bn", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.IntTypes.op_Less_Dot", "Lib.IntTypes.U32", "Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_consttime_threshold", "Hacl.Bignum.MontExponentiation.bn_exp_mont_bm_consttime", "Prims.unit", "Prims.bool", "Hacl.Bignum.MontExponentiation.bn_exp_mont_fw_consttime", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.BM.bn.BN.len in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); BM.bn_mont_one len k.BM.from ctx_n mu ctx_r2 oneM inline_for_extraction noextract val bn_mont_mul: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_mont_sqr: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SM.bn_mont_sqr_lemma n mu (as_seq h0 aM); SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_mont_concrete_ops (t:limb_t) (k:BM.mont t) (n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu; BE.lone = bn_mont_one k n mu; BE.lmul = bn_mont_mul k n mu; BE.lsqr = bn_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n inline_for_extraction noextract let bn_exp_mont_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> mu:limb t -> r2:lbignum t len -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM == LE.pow k1 (bn_v h0 aM) (bn_v h0 b))) // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_bm_vartime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_bm_vartime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_rl_vartime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_rl_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_bm_consttime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_bm_consttime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_mont_ladder_swap_consttime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_mont_ladder_swap_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); LE.exp_mont_ladder_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); pop_frame () // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_fw_vartime: #t:limb_t -> k:BM.mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.BM.bn.BN.len <= max_size_t} -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_fw_vartime #t k l n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_vartime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b) (v l); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_fw_consttime: #t:limb_t -> k:BM.mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.BM.bn.BN.len <= max_size_t} -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_fw_consttime #t k l n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_consttime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b) (v l); pop_frame () /////////////////////////////////////////////// // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_vartime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_vartime #t k n mu r2 aM bBits b resM = if bBits <. size S.bn_exp_mont_vartime_threshold then bn_exp_mont_bm_vartime k n mu r2 aM bBits b resM else bn_exp_mont_fw_vartime k 4ul n mu r2 aM bBits b resM // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_consttime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len
false
false
Hacl.Bignum.MontExponentiation.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_exp_mont_consttime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len
[]
Hacl.Bignum.MontExponentiation.bn_exp_mont_consttime
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.Montgomery.mont t -> Hacl.Bignum.MontExponentiation.bn_exp_mont_st t (Mkbn?.len (Mkmont?.bn k))
{ "end_col": 58, "end_line": 300, "start_col": 2, "start_line": 297 }
Prims.Tot
val mk_bn_mont_concrete_ops (t: limb_t) (k: BM.mont t) (n: Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len))) (mu: limb t {SM.bn_mont_pre n mu}) : BE.concrete_ops t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_bn_mont_concrete_ops (t:limb_t) (k:BM.mont t) (n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu; BE.lone = bn_mont_one k n mu; BE.lmul = bn_mont_mul k n mu; BE.lsqr = bn_mont_sqr k n mu; }
val mk_bn_mont_concrete_ops (t: limb_t) (k: BM.mont t) (n: Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len))) (mu: limb t {SM.bn_mont_pre n mu}) : BE.concrete_ops t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) let mk_bn_mont_concrete_ops (t: limb_t) (k: BM.mont t) (n: Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len))) (mu: limb t {SM.bn_mont_pre n mu}) : BE.concrete_ops t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) =
false
null
false
{ BE.to = mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu; BE.lone = bn_mont_one k n mu; BE.lmul = bn_mont_mul k n mu; BE.lsqr = bn_mont_sqr k n mu }
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Montgomery.mont", "FStar.Ghost.erased", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__bn", "Hacl.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "FStar.Ghost.reveal", "Hacl.Impl.Exponentiation.Definitions.Mkconcrete_ops", "Lib.IntTypes.op_Plus_Bang", "FStar.Ghost.hide", "Hacl.Impl.Exponentiation.Definitions.to_comm_monoid", "Hacl.Bignum.MontExponentiation.mk_to_nat_mont_ll_comm_monoid", "Hacl.Bignum.MontExponentiation.bn_mont_one", "Hacl.Bignum.MontExponentiation.bn_mont_mul", "Hacl.Bignum.MontExponentiation.bn_mont_sqr", "Hacl.Impl.Exponentiation.Definitions.concrete_ops" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.BM.bn.BN.len in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); BM.bn_mont_one len k.BM.from ctx_n mu ctx_r2 oneM inline_for_extraction noextract val bn_mont_mul: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_mont_sqr: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SM.bn_mont_sqr_lemma n mu (as_seq h0 aM); SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_mont_concrete_ops (t:limb_t) (k:BM.mont t) (n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) =
false
false
Hacl.Bignum.MontExponentiation.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 mk_bn_mont_concrete_ops (t: limb_t) (k: BM.mont t) (n: Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len))) (mu: limb t {SM.bn_mont_pre n mu}) : BE.concrete_ops t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len)
[]
Hacl.Bignum.MontExponentiation.mk_bn_mont_concrete_ops
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> k: Hacl.Bignum.Montgomery.mont t -> n: FStar.Ghost.erased (Hacl.Spec.Bignum.Definitions.lbignum t (Lib.IntTypes.v (Mkbn?.len (Mkmont?.bn k)))) -> mu: Hacl.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre (FStar.Ghost.reveal n) mu} -> Hacl.Impl.Exponentiation.Definitions.concrete_ops t (Mkbn?.len (Mkmont?.bn k)) (Mkbn?.len (Mkmont?.bn k) +! Mkbn?.len (Mkmont?.bn k))
{ "end_col": 31, "end_line": 130, "start_col": 2, "start_line": 127 }
Prims.Tot
val mk_to_nat_mont_ll_comm_monoid (t: limb_t) (len: BN.meta_len t) (n: BD.lbignum t (v len)) (mu: limb t {SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; }
val mk_to_nat_mont_ll_comm_monoid (t: limb_t) (len: BN.meta_len t) (n: BD.lbignum t (v len)) (mu: limb t {SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) let mk_to_nat_mont_ll_comm_monoid (t: limb_t) (len: BN.meta_len t) (n: BD.lbignum t (v len)) (mu: limb t {SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) =
false
null
false
{ BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n }
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "Hacl.Impl.Exponentiation.Definitions.Mkto_comm_monoid", "Lib.IntTypes.op_Plus_Bang", "Hacl.Bignum.MontExponentiation.a_spec", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Definitions.bn_v", "Lib.IntTypes.SEC", "Hacl.Bignum.MontExponentiation.linv_ctx", "Hacl.Bignum.MontExponentiation.linv", "Hacl.Bignum.MontExponentiation.refl", "Hacl.Impl.Exponentiation.Definitions.to_comm_monoid" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) =
false
false
Hacl.Bignum.MontExponentiation.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 mk_to_nat_mont_ll_comm_monoid (t: limb_t) (len: BN.meta_len t) (n: BD.lbignum t (v len)) (mu: limb t {SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len)
[]
Hacl.Bignum.MontExponentiation.mk_to_nat_mont_ll_comm_monoid
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> n: Hacl.Spec.Bignum.Definitions.lbignum t (Lib.IntTypes.v len) -> mu: Hacl.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre n mu} -> Hacl.Impl.Exponentiation.Definitions.to_comm_monoid t len (len +! len)
{ "end_col": 19, "end_line": 64, "start_col": 2, "start_line": 60 }
Prims.Tot
val linv_ctx (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len) (ctx: BD.lbignum t (len + len)) : Type0
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n
val linv_ctx (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len) (ctx: BD.lbignum t (len + len)) : Type0 let linv_ctx (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len) (ctx: BD.lbignum t (len + len)) : Type0 =
false
null
false
let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 ((2 * bits t) * len) % BD.bn_v n
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.op_Addition", "Prims.l_and", "Prims.eq2", "Lib.Sequence.lseq", "Hacl.Spec.Bignum.Definitions.limb", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.pow2", "FStar.Mul.op_Star", "Lib.IntTypes.bits", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.slice", "Prims.l_Forall", "Prims.nat", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.index", "Lib.Sequence.sub" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a
false
false
Hacl.Bignum.MontExponentiation.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 linv_ctx (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len) (ctx: BD.lbignum t (len + len)) : Type0
[]
Hacl.Bignum.MontExponentiation.linv_ctx
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> ctx: Hacl.Spec.Bignum.Definitions.lbignum t (len + len) -> Type0
{ "end_col": 71, "end_line": 49, "start_col": 105, "start_line": 45 }
Prims.Tot
val bn_mont_sqr: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SM.bn_mont_sqr_lemma n mu (as_seq h0 aM); SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.sqr ctx_n mu aM resM
val bn_mont_sqr: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_sqr #t k n mu ctx aM resM =
false
null
false
let h0 = ST.get () in SM.bn_mont_sqr_lemma n mu (as_seq h0 aM); SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.sqr ctx_n mu aM resM
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Montgomery.mont", "FStar.Ghost.erased", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__bn", "Hacl.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "FStar.Ghost.reveal", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Plus_Bang", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__sqr", "Prims.unit", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t", "Hacl.Spec.Bignum.Montgomery.bn_mont_mul_lemma", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.Montgomery.bn_mont_sqr_lemma", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.BM.bn.BN.len in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); BM.bn_mont_one len k.BM.from ctx_n mu ctx_r2 oneM inline_for_extraction noextract val bn_mont_mul: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_mont_sqr: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu)
false
false
Hacl.Bignum.MontExponentiation.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_mont_sqr: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu)
[]
Hacl.Bignum.MontExponentiation.bn_mont_sqr
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.Montgomery.mont t -> n: FStar.Ghost.erased (Hacl.Spec.Bignum.Definitions.lbignum t (Lib.IntTypes.v (Mkbn?.len (Mkmont?.bn k)))) -> mu: Hacl.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre (FStar.Ghost.reveal n) mu} -> Hacl.Impl.Exponentiation.Definitions.lsqr_st t (Mkbn?.len (Mkmont?.bn k)) (Mkbn?.len (Mkmont?.bn k) +! Mkbn?.len (Mkmont?.bn k)) (Hacl.Bignum.MontExponentiation.mk_to_nat_mont_ll_comm_monoid t (Mkbn?.len (Mkmont?.bn k)) (FStar.Ghost.reveal n) mu)
{ "end_col": 27, "end_line": 116, "start_col": 39, "start_line": 111 }
Prims.Tot
val bn_mont_mul: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.mul ctx_n mu aM bM resM
val bn_mont_mul: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_mul #t k n mu ctx aM bM resM =
false
null
false
let h0 = ST.get () in SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.mul ctx_n mu aM bM resM
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Montgomery.mont", "FStar.Ghost.erased", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__bn", "Hacl.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "FStar.Ghost.reveal", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Plus_Bang", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__mul", "Prims.unit", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t", "Hacl.Spec.Bignum.Montgomery.bn_mont_mul_lemma", "Lib.Buffer.as_seq", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.BM.bn.BN.len in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); BM.bn_mont_one len k.BM.from ctx_n mu ctx_r2 oneM inline_for_extraction noextract val bn_mont_mul: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu)
false
false
Hacl.Bignum.MontExponentiation.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_mont_mul: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu)
[]
Hacl.Bignum.MontExponentiation.bn_mont_mul
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.Montgomery.mont t -> n: FStar.Ghost.erased (Hacl.Spec.Bignum.Definitions.lbignum t (Lib.IntTypes.v (Mkbn?.len (Mkmont?.bn k)))) -> mu: Hacl.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre (FStar.Ghost.reveal n) mu} -> Hacl.Impl.Exponentiation.Definitions.lmul_st t (Mkbn?.len (Mkmont?.bn k)) (Mkbn?.len (Mkmont?.bn k) +! Mkbn?.len (Mkmont?.bn k)) (Hacl.Bignum.MontExponentiation.mk_to_nat_mont_ll_comm_monoid t (Mkbn?.len (Mkmont?.bn k)) (FStar.Ghost.reveal n) mu)
{ "end_col": 30, "end_line": 99, "start_col": 42, "start_line": 95 }
Prims.Tot
val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.BM.bn.BN.len in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); BM.bn_mont_one len k.BM.from ctx_n mu ctx_r2 oneM
val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_one #t k n mu ctx oneM =
false
null
false
[@@ inline_let ]let len = k.BM.bn.BN.len in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); BM.bn_mont_one len k.BM.from ctx_n mu ctx_r2 oneM
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Montgomery.mont", "FStar.Ghost.erased", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__bn", "Hacl.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "FStar.Ghost.reveal", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Plus_Bang", "Hacl.Bignum.Montgomery.bn_mont_one", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__from", "Prims.unit", "Hacl.Spec.Bignum.Montgomery.bn_mont_one_lemma", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.meta_len" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu)
false
false
Hacl.Bignum.MontExponentiation.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu)
[]
Hacl.Bignum.MontExponentiation.bn_mont_one
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.Montgomery.mont t -> n: FStar.Ghost.erased (Hacl.Spec.Bignum.Definitions.lbignum t (Lib.IntTypes.v (Mkbn?.len (Mkmont?.bn k)))) -> mu: Hacl.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre (FStar.Ghost.reveal n) mu} -> Hacl.Impl.Exponentiation.Definitions.lone_st t (Mkbn?.len (Mkmont?.bn k)) (Mkbn?.len (Mkmont?.bn k) +! Mkbn?.len (Mkmont?.bn k)) (Hacl.Bignum.MontExponentiation.mk_to_nat_mont_ll_comm_monoid t (Mkbn?.len (Mkmont?.bn k)) (FStar.Ghost.reveal n) mu)
{ "end_col": 51, "end_line": 83, "start_col": 2, "start_line": 78 }
FStar.HyperStack.ST.Stack
val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx))
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2)
val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx =
true
null
false
let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2)
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims._assert", "Prims.eq2", "Lib.Sequence.lseq", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.v", "Lib.Sequence.sub", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Prims.unit", "Lib.Sequence.eq_intro", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.update_sub", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.BM.bn.BN.len in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); BM.bn_mont_one len k.BM.from ctx_n mu ctx_r2 oneM inline_for_extraction noextract val bn_mont_mul: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_mont_sqr: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SM.bn_mont_sqr_lemma n mu (as_seq h0 aM); SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_mont_concrete_ops (t:limb_t) (k:BM.mont t) (n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu; BE.lone = bn_mont_one k n mu; BE.lmul = bn_mont_mul k n mu; BE.lsqr = bn_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx))
false
false
Hacl.Bignum.MontExponentiation.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 mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx))
[]
Hacl.Bignum.MontExponentiation.mk_ctx
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len t -> n: Hacl.Bignum.Definitions.lbignum t len -> r2: Hacl.Bignum.Definitions.lbignum t len -> ctx: Hacl.Bignum.Definitions.lbignum t (len +! len) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 67, "end_line": 161, "start_col": 28, "start_line": 150 }
Prims.Tot
val bn_exp_mont_fw_vartime: #t:limb_t -> k:BM.mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.BM.bn.BN.len <= max_size_t} -> bn_exp_mont_st t k.BM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_mont_fw_vartime #t k l n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_vartime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b) (v l); pop_frame ()
val bn_exp_mont_fw_vartime: #t:limb_t -> k:BM.mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.BM.bn.BN.len <= max_size_t} -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_fw_vartime #t k l n mu r2 aM bBits b resM =
false
null
false
push_frame (); let h0 = ST.get () in [@@ inline_let ]let len = k.BM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_vartime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b) (v l); pop_frame ()
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Montgomery.mont", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.bits", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Prims.pow2", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__bn", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Lib.Exponentiation.exp_fw_lemma", "Lib.NatMod.nat_mod", "Hacl.Bignum.Definitions.bn_v", "FStar.Ghost.reveal", "Lib.Exponentiation.Definition.comm_monoid", "Hacl.Impl.Exponentiation.lexp_fw_vartime", "Lib.IntTypes.op_Plus_Bang", "Hacl.Bignum.MontExponentiation.mk_bn_mont_concrete_ops", "FStar.Ghost.hide", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Bignum.MontExponentiation.mk_ctx", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.add", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.Ghost.erased", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_Subtraction", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "Hacl.Spec.Bignum.Definitions.blocks0", "Hacl.Bignum.meta_len", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.BM.bn.BN.len in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); BM.bn_mont_one len k.BM.from ctx_n mu ctx_r2 oneM inline_for_extraction noextract val bn_mont_mul: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_mont_sqr: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SM.bn_mont_sqr_lemma n mu (as_seq h0 aM); SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_mont_concrete_ops (t:limb_t) (k:BM.mont t) (n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu; BE.lone = bn_mont_one k n mu; BE.lmul = bn_mont_mul k n mu; BE.lsqr = bn_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n inline_for_extraction noextract let bn_exp_mont_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> mu:limb t -> r2:lbignum t len -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM == LE.pow k1 (bn_v h0 aM) (bn_v h0 b))) // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_bm_vartime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_bm_vartime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_rl_vartime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_rl_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_bm_consttime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_bm_consttime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_mont_ladder_swap_consttime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_mont_ladder_swap_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); LE.exp_mont_ladder_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); pop_frame () // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_fw_vartime: #t:limb_t -> k:BM.mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.BM.bn.BN.len <= max_size_t} -> bn_exp_mont_st t k.BM.bn.BN.len
false
false
Hacl.Bignum.MontExponentiation.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_exp_mont_fw_vartime: #t:limb_t -> k:BM.mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.BM.bn.BN.len <= max_size_t} -> bn_exp_mont_st t k.BM.bn.BN.len
[]
Hacl.Bignum.MontExponentiation.bn_exp_mont_fw_vartime
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.Montgomery.mont t -> l: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v l /\ Lib.IntTypes.v l < Lib.IntTypes.bits Lib.IntTypes.U32 /\ Prims.pow2 (Lib.IntTypes.v l) * Lib.IntTypes.v (Mkbn?.len (Mkmont?.bn k)) <= Lib.IntTypes.max_size_t } -> Hacl.Bignum.MontExponentiation.bn_exp_mont_st t (Mkbn?.len (Mkmont?.bn k))
{ "end_col": 14, "end_line": 256, "start_col": 2, "start_line": 246 }
Prims.Tot
val bn_exp_mont_fw_consttime: #t:limb_t -> k:BM.mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.BM.bn.BN.len <= max_size_t} -> bn_exp_mont_st t k.BM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_mont_fw_consttime #t k l n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_consttime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b) (v l); pop_frame ()
val bn_exp_mont_fw_consttime: #t:limb_t -> k:BM.mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.BM.bn.BN.len <= max_size_t} -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_fw_consttime #t k l n mu r2 aM bBits b resM =
false
null
false
push_frame (); let h0 = ST.get () in [@@ inline_let ]let len = k.BM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_consttime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b) (v l); pop_frame ()
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Montgomery.mont", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.bits", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Prims.pow2", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__bn", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Lib.Exponentiation.exp_fw_lemma", "Lib.NatMod.nat_mod", "Hacl.Bignum.Definitions.bn_v", "FStar.Ghost.reveal", "Lib.Exponentiation.Definition.comm_monoid", "Hacl.Impl.Exponentiation.lexp_fw_consttime", "Lib.IntTypes.op_Plus_Bang", "Hacl.Bignum.MontExponentiation.mk_bn_mont_concrete_ops", "FStar.Ghost.hide", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Bignum.MontExponentiation.mk_ctx", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.add", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.Ghost.erased", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_Subtraction", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "Hacl.Spec.Bignum.Definitions.blocks0", "Hacl.Bignum.meta_len", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.BM.bn.BN.len in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); BM.bn_mont_one len k.BM.from ctx_n mu ctx_r2 oneM inline_for_extraction noextract val bn_mont_mul: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_mont_sqr: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SM.bn_mont_sqr_lemma n mu (as_seq h0 aM); SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_mont_concrete_ops (t:limb_t) (k:BM.mont t) (n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu; BE.lone = bn_mont_one k n mu; BE.lmul = bn_mont_mul k n mu; BE.lsqr = bn_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n inline_for_extraction noextract let bn_exp_mont_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> mu:limb t -> r2:lbignum t len -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM == LE.pow k1 (bn_v h0 aM) (bn_v h0 b))) // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_bm_vartime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_bm_vartime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_rl_vartime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_rl_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_bm_consttime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_bm_consttime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_mont_ladder_swap_consttime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_mont_ladder_swap_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); LE.exp_mont_ladder_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); pop_frame () // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_fw_vartime: #t:limb_t -> k:BM.mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.BM.bn.BN.len <= max_size_t} -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_fw_vartime #t k l n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_vartime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b) (v l); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_fw_consttime: #t:limb_t -> k:BM.mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.BM.bn.BN.len <= max_size_t} -> bn_exp_mont_st t k.BM.bn.BN.len
false
false
Hacl.Bignum.MontExponentiation.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_exp_mont_fw_consttime: #t:limb_t -> k:BM.mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.BM.bn.BN.len <= max_size_t} -> bn_exp_mont_st t k.BM.bn.BN.len
[]
Hacl.Bignum.MontExponentiation.bn_exp_mont_fw_consttime
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.Montgomery.mont t -> l: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v l /\ Lib.IntTypes.v l < Lib.IntTypes.bits Lib.IntTypes.U32 /\ Prims.pow2 (Lib.IntTypes.v l) * Lib.IntTypes.v (Mkbn?.len (Mkmont?.bn k)) <= Lib.IntTypes.max_size_t } -> Hacl.Bignum.MontExponentiation.bn_exp_mont_st t (Mkbn?.len (Mkmont?.bn k))
{ "end_col": 14, "end_line": 278, "start_col": 2, "start_line": 268 }
Prims.Tot
val bn_exp_mont_bm_vartime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_mont_bm_vartime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_rl_vartime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_rl_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); pop_frame ()
val bn_exp_mont_bm_vartime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_bm_vartime #t k n mu r2 aM bBits b resM =
false
null
false
push_frame (); let h0 = ST.get () in [@@ inline_let ]let len = k.BM.bn.BN.len in [@@ inline_let ]let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_rl_vartime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_rl_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); pop_frame ()
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Montgomery.mont", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__bn", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Lib.Exponentiation.exp_rl_lemma", "Lib.NatMod.nat_mod", "Hacl.Bignum.Definitions.bn_v", "FStar.Ghost.reveal", "Lib.Exponentiation.Definition.comm_monoid", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Exponentiation.lexp_rl_vartime", "Lib.IntTypes.op_Plus_Bang", "Hacl.Bignum.MontExponentiation.mk_bn_mont_concrete_ops", "FStar.Ghost.hide", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Bignum.MontExponentiation.mk_ctx", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.add", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.Ghost.erased", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "Hacl.Spec.Bignum.Definitions.blocks0", "Hacl.Bignum.meta_len", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.BM.bn.BN.len in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); BM.bn_mont_one len k.BM.from ctx_n mu ctx_r2 oneM inline_for_extraction noextract val bn_mont_mul: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_mont_sqr: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SM.bn_mont_sqr_lemma n mu (as_seq h0 aM); SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_mont_concrete_ops (t:limb_t) (k:BM.mont t) (n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu; BE.lone = bn_mont_one k n mu; BE.lmul = bn_mont_mul k n mu; BE.lsqr = bn_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n inline_for_extraction noextract let bn_exp_mont_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> mu:limb t -> r2:lbignum t len -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM == LE.pow k1 (bn_v h0 aM) (bn_v h0 b))) // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_bm_vartime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len
false
false
Hacl.Bignum.MontExponentiation.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_exp_mont_bm_vartime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len
[]
Hacl.Bignum.MontExponentiation.bn_exp_mont_bm_vartime
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.Montgomery.mont t -> Hacl.Bignum.MontExponentiation.bn_exp_mont_st t (Mkbn?.len (Mkmont?.bn k))
{ "end_col": 14, "end_line": 216, "start_col": 2, "start_line": 206 }
Prims.Tot
val bn_exp_mont_bm_consttime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_mont_bm_consttime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_mont_ladder_swap_consttime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_mont_ladder_swap_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); LE.exp_mont_ladder_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); pop_frame ()
val bn_exp_mont_bm_consttime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_bm_consttime #t k n mu r2 aM bBits b resM =
false
null
false
push_frame (); let h0 = ST.get () in [@@ inline_let ]let len = k.BM.bn.BN.len in [@@ inline_let ]let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_mont_ladder_swap_consttime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_mont_ladder_swap_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); LE.exp_mont_ladder_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); pop_frame ()
{ "checked_file": "Hacl.Bignum.MontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.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.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Montgomery.mont", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__bn", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Lib.Exponentiation.exp_mont_ladder_lemma", "Lib.NatMod.nat_mod", "Hacl.Bignum.Definitions.bn_v", "FStar.Ghost.reveal", "Lib.Exponentiation.Definition.comm_monoid", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Exponentiation.exp_mont_ladder_swap_lemma", "Hacl.Impl.Exponentiation.lexp_mont_ladder_swap_consttime", "Lib.IntTypes.op_Plus_Bang", "Hacl.Bignum.MontExponentiation.mk_bn_mont_concrete_ops", "FStar.Ghost.hide", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Bignum.MontExponentiation.mk_ctx", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.add", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.Ghost.erased", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "Hacl.Spec.Bignum.Definitions.blocks0", "Hacl.Bignum.meta_len", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Bignum.MontExponentiation 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 LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module S = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // All operations are performed in the Montgomery domain! inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < BD.bn_v n inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_mont_one: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.BM.bn.BN.len in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); BM.bn_mont_one len k.BM.from ctx_n mu ctx_r2 oneM inline_for_extraction noextract val bn_mont_mul: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_mont_sqr: #t:limb_t -> k:BM.mont t -> n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu) let bn_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SM.bn_mont_sqr_lemma n mu (as_seq h0 aM); SM.bn_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); let ctx_n = sub ctx 0ul k.BM.bn.BN.len in k.BM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_mont_concrete_ops (t:limb_t) (k:BM.mont t) (n:Ghost.erased (BD.lbignum t (v k.BM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.BM.bn.BN.len (k.BM.bn.BN.len +! k.BM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.BM.bn.BN.len n mu; BE.lone = bn_mont_one k n mu; BE.lmul = bn_mont_mul k n mu; BE.lsqr = bn_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n inline_for_extraction noextract let bn_exp_mont_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> mu:limb t -> r2:lbignum t len -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM == LE.pow k1 (bn_v h0 aM) (bn_v h0 b))) // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_bm_vartime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len let bn_exp_mont_bm_vartime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.BM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_rl_vartime len (len +! len) (mk_bn_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_rl_lemma k1 (bn_v h0 aM) (v bBits) (bn_v h0 b); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_mont_bm_consttime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len
false
false
Hacl.Bignum.MontExponentiation.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_exp_mont_bm_consttime: #t:limb_t -> k:BM.mont t -> bn_exp_mont_st t k.BM.bn.BN.len
[]
Hacl.Bignum.MontExponentiation.bn_exp_mont_bm_consttime
{ "file_name": "code/bignum/Hacl.Bignum.MontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.Montgomery.mont t -> Hacl.Bignum.MontExponentiation.bn_exp_mont_st t (Mkbn?.len (Mkmont?.bn k))
{ "end_col": 14, "end_line": 234, "start_col": 2, "start_line": 223 }
FStar.Pervasives.Lemma
val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs))))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl
val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs =
false
null
true
match xs with | [] -> () | hd :: tl -> mem_existsb f tl
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.bool", "Prims.list", "FStar.List.Tot.Properties.mem_existsb", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs))))
false
false
FStar.List.Tot.Properties.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_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs))))
[ "recursion" ]
FStar.List.Tot.Properties.mem_existsb
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> Prims.bool) -> xs: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.existsb f xs <==> (exists (x: a). f x = true /\ FStar.List.Tot.Base.mem x xs))
{ "end_col": 30, "end_line": 107, "start_col": 2, "start_line": 105 }
FStar.Pervasives.Lemma
val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc)
val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc =
false
null
true
match l with | [] -> () | hd :: tl -> rev_acc_length tl (hd :: acc)
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.rev_acc_length", "Prims.Cons", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc))
[ "recursion" ]
FStar.List.Tot.Properties.rev_acc_length
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list 'a -> acc: Prims.list 'a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.length (FStar.List.Tot.Base.rev_acc l acc) = FStar.List.Tot.Base.length l + FStar.List.Tot.Base.length acc)
{ "end_col": 43, "end_line": 126, "start_col": 31, "start_line": 124 }
FStar.Pervasives.Lemma
val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_mem l x = rev_memP l x
val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x =
false
null
true
rev_memP l x
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.list", "FStar.List.Tot.Properties.rev_memP", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l))
[]
FStar.List.Tot.Properties.rev_mem
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list a -> x: a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.mem x (FStar.List.Tot.Base.rev l) <==> FStar.List.Tot.Base.mem x l)
{ "end_col": 30, "end_line": 149, "start_col": 18, "start_line": 149 }
FStar.Pervasives.Lemma
val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2
val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 =
false
null
true
match l with | [] -> () | hd :: tl -> append_inv_head tl l1 l2
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.append_inv_head", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2)))
false
false
FStar.List.Tot.Properties.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_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2))
[ "recursion" ]
FStar.List.Tot.Properties.append_inv_head
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list 'a -> l1: Prims.list 'a -> l2: Prims.list 'a -> FStar.Pervasives.Lemma (requires l @ l1 == l @ l2) (ensures l1 == l2)
{ "end_col": 40, "end_line": 242, "start_col": 34, "start_line": 240 }
FStar.Pervasives.Lemma
val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs))))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl
val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs =
false
null
true
match xs with | [] -> () | hd :: tl -> memP_existsb f tl
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.bool", "Prims.list", "FStar.List.Tot.Properties.memP_existsb", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs))))
false
false
FStar.List.Tot.Properties.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_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs))))
[ "recursion" ]
FStar.List.Tot.Properties.memP_existsb
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> Prims.bool) -> xs: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.existsb f xs <==> (exists (x: a). f x = true /\ FStar.List.Tot.Base.memP x xs))
{ "end_col": 31, "end_line": 66, "start_col": 2, "start_line": 64 }
FStar.Pervasives.Lemma
val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a
val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem #t l1 l2 a =
false
null
true
match l1 with | [] -> () | hd :: tl -> append_mem tl l2 a
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.list", "FStar.List.Tot.Properties.append_mem", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2)))
false
false
FStar.List.Tot.Properties.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_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2)))
[ "recursion" ]
FStar.List.Tot.Properties.append_mem
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list t -> l2: Prims.list t -> a: t -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.mem a (l1 @ l2) = (FStar.List.Tot.Base.mem a l1 || FStar.List.Tot.Base.mem a l2))
{ "end_col": 32, "end_line": 199, "start_col": 32, "start_line": 197 }
FStar.Pervasives.Lemma
val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3
val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 =
false
null
true
match l1 with | [] -> () | hd :: tl -> append_assoc tl l2 l3
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.append_assoc", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3)))
[ "recursion" ]
FStar.List.Tot.Properties.append_assoc
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list 'a -> l2: Prims.list 'a -> l3: Prims.list 'a -> FStar.Pervasives.Lemma (ensures l1 @ l2 @ l3 == (l1 @ l2) @ l3)
{ "end_col": 37, "end_line": 182, "start_col": 32, "start_line": 180 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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 llist a (n:nat) = l:list a {length l = n}
let llist a (n: nat) =
false
null
false
l: list a {length l = n}
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "total" ]
[ "Prims.nat", "Prims.list", "Prims.b2t", "Prims.op_Equality", "FStar.List.Tot.Base.length" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base
false
true
FStar.List.Tot.Properties.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 llist : a: Type -> n: Prims.nat -> Type
[]
FStar.List.Tot.Properties.llist
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> n: Prims.nat -> Type
{ "end_col": 45, "end_line": 26, "start_col": 22, "start_line": 26 }
FStar.Pervasives.Lemma
val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1))))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2
val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 =
false
null
true
rev_rev' l1; rev_rev' l2; rev_rev' (l1 @ l2); rev'_append l1 l2
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.rev'_append", "Prims.unit", "FStar.List.Tot.Properties.rev_rev'", "FStar.List.Tot.Base.op_At" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1))))
[]
FStar.List.Tot.Properties.rev_append
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list 'a -> l2: Prims.list 'a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.rev (l1 @ l2) == FStar.List.Tot.Base.rev l2 @ FStar.List.Tot.Base.rev l1)
{ "end_col": 84, "end_line": 343, "start_col": 23, "start_line": 343 }
FStar.Pervasives.Lemma
val mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)]
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q
val mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] =
false
null
true
match l with | [] -> () | a :: q -> mem_memP x q
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.list", "FStar.List.Tot.Properties.mem_memP", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_iff", "Prims.b2t", "FStar.List.Tot.Base.mem", "FStar.List.Tot.Base.memP", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.bool", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l))
false
false
FStar.List.Tot.Properties.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_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)]
[ "recursion" ]
FStar.List.Tot.Properties.mem_memP
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> l: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.mem x l <==> FStar.List.Tot.Base.memP x l) [SMTPat (FStar.List.Tot.Base.mem x l); SMTPat (FStar.List.Tot.Base.memP x l)]
{ "end_col": 26, "end_line": 42, "start_col": 2, "start_line": 40 }
FStar.Pervasives.Lemma
val lemma_index_memP (#t: Type) (l: list t) (i: nat{i < length l}) : Lemma (ensures ((index l i) `memP` l)) [SMTPat ((index l i) `memP` l)]
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1)
val lemma_index_memP (#t: Type) (l: list t) (i: nat{i < length l}) : Lemma (ensures ((index l i) `memP` l)) [SMTPat ((index l i) `memP` l)] let rec lemma_index_memP (#t: Type) (l: list t) (i: nat{i < length l}) : Lemma (ensures ((index l i) `memP` l)) [SMTPat ((index l i) `memP` l)] =
false
null
true
match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1)
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "Prims.int", "FStar.List.Tot.Properties.lemma_index_memP", "FStar.List.Tot.Base.tl", "Prims.op_Subtraction", "Prims.unit", "Prims.l_True", "Prims.squash", "FStar.List.Tot.Base.memP", "FStar.List.Tot.Base.index", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l))
false
false
FStar.List.Tot.Properties.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_index_memP (#t: Type) (l: list t) (i: nat{i < length l}) : Lemma (ensures ((index l i) `memP` l)) [SMTPat ((index l i) `memP` l)]
[ "recursion" ]
FStar.List.Tot.Properties.lemma_index_memP
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list t -> i: Prims.nat{i < FStar.List.Tot.Base.length l} -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.memP (FStar.List.Tot.Base.index l i) l) [SMTPat (FStar.List.Tot.Base.memP (FStar.List.Tot.Base.index l i) l)]
{ "end_col": 40, "end_line": 51, "start_col": 2, "start_line": 49 }
FStar.Pervasives.Lemma
val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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 lemma_snoc_length (l, x) = append_length l [x]
val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) =
false
null
true
append_length l [x]
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "FStar.Pervasives.Native.tuple2", "Prims.list", "FStar.List.Tot.Properties.append_length", "Prims.Cons", "Prims.Nil", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1))
[]
FStar.List.Tot.Properties.lemma_snoc_length
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
lx: (Prims.list 'a * 'a) -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.length (FStar.List.Tot.Base.snoc lx) = FStar.List.Tot.Base.length (FStar.Pervasives.Native.fst lx) + 1)
{ "end_col": 50, "end_line": 362, "start_col": 31, "start_line": 362 }
FStar.Pervasives.Lemma
val append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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 append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2
val append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) =
false
null
true
append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.append_length_inv_head", "Prims.unit", "FStar.List.Tot.Properties.append_length", "Prims.l_and", "Prims.eq2", "FStar.List.Tot.Base.append", "Prims.nat", "FStar.List.Tot.Base.length", "Prims.squash", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2))
false
false
FStar.List.Tot.Properties.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_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2))
[]
FStar.List.Tot.Properties.append_length_inv_tail
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
left1: Prims.list a -> right1: Prims.list a -> left2: Prims.list a -> right2: Prims.list a -> FStar.Pervasives.Lemma (requires left1 @ right1 == left2 @ right2 /\ FStar.List.Tot.Base.length right1 == FStar.List.Tot.Base.length right2) (ensures left1 == left2 /\ right1 == right2)
{ "end_col": 50, "end_line": 283, "start_col": 2, "start_line": 281 }
FStar.Pervasives.Lemma
val memP_map_elim (#a #b: Type) (f: (a -> Tot b)) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x: a). memP x l /\ f x == y))) (decreases l)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q
val memP_map_elim (#a #b: Type) (f: (a -> Tot b)) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x: a). memP x l /\ f x == y))) (decreases l) let rec memP_map_elim (#a #b: Type) (f: (a -> Tot b)) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x: a). memP x l /\ f x == y))) (decreases l) =
false
null
true
match l with | [] -> () | _ :: q -> memP_map_elim f y q
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma", "" ]
[ "Prims.list", "FStar.List.Tot.Properties.memP_map_elim", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "FStar.List.Tot.Base.memP", "FStar.List.Tot.Base.map", "Prims.l_Exists", "Prims.l_and", "Prims.eq2", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y)))
false
false
FStar.List.Tot.Properties.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_map_elim (#a #b: Type) (f: (a -> Tot b)) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x: a). memP x l /\ f x == y))) (decreases l)
[ "recursion" ]
FStar.List.Tot.Properties.memP_map_elim
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> b) -> y: b -> l: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.memP y (FStar.List.Tot.Base.map f l) ==> (exists (x: a). FStar.List.Tot.Base.memP x l /\ f x == y)) (decreases l)
{ "end_col": 33, "end_line": 92, "start_col": 2, "start_line": 90 }
FStar.Pervasives.Lemma
val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a
val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a =
false
null
true
match l1 with | [] -> () | hd :: tl -> append_count tl l2 a
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.list", "FStar.List.Tot.Properties.append_count", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2)))
[ "recursion" ]
FStar.List.Tot.Properties.append_count
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list t -> l2: Prims.list t -> a: t -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.count a (l1 @ l2) = FStar.List.Tot.Base.count a l1 + FStar.List.Tot.Base.count a l2)
{ "end_col": 34, "end_line": 216, "start_col": 34, "start_line": 214 }
FStar.Pervasives.Lemma
val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_ind p l = rev'_involutive l; rev'_list_ind p (rev' l)
val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l =
false
null
true
rev'_involutive l; rev'_list_ind p (rev' l)
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.bool", "FStar.List.Tot.Properties.rev'_list_ind", "FStar.List.Tot.Properties.rev'", "Prims.unit", "FStar.List.Tot.Properties.rev'_involutive" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl]))))
false
false
FStar.List.Tot.Properties.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_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l))
[]
FStar.List.Tot.Properties.rev_ind
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
p: (_: Prims.list 'a -> Prims.bool) -> l: Prims.list 'a -> FStar.Pervasives.Lemma (requires p [] /\ (forall (hd: Prims.list 'a) (tl: 'a). p hd ==> p (hd @ [tl]))) (ensures p l)
{ "end_col": 61, "end_line": 376, "start_col": 18, "start_line": 376 }
FStar.Pervasives.Lemma
val append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2
val append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) =
false
null
true
match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma", "" ]
[ "Prims.list", "FStar.List.Tot.Properties.append_length_inv_head", "FStar.List.Tot.Base.tl", "Prims.unit", "Prims.l_and", "Prims.eq2", "FStar.List.Tot.Base.append", "Prims.nat", "FStar.List.Tot.Base.length", "Prims.squash", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2))
false
false
FStar.List.Tot.Properties.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_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1)
[ "recursion" ]
FStar.List.Tot.Properties.append_length_inv_head
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
left1: Prims.list a -> right1: Prims.list a -> left2: Prims.list a -> right2: Prims.list a -> FStar.Pervasives.Lemma (requires left1 @ right1 == left2 @ right2 /\ FStar.List.Tot.Base.length left1 == FStar.List.Tot.Base.length left2) (ensures left1 == left2 /\ right1 == right2) (decreases left1)
{ "end_col": 58, "end_line": 273, "start_col": 2, "start_line": 270 }
Prims.GTot
val index_of (#t: Type) (l: list t) (x: t{x `memP` l}) : GTot (i: nat{i < length l /\ index l i == x})
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x )
val index_of (#t: Type) (l: list t) (x: t{x `memP` l}) : GTot (i: nat{i < length l /\ index l i == x}) let rec index_of (#t: Type) (l: list t) (x: t{x `memP` l}) : GTot (i: nat{i < length l /\ index l i == x}) =
false
null
false
match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then (0) else (1 + index_of rest x)
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "sometrivial" ]
[ "Prims.list", "FStar.List.Tot.Base.memP", "FStar.StrongExcludedMiddle.strong_excluded_middle", "Prims.eq2", "Prims.bool", "Prims.op_Addition", "FStar.List.Tot.Properties.index_of", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) :
false
false
FStar.List.Tot.Properties.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_of (#t: Type) (l: list t) (x: t{x `memP` l}) : GTot (i: nat{i < length l /\ index l i == x})
[ "recursion" ]
FStar.List.Tot.Properties.index_of
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list t -> x: t{FStar.List.Tot.Base.memP x l} -> Prims.GTot (i: Prims.nat{i < FStar.List.Tot.Base.length l /\ FStar.List.Tot.Base.index l i == x})
{ "end_col": 5, "end_line": 516, "start_col": 2, "start_line": 509 }
FStar.Pervasives.Lemma
val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_memP #a l x = rev_acc_memP l [] x
val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x =
false
null
true
rev_acc_memP l [] x
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.rev_acc_memP", "Prims.Nil", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l))
[]
FStar.List.Tot.Properties.rev_memP
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list a -> x: a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.memP x (FStar.List.Tot.Base.rev l) <==> FStar.List.Tot.Base.memP x l)
{ "end_col": 41, "end_line": 144, "start_col": 22, "start_line": 144 }
FStar.Pervasives.Lemma
val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))]
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2
val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 =
false
null
true
match l1 with | [] -> () | hd :: tl -> append_length tl l2
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.append_length", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))]
[ "recursion" ]
FStar.List.Tot.Properties.append_length
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list 'a -> l2: Prims.list 'a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.length (l1 @ l2) = FStar.List.Tot.Base.length l1 + FStar.List.Tot.Base.length l2) [SMTPat (FStar.List.Tot.Base.length (l1 @ l2))]
{ "end_col": 33, "end_line": 189, "start_col": 30, "start_line": 187 }
FStar.Pervasives.Lemma
val assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y. ~(memP (x, y) l))) (decreases l)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y . ~ (memP (x, y) l))) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_memP_none x q
val assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y. ~(memP (x, y) l))) (decreases l) let rec assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y. ~(memP (x, y) l))) (decreases l) =
false
null
true
match l with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_memP_none x q
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma", "" ]
[ "Prims.eqtype", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.op_Equality", "Prims._assert", "Prims.l_False", "Prims.bool", "FStar.List.Tot.Properties.assoc_memP_none", "Prims.unit", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.List.Tot.Base.assoc", "FStar.Pervasives.Native.None", "Prims.squash", "Prims.l_Forall", "Prims.l_not", "FStar.List.Tot.Base.memP", "FStar.Pervasives.Native.Mktuple2", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2 let rec assoc_append_elim_l (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l1 == None)) (ensures (assoc x (l1 @ l2) == assoc x l2)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_append_elim_l x q l2 let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q let rec assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y . ~ (memP (x, y) l)))
false
false
FStar.List.Tot.Properties.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_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y. ~(memP (x, y) l))) (decreases l)
[ "recursion" ]
FStar.List.Tot.Properties.assoc_memP_none
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> l: Prims.list (a * b) -> FStar.Pervasives.Lemma (requires FStar.List.Tot.Base.assoc x l == FStar.Pervasives.Native.None) (ensures forall (y: b). ~(FStar.List.Tot.Base.memP (x, y) l)) (decreases l)
{ "end_col": 72, "end_line": 781, "start_col": 2, "start_line": 779 }
FStar.Pervasives.Lemma
val mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb
val mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) =
false
null
true
match la with | [] -> () | hd :: tl -> mem_subset tl lb
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.list", "FStar.List.Tot.Properties.mem_subset", "Prims.unit", "Prims.l_Forall", "Prims.l_imp", "Prims.b2t", "FStar.List.Tot.Base.mem", "Prims.squash", "FStar.List.Tot.Base.subset", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb))
false
false
FStar.List.Tot.Properties.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_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb))
[ "recursion" ]
FStar.List.Tot.Properties.mem_subset
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
la: Prims.list a -> lb: Prims.list a -> FStar.Pervasives.Lemma (requires forall (x: a). FStar.List.Tot.Base.mem x la ==> FStar.List.Tot.Base.mem x lb) (ensures FStar.List.Tot.Base.subset la lb)
{ "end_col": 32, "end_line": 582, "start_col": 2, "start_line": 580 }
FStar.Pervasives.Lemma
val assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y. assoc x l == Some y)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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 assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y . assoc x l == Some y))) = match assoc x l with | None -> assoc_memP_none x l; mem_memP x (map fst l); memP_map_elim fst x l | Some y -> assoc_memP_some x y l; memP_map_intro fst (x, y) l; mem_memP x (map fst l)
val assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y. assoc x l == Some y))) let assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y. assoc x l == Some y))) =
false
null
true
match assoc x l with | None -> assoc_memP_none x l; mem_memP x (map fst l); memP_map_elim fst x l | Some y -> assoc_memP_some x y l; memP_map_intro fst (x, y) l; mem_memP x (map fst l)
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.list", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.assoc", "FStar.List.Tot.Properties.memP_map_elim", "FStar.Pervasives.Native.fst", "Prims.unit", "FStar.List.Tot.Properties.mem_memP", "FStar.List.Tot.Base.map", "FStar.List.Tot.Properties.assoc_memP_none", "FStar.List.Tot.Properties.memP_map_intro", "FStar.Pervasives.Native.Mktuple2", "FStar.List.Tot.Properties.assoc_memP_some", "Prims.l_True", "Prims.squash", "Prims.l_iff", "Prims.b2t", "FStar.List.Tot.Base.mem", "Prims.l_Exists", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Some", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2 let rec assoc_append_elim_l (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l1 == None)) (ensures (assoc x (l1 @ l2) == assoc x l2)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_append_elim_l x q l2 let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q let rec assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y . ~ (memP (x, y) l))) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_memP_none x q let assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma
false
false
FStar.List.Tot.Properties.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_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y. assoc x l == Some y)))
[]
FStar.List.Tot.Properties.assoc_mem
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> l: Prims.list (a * b) -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.mem x (FStar.List.Tot.Base.map FStar.Pervasives.Native.fst l) <==> (exists (y: b). FStar.List.Tot.Base.assoc x l == FStar.Pervasives.Native.Some y))
{ "end_col": 26, "end_line": 798, "start_col": 2, "start_line": 790 }
FStar.Pervasives.Lemma
val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l)))))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl
val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count_forall #a f l =
false
null
true
match l with | [] -> () | hd :: tl -> partition_count_forall f tl
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.bool", "Prims.list", "FStar.List.Tot.Properties.partition_count_forall", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l)))))
false
false
FStar.List.Tot.Properties.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_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l)))))
[ "recursion" ]
FStar.List.Tot.Properties.partition_count_forall
{ "file_name": "ulib/FStar.List.Tot.Properties.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.count x l = FStar.List.Tot.Base.count x (FStar.Pervasives.Native.fst (FStar.List.Tot.Base.partition f l)) + FStar.List.Tot.Base.count x (FStar.Pervasives.Native.snd (FStar.List.Tot.Base.partition f l)))
{ "end_col": 41, "end_line": 573, "start_col": 39, "start_line": 571 }
FStar.Pervasives.Lemma
val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l
val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l =
false
null
true
rev_rev' l; rev_rev' (rev' l); rev'_involutive l
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.rev'_involutive", "Prims.unit", "FStar.List.Tot.Properties.rev_rev'", "FStar.List.Tot.Properties.rev'" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l))
[]
FStar.List.Tot.Properties.rev_involutive
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list 'a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.rev (FStar.List.Tot.Base.rev l) == l)
{ "end_col": 71, "end_line": 355, "start_col": 23, "start_line": 355 }
FStar.Pervasives.Lemma
val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_length l = rev_acc_length l []
val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l =
false
null
true
rev_acc_length l []
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.rev_acc_length", "Prims.Nil", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l))
[]
FStar.List.Tot.Properties.rev_length
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list 'a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.length (FStar.List.Tot.Base.rev l) = FStar.List.Tot.Base.length l)
{ "end_col": 38, "end_line": 131, "start_col": 19, "start_line": 131 }
FStar.Pervasives.Lemma
val precedes_append_cons_r (#a: Type) (l1: list a) (x: a) (l2: list a) : Lemma (requires True) (ensures (x << append l1 (x :: l2))) [SMTPat (x << append l1 (x :: l2))]
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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 precedes_append_cons_r (#a: Type) (l1: list a) (x: a) (l2: list a) : Lemma (requires True) (ensures (x << append l1 (x :: l2))) [SMTPat (x << append l1 (x :: l2))] = match l1 with | [] -> () | _ :: q -> precedes_append_cons_r q x l2
val precedes_append_cons_r (#a: Type) (l1: list a) (x: a) (l2: list a) : Lemma (requires True) (ensures (x << append l1 (x :: l2))) [SMTPat (x << append l1 (x :: l2))] let rec precedes_append_cons_r (#a: Type) (l1: list a) (x: a) (l2: list a) : Lemma (requires True) (ensures (x << append l1 (x :: l2))) [SMTPat (x << append l1 (x :: l2))] =
false
null
true
match l1 with | [] -> () | _ :: q -> precedes_append_cons_r q x l2
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.precedes_append_cons_r", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.precedes", "FStar.List.Tot.Base.append", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2 let rec assoc_append_elim_l (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l1 == None)) (ensures (assoc x (l1 @ l2) == assoc x l2)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_append_elim_l x q l2 let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q let rec assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y . ~ (memP (x, y) l))) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_memP_none x q let assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y . assoc x l == Some y))) = match assoc x l with | None -> assoc_memP_none x l; mem_memP x (map fst l); memP_map_elim fst x l | Some y -> assoc_memP_some x y l; memP_map_intro fst (x, y) l; mem_memP x (map fst l) (** Properties of [fold_left] *) let rec fold_left_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b) . p x ==> memP y l ==> p (f x y) ) (ensures forall (x: a) . p x ==> p (fold_left f x l)) = match l with | [] -> () | y :: q -> fold_left_invar f q p let rec fold_left_map (#a #b #c: Type) (f_aba: a -> b -> Tot a) (f_bc: b -> Tot c) (f_aca: a -> c -> Tot a) (l: list b) : Lemma (requires forall (x: a) (y: b) . f_aba x y == f_aca x (f_bc y) ) (ensures forall (x : a) . fold_left f_aba x l == fold_left f_aca x (map f_bc l) ) = match l with | [] -> () | y :: q -> fold_left_map f_aba f_bc f_aca q let rec map_append (#a #b: Type) (f: a -> Tot b) (l1 l2: list a) : Lemma (ensures map f (l1 @ l2) == map f l1 @ map f l2) = match l1 with | [] -> () | x :: q -> map_append f q l2 let rec fold_left_append (#a #b: Type) (f: a -> b -> Tot a) (l1 l2: list b) : Lemma (ensures forall x . fold_left f x (l1 @ l2) == fold_left f (fold_left f x l1) l2) = match l1 with | [] -> () | x :: q -> fold_left_append f q l2 let rec fold_left_monoid (#a: Type) (opA: (a -> a -> Tot a)) (zeroA: a) (l: list a) : Lemma (requires (forall u v w . (u `opA` (v `opA` w)) == ((u `opA` v) `opA` w)) /\ (forall x . (x `opA` zeroA) == x) /\ (forall x . (zeroA `opA` x) == x)) (ensures forall x . (fold_left opA x l) == (x `opA` (fold_left opA zeroA l))) = match l with | [] -> () | x :: q -> fold_left_monoid opA zeroA q let fold_left_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w . f u (f v w) == f (f u v) w) /\ (forall x . f x z == x) /\ (forall x . f z x == x)) (ensures fold_left f z (l1 @ l2) == f (fold_left f z l1) (fold_left f z l2)) = fold_left_append f l1 l2; fold_left_monoid f z l2 (* Properties of [index] *) private let rec index_extensionality_aux (#a: Type) (l1 l2: list a) (l_len: (l_len: unit { length l1 == length l2 } )) (l_index: (i: (i: nat {i < length l1})) -> Tot (l_index: unit {index l1 i == index l2 i})) : Lemma (ensures (l1 == l2)) = match (l1, l2) with | (a1::q1, a2::q2) -> let a_eq : (a_eq : unit {a1 == a2}) = l_index 0 in let q_len : (q_len: unit {length q1 == length q2}) = () in let q_index (i: (i: nat {i < length q1})) : Tot (q_index: unit {index q1 i == index q2 i}) = l_index (i + 1) in let q_eq : (q_eq : unit {l1 == l2}) = index_extensionality_aux q1 q2 q_len q_index in () | _ -> () let index_extensionality (#a: Type) (l1 l2: list a) : Lemma (requires (length l1 == length l2 /\ (forall (i: nat) . i < length l1 ==> index l1 i == index l2 i))) (ensures (l1 == l2)) = index_extensionality_aux l1 l2 () (fun i -> ()) (** Properties of [strict_suffix_of] *) let rec strict_suffix_of_nil (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (strict_suffix_of [] (x::l))) (decreases l) = match l with | [] -> () | a' :: q -> strict_suffix_of_nil a' q let strict_suffix_of_or_eq_nil (#a: Type) (l: list a) : Lemma (ensures (strict_suffix_of [] l \/ l == [])) = match l with | [] -> () | a :: q -> strict_suffix_of_nil a q let strict_suffix_of_cons (#a: Type) (x: a) (l: list a) : Lemma (ensures (strict_suffix_of l (x::l))) = () let rec strict_suffix_of_trans (#a: Type) (l1 l2 l3: list a) : Lemma (requires True) (ensures ((strict_suffix_of l1 l2 /\ strict_suffix_of l2 l3) ==> strict_suffix_of l1 l3)) (decreases l3) [SMTPat (strict_suffix_of l1 l2); SMTPat (strict_suffix_of l2 l3)] = match l3 with | [] -> () | _ :: q -> strict_suffix_of_trans l1 l2 q let rec strict_suffix_of_correct (#a) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> l1 << l2)) (decreases l2) = match l2 with | [] -> () | _ :: q -> strict_suffix_of_correct l1 q let rec map_strict_suffix_of (#a #b: Type) (f: a -> Tot b) (l1: list a) (l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> strict_suffix_of (map f l1) (map f l2))) (decreases l2) = match l2 with | [] -> () | a::q -> map_strict_suffix_of f l1 q let rec mem_strict_suffix_of (#a: eqtype) (l1: list a) (m: a) (l2: list a) : Lemma (requires True) (ensures ((mem m l1 /\ strict_suffix_of l1 l2) ==> mem m l2)) = match l2 with | [] -> () | a :: q -> mem_strict_suffix_of l1 m q let rec strict_suffix_of_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures (strict_suffix_of l1 l2 ==> (exists l3 . l2 == append l3 l1))) = match l2 with | [] -> () | a :: q -> FStar.Classical.or_elim #(l1 == q) #(strict_suffix_of l1 q) #(fun _ -> exists l3 . l2 == append l3 l1) (fun _ -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) (a :: [])) (fun _ -> FStar.Classical.exists_elim (exists l3 . l2 == append l3 l1) #_ #(fun l3 -> q == append l3 l1) (strict_suffix_of_exists_append l1 q) (fun l3 -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) (a :: l3) )) let strict_suffix_of_or_eq_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures ((strict_suffix_of l1 l2 \/ l1 == l2) ==> (exists l3 . l2 == append l3 l1))) = FStar.Classical.or_elim #(strict_suffix_of l1 l2) #(l1 == l2) #(fun _ -> exists l3 . l2 == append l3 l1) (fun _ -> strict_suffix_of_exists_append l1 l2) (fun _ -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) [] ) (** Properties of << with lists *) let precedes_tl (#a: Type) (l: list a {Cons? l}) : Lemma (ensures (tl l << l)) = () let rec precedes_append_cons_r (#a: Type) (l1: list a) (x: a) (l2: list a) : Lemma (requires True) (ensures (x << append l1 (x :: l2)))
false
false
FStar.List.Tot.Properties.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 precedes_append_cons_r (#a: Type) (l1: list a) (x: a) (l2: list a) : Lemma (requires True) (ensures (x << append l1 (x :: l2))) [SMTPat (x << append l1 (x :: l2))]
[ "recursion" ]
FStar.List.Tot.Properties.precedes_append_cons_r
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list a -> x: a -> l2: Prims.list a -> FStar.Pervasives.Lemma (ensures x << l1 @ x :: l2) [SMTPat (x << l1 @ x :: l2)]
{ "end_col": 43, "end_line": 1033, "start_col": 2, "start_line": 1031 }
FStar.Pervasives.Lemma
val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x
val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x =
false
null
true
match l with | [] -> () | hd :: tl -> partition_mem f tl x
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.bool", "Prims.list", "FStar.List.Tot.Properties.partition_mem", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in
false
false
FStar.List.Tot.Properties.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_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2)))
[ "recursion" ]
FStar.List.Tot.Properties.partition_mem
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> Prims.bool) -> l: Prims.list a -> x: a -> FStar.Pervasives.Lemma (ensures (let _ = FStar.List.Tot.Base.partition f l in (let FStar.Pervasives.Native.Mktuple2 #_ #_ l1 l2 = _ in FStar.List.Tot.Base.mem x l = (FStar.List.Tot.Base.mem x l1 || FStar.List.Tot.Base.mem x l2)) <: Type0))
{ "end_col": 34, "end_line": 530, "start_col": 33, "start_line": 528 }
FStar.Pervasives.Lemma
val assoc_precedes (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) (y: b) : Lemma (requires (assoc x l == Some y)) (ensures (x << l /\ y << l))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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 assoc_precedes (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) (y: b) : Lemma (requires (assoc x l == Some y)) (ensures (x << l /\ y << l)) = assoc_memP_some x y l; memP_precedes (x, y) l
val assoc_precedes (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) (y: b) : Lemma (requires (assoc x l == Some y)) (ensures (x << l /\ y << l)) let assoc_precedes (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) (y: b) : Lemma (requires (assoc x l == Some y)) (ensures (x << l /\ y << l)) =
false
null
true
assoc_memP_some x y l; memP_precedes (x, y) l
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.list", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Properties.memP_precedes", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "FStar.List.Tot.Properties.assoc_memP_some", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.List.Tot.Base.assoc", "FStar.Pervasives.Native.Some", "Prims.squash", "Prims.l_and", "Prims.precedes", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2 let rec assoc_append_elim_l (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l1 == None)) (ensures (assoc x (l1 @ l2) == assoc x l2)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_append_elim_l x q l2 let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q let rec assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y . ~ (memP (x, y) l))) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_memP_none x q let assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y . assoc x l == Some y))) = match assoc x l with | None -> assoc_memP_none x l; mem_memP x (map fst l); memP_map_elim fst x l | Some y -> assoc_memP_some x y l; memP_map_intro fst (x, y) l; mem_memP x (map fst l) (** Properties of [fold_left] *) let rec fold_left_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b) . p x ==> memP y l ==> p (f x y) ) (ensures forall (x: a) . p x ==> p (fold_left f x l)) = match l with | [] -> () | y :: q -> fold_left_invar f q p let rec fold_left_map (#a #b #c: Type) (f_aba: a -> b -> Tot a) (f_bc: b -> Tot c) (f_aca: a -> c -> Tot a) (l: list b) : Lemma (requires forall (x: a) (y: b) . f_aba x y == f_aca x (f_bc y) ) (ensures forall (x : a) . fold_left f_aba x l == fold_left f_aca x (map f_bc l) ) = match l with | [] -> () | y :: q -> fold_left_map f_aba f_bc f_aca q let rec map_append (#a #b: Type) (f: a -> Tot b) (l1 l2: list a) : Lemma (ensures map f (l1 @ l2) == map f l1 @ map f l2) = match l1 with | [] -> () | x :: q -> map_append f q l2 let rec fold_left_append (#a #b: Type) (f: a -> b -> Tot a) (l1 l2: list b) : Lemma (ensures forall x . fold_left f x (l1 @ l2) == fold_left f (fold_left f x l1) l2) = match l1 with | [] -> () | x :: q -> fold_left_append f q l2 let rec fold_left_monoid (#a: Type) (opA: (a -> a -> Tot a)) (zeroA: a) (l: list a) : Lemma (requires (forall u v w . (u `opA` (v `opA` w)) == ((u `opA` v) `opA` w)) /\ (forall x . (x `opA` zeroA) == x) /\ (forall x . (zeroA `opA` x) == x)) (ensures forall x . (fold_left opA x l) == (x `opA` (fold_left opA zeroA l))) = match l with | [] -> () | x :: q -> fold_left_monoid opA zeroA q let fold_left_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w . f u (f v w) == f (f u v) w) /\ (forall x . f x z == x) /\ (forall x . f z x == x)) (ensures fold_left f z (l1 @ l2) == f (fold_left f z l1) (fold_left f z l2)) = fold_left_append f l1 l2; fold_left_monoid f z l2 (* Properties of [index] *) private let rec index_extensionality_aux (#a: Type) (l1 l2: list a) (l_len: (l_len: unit { length l1 == length l2 } )) (l_index: (i: (i: nat {i < length l1})) -> Tot (l_index: unit {index l1 i == index l2 i})) : Lemma (ensures (l1 == l2)) = match (l1, l2) with | (a1::q1, a2::q2) -> let a_eq : (a_eq : unit {a1 == a2}) = l_index 0 in let q_len : (q_len: unit {length q1 == length q2}) = () in let q_index (i: (i: nat {i < length q1})) : Tot (q_index: unit {index q1 i == index q2 i}) = l_index (i + 1) in let q_eq : (q_eq : unit {l1 == l2}) = index_extensionality_aux q1 q2 q_len q_index in () | _ -> () let index_extensionality (#a: Type) (l1 l2: list a) : Lemma (requires (length l1 == length l2 /\ (forall (i: nat) . i < length l1 ==> index l1 i == index l2 i))) (ensures (l1 == l2)) = index_extensionality_aux l1 l2 () (fun i -> ()) (** Properties of [strict_suffix_of] *) let rec strict_suffix_of_nil (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (strict_suffix_of [] (x::l))) (decreases l) = match l with | [] -> () | a' :: q -> strict_suffix_of_nil a' q let strict_suffix_of_or_eq_nil (#a: Type) (l: list a) : Lemma (ensures (strict_suffix_of [] l \/ l == [])) = match l with | [] -> () | a :: q -> strict_suffix_of_nil a q let strict_suffix_of_cons (#a: Type) (x: a) (l: list a) : Lemma (ensures (strict_suffix_of l (x::l))) = () let rec strict_suffix_of_trans (#a: Type) (l1 l2 l3: list a) : Lemma (requires True) (ensures ((strict_suffix_of l1 l2 /\ strict_suffix_of l2 l3) ==> strict_suffix_of l1 l3)) (decreases l3) [SMTPat (strict_suffix_of l1 l2); SMTPat (strict_suffix_of l2 l3)] = match l3 with | [] -> () | _ :: q -> strict_suffix_of_trans l1 l2 q let rec strict_suffix_of_correct (#a) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> l1 << l2)) (decreases l2) = match l2 with | [] -> () | _ :: q -> strict_suffix_of_correct l1 q let rec map_strict_suffix_of (#a #b: Type) (f: a -> Tot b) (l1: list a) (l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> strict_suffix_of (map f l1) (map f l2))) (decreases l2) = match l2 with | [] -> () | a::q -> map_strict_suffix_of f l1 q let rec mem_strict_suffix_of (#a: eqtype) (l1: list a) (m: a) (l2: list a) : Lemma (requires True) (ensures ((mem m l1 /\ strict_suffix_of l1 l2) ==> mem m l2)) = match l2 with | [] -> () | a :: q -> mem_strict_suffix_of l1 m q let rec strict_suffix_of_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures (strict_suffix_of l1 l2 ==> (exists l3 . l2 == append l3 l1))) = match l2 with | [] -> () | a :: q -> FStar.Classical.or_elim #(l1 == q) #(strict_suffix_of l1 q) #(fun _ -> exists l3 . l2 == append l3 l1) (fun _ -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) (a :: [])) (fun _ -> FStar.Classical.exists_elim (exists l3 . l2 == append l3 l1) #_ #(fun l3 -> q == append l3 l1) (strict_suffix_of_exists_append l1 q) (fun l3 -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) (a :: l3) )) let strict_suffix_of_or_eq_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures ((strict_suffix_of l1 l2 \/ l1 == l2) ==> (exists l3 . l2 == append l3 l1))) = FStar.Classical.or_elim #(strict_suffix_of l1 l2) #(l1 == l2) #(fun _ -> exists l3 . l2 == append l3 l1) (fun _ -> strict_suffix_of_exists_append l1 l2) (fun _ -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) [] ) (** Properties of << with lists *) let precedes_tl (#a: Type) (l: list a {Cons? l}) : Lemma (ensures (tl l << l)) = () let rec precedes_append_cons_r (#a: Type) (l1: list a) (x: a) (l2: list a) : Lemma (requires True) (ensures (x << append l1 (x :: l2))) [SMTPat (x << append l1 (x :: l2))] = match l1 with | [] -> () | _ :: q -> precedes_append_cons_r q x l2 let precedes_append_cons_prod_r (#a #b: Type) (l1: list (a * b)) (x: a) (y: b) (l2: list (a * b)) : Lemma (ensures x << (append l1 ((x, y) :: l2)) /\ y << (append l1 ((x, y) :: l2))) = precedes_append_cons_r l1 (x, y) l2 let rec memP_precedes (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> x << l)) (decreases l) = match l with | [] -> () | y :: q -> FStar.Classical.or_elim #(x == y) #(memP x q) #(fun _ -> x << l) (fun _ -> ()) (fun _ -> memP_precedes x q) let assoc_precedes (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) (y: b) : Lemma (requires (assoc x l == Some y))
false
false
FStar.List.Tot.Properties.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_precedes (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) (y: b) : Lemma (requires (assoc x l == Some y)) (ensures (x << l /\ y << l))
[]
FStar.List.Tot.Properties.assoc_precedes
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> l: Prims.list (a * b) -> y: b -> FStar.Pervasives.Lemma (requires FStar.List.Tot.Base.assoc x l == FStar.Pervasives.Native.Some y) (ensures x << l /\ y << l)
{ "end_col": 24, "end_line": 1075, "start_col": 2, "start_line": 1074 }
FStar.Pervasives.Lemma
val strict_suffix_of_correct (#a: _) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> l1 << l2)) (decreases l2)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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 strict_suffix_of_correct (#a) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> l1 << l2)) (decreases l2) = match l2 with | [] -> () | _ :: q -> strict_suffix_of_correct l1 q
val strict_suffix_of_correct (#a: _) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> l1 << l2)) (decreases l2) let rec strict_suffix_of_correct #a (l1: list a) (l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> l1 << l2)) (decreases l2) =
false
null
true
match l2 with | [] -> () | _ :: q -> strict_suffix_of_correct l1 q
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma", "" ]
[ "Prims.list", "FStar.List.Tot.Properties.strict_suffix_of_correct", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "FStar.List.Tot.Base.strict_suffix_of", "Prims.precedes", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2 let rec assoc_append_elim_l (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l1 == None)) (ensures (assoc x (l1 @ l2) == assoc x l2)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_append_elim_l x q l2 let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q let rec assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y . ~ (memP (x, y) l))) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_memP_none x q let assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y . assoc x l == Some y))) = match assoc x l with | None -> assoc_memP_none x l; mem_memP x (map fst l); memP_map_elim fst x l | Some y -> assoc_memP_some x y l; memP_map_intro fst (x, y) l; mem_memP x (map fst l) (** Properties of [fold_left] *) let rec fold_left_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b) . p x ==> memP y l ==> p (f x y) ) (ensures forall (x: a) . p x ==> p (fold_left f x l)) = match l with | [] -> () | y :: q -> fold_left_invar f q p let rec fold_left_map (#a #b #c: Type) (f_aba: a -> b -> Tot a) (f_bc: b -> Tot c) (f_aca: a -> c -> Tot a) (l: list b) : Lemma (requires forall (x: a) (y: b) . f_aba x y == f_aca x (f_bc y) ) (ensures forall (x : a) . fold_left f_aba x l == fold_left f_aca x (map f_bc l) ) = match l with | [] -> () | y :: q -> fold_left_map f_aba f_bc f_aca q let rec map_append (#a #b: Type) (f: a -> Tot b) (l1 l2: list a) : Lemma (ensures map f (l1 @ l2) == map f l1 @ map f l2) = match l1 with | [] -> () | x :: q -> map_append f q l2 let rec fold_left_append (#a #b: Type) (f: a -> b -> Tot a) (l1 l2: list b) : Lemma (ensures forall x . fold_left f x (l1 @ l2) == fold_left f (fold_left f x l1) l2) = match l1 with | [] -> () | x :: q -> fold_left_append f q l2 let rec fold_left_monoid (#a: Type) (opA: (a -> a -> Tot a)) (zeroA: a) (l: list a) : Lemma (requires (forall u v w . (u `opA` (v `opA` w)) == ((u `opA` v) `opA` w)) /\ (forall x . (x `opA` zeroA) == x) /\ (forall x . (zeroA `opA` x) == x)) (ensures forall x . (fold_left opA x l) == (x `opA` (fold_left opA zeroA l))) = match l with | [] -> () | x :: q -> fold_left_monoid opA zeroA q let fold_left_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w . f u (f v w) == f (f u v) w) /\ (forall x . f x z == x) /\ (forall x . f z x == x)) (ensures fold_left f z (l1 @ l2) == f (fold_left f z l1) (fold_left f z l2)) = fold_left_append f l1 l2; fold_left_monoid f z l2 (* Properties of [index] *) private let rec index_extensionality_aux (#a: Type) (l1 l2: list a) (l_len: (l_len: unit { length l1 == length l2 } )) (l_index: (i: (i: nat {i < length l1})) -> Tot (l_index: unit {index l1 i == index l2 i})) : Lemma (ensures (l1 == l2)) = match (l1, l2) with | (a1::q1, a2::q2) -> let a_eq : (a_eq : unit {a1 == a2}) = l_index 0 in let q_len : (q_len: unit {length q1 == length q2}) = () in let q_index (i: (i: nat {i < length q1})) : Tot (q_index: unit {index q1 i == index q2 i}) = l_index (i + 1) in let q_eq : (q_eq : unit {l1 == l2}) = index_extensionality_aux q1 q2 q_len q_index in () | _ -> () let index_extensionality (#a: Type) (l1 l2: list a) : Lemma (requires (length l1 == length l2 /\ (forall (i: nat) . i < length l1 ==> index l1 i == index l2 i))) (ensures (l1 == l2)) = index_extensionality_aux l1 l2 () (fun i -> ()) (** Properties of [strict_suffix_of] *) let rec strict_suffix_of_nil (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (strict_suffix_of [] (x::l))) (decreases l) = match l with | [] -> () | a' :: q -> strict_suffix_of_nil a' q let strict_suffix_of_or_eq_nil (#a: Type) (l: list a) : Lemma (ensures (strict_suffix_of [] l \/ l == [])) = match l with | [] -> () | a :: q -> strict_suffix_of_nil a q let strict_suffix_of_cons (#a: Type) (x: a) (l: list a) : Lemma (ensures (strict_suffix_of l (x::l))) = () let rec strict_suffix_of_trans (#a: Type) (l1 l2 l3: list a) : Lemma (requires True) (ensures ((strict_suffix_of l1 l2 /\ strict_suffix_of l2 l3) ==> strict_suffix_of l1 l3)) (decreases l3) [SMTPat (strict_suffix_of l1 l2); SMTPat (strict_suffix_of l2 l3)] = match l3 with | [] -> () | _ :: q -> strict_suffix_of_trans l1 l2 q let rec strict_suffix_of_correct (#a) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> l1 << l2))
false
false
FStar.List.Tot.Properties.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_suffix_of_correct (#a: _) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> l1 << l2)) (decreases l2)
[ "recursion" ]
FStar.List.Tot.Properties.strict_suffix_of_correct
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list a -> l2: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.strict_suffix_of l1 l2 ==> l1 << l2) (decreases l2)
{ "end_col": 33, "end_line": 953, "start_col": 2, "start_line": 950 }
FStar.Pervasives.Lemma
val fold_left_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b). p x ==> memP y l ==> p (f x y)) (ensures forall (x: a). p x ==> p (fold_left f x l))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b) . p x ==> memP y l ==> p (f x y) ) (ensures forall (x: a) . p x ==> p (fold_left f x l)) = match l with | [] -> () | y :: q -> fold_left_invar f q p
val fold_left_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b). p x ==> memP y l ==> p (f x y)) (ensures forall (x: a). p x ==> p (fold_left f x l)) let rec fold_left_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b). p x ==> memP y l ==> p (f x y)) (ensures forall (x: a). p x ==> p (fold_left f x l)) =
false
null
true
match l with | [] -> () | y :: q -> fold_left_invar f q p
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.fold_left_invar", "Prims.unit", "Prims.l_Forall", "Prims.l_imp", "FStar.List.Tot.Base.memP", "Prims.squash", "FStar.List.Tot.Base.fold_left", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2 let rec assoc_append_elim_l (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l1 == None)) (ensures (assoc x (l1 @ l2) == assoc x l2)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_append_elim_l x q l2 let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q let rec assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y . ~ (memP (x, y) l))) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_memP_none x q let assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y . assoc x l == Some y))) = match assoc x l with | None -> assoc_memP_none x l; mem_memP x (map fst l); memP_map_elim fst x l | Some y -> assoc_memP_some x y l; memP_map_intro fst (x, y) l; mem_memP x (map fst l) (** Properties of [fold_left] *) let rec fold_left_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b) . p x ==> memP y l ==> p (f x y) ) (ensures forall (x: a) . p x ==> p (fold_left f x l))
false
false
FStar.List.Tot.Properties.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_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b). p x ==> memP y l ==> p (f x y)) (ensures forall (x: a). p x ==> p (fold_left f x l))
[ "recursion" ]
FStar.List.Tot.Properties.fold_left_invar
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> _: b -> a) -> l: Prims.list b -> p: (_: a -> Type0) -> FStar.Pervasives.Lemma (requires forall (x: a) (y: b). p x ==> FStar.List.Tot.Base.memP y l ==> p (f x y)) (ensures forall (x: a). p x ==> p (FStar.List.Tot.Base.fold_left f x l))
{ "end_col": 35, "end_line": 813, "start_col": 2, "start_line": 811 }
FStar.Pervasives.Lemma
val assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q
val assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) =
false
null
true
match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma", "" ]
[ "Prims.eqtype", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.op_Equality", "Prims.bool", "FStar.List.Tot.Properties.assoc_memP_some", "Prims.unit", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.List.Tot.Base.assoc", "FStar.Pervasives.Native.Some", "Prims.squash", "FStar.List.Tot.Base.memP", "FStar.Pervasives.Native.Mktuple2", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2 let rec assoc_append_elim_l (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l1 == None)) (ensures (assoc x (l1 @ l2) == assoc x l2)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_append_elim_l x q l2 let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l))
false
false
FStar.List.Tot.Properties.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_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l)
[ "recursion" ]
FStar.List.Tot.Properties.assoc_memP_some
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> y: b -> l: Prims.list (a * b) -> FStar.Pervasives.Lemma (requires FStar.List.Tot.Base.assoc x l == FStar.Pervasives.Native.Some y) (ensures FStar.List.Tot.Base.memP (x, y) l) (decreases l)
{ "end_col": 64, "end_line": 768, "start_col": 2, "start_line": 766 }
FStar.Pervasives.Lemma
val strict_suffix_of_or_eq_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures ((strict_suffix_of l1 l2 \/ l1 == l2) ==> (exists l3. l2 == append l3 l1)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_suffix_of_or_eq_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures ((strict_suffix_of l1 l2 \/ l1 == l2) ==> (exists l3 . l2 == append l3 l1))) = FStar.Classical.or_elim #(strict_suffix_of l1 l2) #(l1 == l2) #(fun _ -> exists l3 . l2 == append l3 l1) (fun _ -> strict_suffix_of_exists_append l1 l2) (fun _ -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) [] )
val strict_suffix_of_or_eq_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures ((strict_suffix_of l1 l2 \/ l1 == l2) ==> (exists l3. l2 == append l3 l1))) let strict_suffix_of_or_eq_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures ((strict_suffix_of l1 l2 \/ l1 == l2) ==> (exists l3. l2 == append l3 l1))) =
false
null
true
FStar.Classical.or_elim #(strict_suffix_of l1 l2) #(l1 == l2) #(fun _ -> exists l3. l2 == append l3 l1) (fun _ -> strict_suffix_of_exists_append l1 l2) (fun _ -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) [])
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.Classical.or_elim", "FStar.List.Tot.Base.strict_suffix_of", "Prims.eq2", "Prims.squash", "Prims.l_or", "Prims.l_Exists", "FStar.List.Tot.Base.append", "FStar.List.Tot.Properties.strict_suffix_of_exists_append", "Prims.unit", "FStar.Classical.exists_intro", "Prims.Nil", "Prims.l_True", "Prims.l_imp", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2 let rec assoc_append_elim_l (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l1 == None)) (ensures (assoc x (l1 @ l2) == assoc x l2)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_append_elim_l x q l2 let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q let rec assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y . ~ (memP (x, y) l))) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_memP_none x q let assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y . assoc x l == Some y))) = match assoc x l with | None -> assoc_memP_none x l; mem_memP x (map fst l); memP_map_elim fst x l | Some y -> assoc_memP_some x y l; memP_map_intro fst (x, y) l; mem_memP x (map fst l) (** Properties of [fold_left] *) let rec fold_left_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b) . p x ==> memP y l ==> p (f x y) ) (ensures forall (x: a) . p x ==> p (fold_left f x l)) = match l with | [] -> () | y :: q -> fold_left_invar f q p let rec fold_left_map (#a #b #c: Type) (f_aba: a -> b -> Tot a) (f_bc: b -> Tot c) (f_aca: a -> c -> Tot a) (l: list b) : Lemma (requires forall (x: a) (y: b) . f_aba x y == f_aca x (f_bc y) ) (ensures forall (x : a) . fold_left f_aba x l == fold_left f_aca x (map f_bc l) ) = match l with | [] -> () | y :: q -> fold_left_map f_aba f_bc f_aca q let rec map_append (#a #b: Type) (f: a -> Tot b) (l1 l2: list a) : Lemma (ensures map f (l1 @ l2) == map f l1 @ map f l2) = match l1 with | [] -> () | x :: q -> map_append f q l2 let rec fold_left_append (#a #b: Type) (f: a -> b -> Tot a) (l1 l2: list b) : Lemma (ensures forall x . fold_left f x (l1 @ l2) == fold_left f (fold_left f x l1) l2) = match l1 with | [] -> () | x :: q -> fold_left_append f q l2 let rec fold_left_monoid (#a: Type) (opA: (a -> a -> Tot a)) (zeroA: a) (l: list a) : Lemma (requires (forall u v w . (u `opA` (v `opA` w)) == ((u `opA` v) `opA` w)) /\ (forall x . (x `opA` zeroA) == x) /\ (forall x . (zeroA `opA` x) == x)) (ensures forall x . (fold_left opA x l) == (x `opA` (fold_left opA zeroA l))) = match l with | [] -> () | x :: q -> fold_left_monoid opA zeroA q let fold_left_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w . f u (f v w) == f (f u v) w) /\ (forall x . f x z == x) /\ (forall x . f z x == x)) (ensures fold_left f z (l1 @ l2) == f (fold_left f z l1) (fold_left f z l2)) = fold_left_append f l1 l2; fold_left_monoid f z l2 (* Properties of [index] *) private let rec index_extensionality_aux (#a: Type) (l1 l2: list a) (l_len: (l_len: unit { length l1 == length l2 } )) (l_index: (i: (i: nat {i < length l1})) -> Tot (l_index: unit {index l1 i == index l2 i})) : Lemma (ensures (l1 == l2)) = match (l1, l2) with | (a1::q1, a2::q2) -> let a_eq : (a_eq : unit {a1 == a2}) = l_index 0 in let q_len : (q_len: unit {length q1 == length q2}) = () in let q_index (i: (i: nat {i < length q1})) : Tot (q_index: unit {index q1 i == index q2 i}) = l_index (i + 1) in let q_eq : (q_eq : unit {l1 == l2}) = index_extensionality_aux q1 q2 q_len q_index in () | _ -> () let index_extensionality (#a: Type) (l1 l2: list a) : Lemma (requires (length l1 == length l2 /\ (forall (i: nat) . i < length l1 ==> index l1 i == index l2 i))) (ensures (l1 == l2)) = index_extensionality_aux l1 l2 () (fun i -> ()) (** Properties of [strict_suffix_of] *) let rec strict_suffix_of_nil (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (strict_suffix_of [] (x::l))) (decreases l) = match l with | [] -> () | a' :: q -> strict_suffix_of_nil a' q let strict_suffix_of_or_eq_nil (#a: Type) (l: list a) : Lemma (ensures (strict_suffix_of [] l \/ l == [])) = match l with | [] -> () | a :: q -> strict_suffix_of_nil a q let strict_suffix_of_cons (#a: Type) (x: a) (l: list a) : Lemma (ensures (strict_suffix_of l (x::l))) = () let rec strict_suffix_of_trans (#a: Type) (l1 l2 l3: list a) : Lemma (requires True) (ensures ((strict_suffix_of l1 l2 /\ strict_suffix_of l2 l3) ==> strict_suffix_of l1 l3)) (decreases l3) [SMTPat (strict_suffix_of l1 l2); SMTPat (strict_suffix_of l2 l3)] = match l3 with | [] -> () | _ :: q -> strict_suffix_of_trans l1 l2 q let rec strict_suffix_of_correct (#a) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> l1 << l2)) (decreases l2) = match l2 with | [] -> () | _ :: q -> strict_suffix_of_correct l1 q let rec map_strict_suffix_of (#a #b: Type) (f: a -> Tot b) (l1: list a) (l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> strict_suffix_of (map f l1) (map f l2))) (decreases l2) = match l2 with | [] -> () | a::q -> map_strict_suffix_of f l1 q let rec mem_strict_suffix_of (#a: eqtype) (l1: list a) (m: a) (l2: list a) : Lemma (requires True) (ensures ((mem m l1 /\ strict_suffix_of l1 l2) ==> mem m l2)) = match l2 with | [] -> () | a :: q -> mem_strict_suffix_of l1 m q let rec strict_suffix_of_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures (strict_suffix_of l1 l2 ==> (exists l3 . l2 == append l3 l1))) = match l2 with | [] -> () | a :: q -> FStar.Classical.or_elim #(l1 == q) #(strict_suffix_of l1 q) #(fun _ -> exists l3 . l2 == append l3 l1) (fun _ -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) (a :: [])) (fun _ -> FStar.Classical.exists_elim (exists l3 . l2 == append l3 l1) #_ #(fun l3 -> q == append l3 l1) (strict_suffix_of_exists_append l1 q) (fun l3 -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) (a :: l3) )) let strict_suffix_of_or_eq_exists_append (#a: Type) (l1 l2: list a) : Lemma
false
false
FStar.List.Tot.Properties.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_suffix_of_or_eq_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures ((strict_suffix_of l1 l2 \/ l1 == l2) ==> (exists l3. l2 == append l3 l1)))
[]
FStar.List.Tot.Properties.strict_suffix_of_or_eq_exists_append
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list a -> l2: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.strict_suffix_of l1 l2 \/ l1 == l2 ==> (exists (l3: Prims.list a). l2 == l3 @ l1))
{ "end_col": 14, "end_line": 1012, "start_col": 2, "start_line": 1003 }
FStar.Pervasives.Lemma
val memP_precedes (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> x << l)) (decreases l)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_precedes (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> x << l)) (decreases l) = match l with | [] -> () | y :: q -> FStar.Classical.or_elim #(x == y) #(memP x q) #(fun _ -> x << l) (fun _ -> ()) (fun _ -> memP_precedes x q)
val memP_precedes (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> x << l)) (decreases l) let rec memP_precedes (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> x << l)) (decreases l) =
false
null
true
match l with | [] -> () | y :: q -> FStar.Classical.or_elim #(x == y) #(memP x q) #(fun _ -> x << l) (fun _ -> ()) (fun _ -> memP_precedes x q)
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma", "" ]
[ "Prims.list", "FStar.Classical.or_elim", "Prims.eq2", "FStar.List.Tot.Base.memP", "Prims.squash", "Prims.l_or", "Prims.precedes", "Prims.unit", "FStar.List.Tot.Properties.memP_precedes", "Prims.l_True", "Prims.l_imp", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2 let rec assoc_append_elim_l (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l1 == None)) (ensures (assoc x (l1 @ l2) == assoc x l2)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_append_elim_l x q l2 let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q let rec assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y . ~ (memP (x, y) l))) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_memP_none x q let assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y . assoc x l == Some y))) = match assoc x l with | None -> assoc_memP_none x l; mem_memP x (map fst l); memP_map_elim fst x l | Some y -> assoc_memP_some x y l; memP_map_intro fst (x, y) l; mem_memP x (map fst l) (** Properties of [fold_left] *) let rec fold_left_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b) . p x ==> memP y l ==> p (f x y) ) (ensures forall (x: a) . p x ==> p (fold_left f x l)) = match l with | [] -> () | y :: q -> fold_left_invar f q p let rec fold_left_map (#a #b #c: Type) (f_aba: a -> b -> Tot a) (f_bc: b -> Tot c) (f_aca: a -> c -> Tot a) (l: list b) : Lemma (requires forall (x: a) (y: b) . f_aba x y == f_aca x (f_bc y) ) (ensures forall (x : a) . fold_left f_aba x l == fold_left f_aca x (map f_bc l) ) = match l with | [] -> () | y :: q -> fold_left_map f_aba f_bc f_aca q let rec map_append (#a #b: Type) (f: a -> Tot b) (l1 l2: list a) : Lemma (ensures map f (l1 @ l2) == map f l1 @ map f l2) = match l1 with | [] -> () | x :: q -> map_append f q l2 let rec fold_left_append (#a #b: Type) (f: a -> b -> Tot a) (l1 l2: list b) : Lemma (ensures forall x . fold_left f x (l1 @ l2) == fold_left f (fold_left f x l1) l2) = match l1 with | [] -> () | x :: q -> fold_left_append f q l2 let rec fold_left_monoid (#a: Type) (opA: (a -> a -> Tot a)) (zeroA: a) (l: list a) : Lemma (requires (forall u v w . (u `opA` (v `opA` w)) == ((u `opA` v) `opA` w)) /\ (forall x . (x `opA` zeroA) == x) /\ (forall x . (zeroA `opA` x) == x)) (ensures forall x . (fold_left opA x l) == (x `opA` (fold_left opA zeroA l))) = match l with | [] -> () | x :: q -> fold_left_monoid opA zeroA q let fold_left_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w . f u (f v w) == f (f u v) w) /\ (forall x . f x z == x) /\ (forall x . f z x == x)) (ensures fold_left f z (l1 @ l2) == f (fold_left f z l1) (fold_left f z l2)) = fold_left_append f l1 l2; fold_left_monoid f z l2 (* Properties of [index] *) private let rec index_extensionality_aux (#a: Type) (l1 l2: list a) (l_len: (l_len: unit { length l1 == length l2 } )) (l_index: (i: (i: nat {i < length l1})) -> Tot (l_index: unit {index l1 i == index l2 i})) : Lemma (ensures (l1 == l2)) = match (l1, l2) with | (a1::q1, a2::q2) -> let a_eq : (a_eq : unit {a1 == a2}) = l_index 0 in let q_len : (q_len: unit {length q1 == length q2}) = () in let q_index (i: (i: nat {i < length q1})) : Tot (q_index: unit {index q1 i == index q2 i}) = l_index (i + 1) in let q_eq : (q_eq : unit {l1 == l2}) = index_extensionality_aux q1 q2 q_len q_index in () | _ -> () let index_extensionality (#a: Type) (l1 l2: list a) : Lemma (requires (length l1 == length l2 /\ (forall (i: nat) . i < length l1 ==> index l1 i == index l2 i))) (ensures (l1 == l2)) = index_extensionality_aux l1 l2 () (fun i -> ()) (** Properties of [strict_suffix_of] *) let rec strict_suffix_of_nil (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (strict_suffix_of [] (x::l))) (decreases l) = match l with | [] -> () | a' :: q -> strict_suffix_of_nil a' q let strict_suffix_of_or_eq_nil (#a: Type) (l: list a) : Lemma (ensures (strict_suffix_of [] l \/ l == [])) = match l with | [] -> () | a :: q -> strict_suffix_of_nil a q let strict_suffix_of_cons (#a: Type) (x: a) (l: list a) : Lemma (ensures (strict_suffix_of l (x::l))) = () let rec strict_suffix_of_trans (#a: Type) (l1 l2 l3: list a) : Lemma (requires True) (ensures ((strict_suffix_of l1 l2 /\ strict_suffix_of l2 l3) ==> strict_suffix_of l1 l3)) (decreases l3) [SMTPat (strict_suffix_of l1 l2); SMTPat (strict_suffix_of l2 l3)] = match l3 with | [] -> () | _ :: q -> strict_suffix_of_trans l1 l2 q let rec strict_suffix_of_correct (#a) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> l1 << l2)) (decreases l2) = match l2 with | [] -> () | _ :: q -> strict_suffix_of_correct l1 q let rec map_strict_suffix_of (#a #b: Type) (f: a -> Tot b) (l1: list a) (l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> strict_suffix_of (map f l1) (map f l2))) (decreases l2) = match l2 with | [] -> () | a::q -> map_strict_suffix_of f l1 q let rec mem_strict_suffix_of (#a: eqtype) (l1: list a) (m: a) (l2: list a) : Lemma (requires True) (ensures ((mem m l1 /\ strict_suffix_of l1 l2) ==> mem m l2)) = match l2 with | [] -> () | a :: q -> mem_strict_suffix_of l1 m q let rec strict_suffix_of_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures (strict_suffix_of l1 l2 ==> (exists l3 . l2 == append l3 l1))) = match l2 with | [] -> () | a :: q -> FStar.Classical.or_elim #(l1 == q) #(strict_suffix_of l1 q) #(fun _ -> exists l3 . l2 == append l3 l1) (fun _ -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) (a :: [])) (fun _ -> FStar.Classical.exists_elim (exists l3 . l2 == append l3 l1) #_ #(fun l3 -> q == append l3 l1) (strict_suffix_of_exists_append l1 q) (fun l3 -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) (a :: l3) )) let strict_suffix_of_or_eq_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures ((strict_suffix_of l1 l2 \/ l1 == l2) ==> (exists l3 . l2 == append l3 l1))) = FStar.Classical.or_elim #(strict_suffix_of l1 l2) #(l1 == l2) #(fun _ -> exists l3 . l2 == append l3 l1) (fun _ -> strict_suffix_of_exists_append l1 l2) (fun _ -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) [] ) (** Properties of << with lists *) let precedes_tl (#a: Type) (l: list a {Cons? l}) : Lemma (ensures (tl l << l)) = () let rec precedes_append_cons_r (#a: Type) (l1: list a) (x: a) (l2: list a) : Lemma (requires True) (ensures (x << append l1 (x :: l2))) [SMTPat (x << append l1 (x :: l2))] = match l1 with | [] -> () | _ :: q -> precedes_append_cons_r q x l2 let precedes_append_cons_prod_r (#a #b: Type) (l1: list (a * b)) (x: a) (y: b) (l2: list (a * b)) : Lemma (ensures x << (append l1 ((x, y) :: l2)) /\ y << (append l1 ((x, y) :: l2))) = precedes_append_cons_r l1 (x, y) l2 let rec memP_precedes (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> x << l))
false
false
FStar.List.Tot.Properties.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_precedes (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> x << l)) (decreases l)
[ "recursion" ]
FStar.List.Tot.Properties.memP_precedes
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> l: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.memP x l ==> x << l) (decreases l)
{ "end_col": 34, "end_line": 1063, "start_col": 2, "start_line": 1055 }
FStar.Pervasives.Lemma
val strict_suffix_of_trans (#a: Type) (l1 l2 l3: list a) : Lemma (requires True) (ensures ((strict_suffix_of l1 l2 /\ strict_suffix_of l2 l3) ==> strict_suffix_of l1 l3)) (decreases l3) [SMTPat (strict_suffix_of l1 l2); SMTPat (strict_suffix_of l2 l3)]
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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 strict_suffix_of_trans (#a: Type) (l1 l2 l3: list a) : Lemma (requires True) (ensures ((strict_suffix_of l1 l2 /\ strict_suffix_of l2 l3) ==> strict_suffix_of l1 l3)) (decreases l3) [SMTPat (strict_suffix_of l1 l2); SMTPat (strict_suffix_of l2 l3)] = match l3 with | [] -> () | _ :: q -> strict_suffix_of_trans l1 l2 q
val strict_suffix_of_trans (#a: Type) (l1 l2 l3: list a) : Lemma (requires True) (ensures ((strict_suffix_of l1 l2 /\ strict_suffix_of l2 l3) ==> strict_suffix_of l1 l3)) (decreases l3) [SMTPat (strict_suffix_of l1 l2); SMTPat (strict_suffix_of l2 l3)] let rec strict_suffix_of_trans (#a: Type) (l1 l2 l3: list a) : Lemma (requires True) (ensures ((strict_suffix_of l1 l2 /\ strict_suffix_of l2 l3) ==> strict_suffix_of l1 l3)) (decreases l3) [SMTPat (strict_suffix_of l1 l2); SMTPat (strict_suffix_of l2 l3)] =
false
null
true
match l3 with | [] -> () | _ :: q -> strict_suffix_of_trans l1 l2 q
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma", "" ]
[ "Prims.list", "FStar.List.Tot.Properties.strict_suffix_of_trans", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "Prims.l_and", "FStar.List.Tot.Base.strict_suffix_of", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2 let rec assoc_append_elim_l (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l1 == None)) (ensures (assoc x (l1 @ l2) == assoc x l2)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_append_elim_l x q l2 let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q let rec assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y . ~ (memP (x, y) l))) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_memP_none x q let assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y . assoc x l == Some y))) = match assoc x l with | None -> assoc_memP_none x l; mem_memP x (map fst l); memP_map_elim fst x l | Some y -> assoc_memP_some x y l; memP_map_intro fst (x, y) l; mem_memP x (map fst l) (** Properties of [fold_left] *) let rec fold_left_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b) . p x ==> memP y l ==> p (f x y) ) (ensures forall (x: a) . p x ==> p (fold_left f x l)) = match l with | [] -> () | y :: q -> fold_left_invar f q p let rec fold_left_map (#a #b #c: Type) (f_aba: a -> b -> Tot a) (f_bc: b -> Tot c) (f_aca: a -> c -> Tot a) (l: list b) : Lemma (requires forall (x: a) (y: b) . f_aba x y == f_aca x (f_bc y) ) (ensures forall (x : a) . fold_left f_aba x l == fold_left f_aca x (map f_bc l) ) = match l with | [] -> () | y :: q -> fold_left_map f_aba f_bc f_aca q let rec map_append (#a #b: Type) (f: a -> Tot b) (l1 l2: list a) : Lemma (ensures map f (l1 @ l2) == map f l1 @ map f l2) = match l1 with | [] -> () | x :: q -> map_append f q l2 let rec fold_left_append (#a #b: Type) (f: a -> b -> Tot a) (l1 l2: list b) : Lemma (ensures forall x . fold_left f x (l1 @ l2) == fold_left f (fold_left f x l1) l2) = match l1 with | [] -> () | x :: q -> fold_left_append f q l2 let rec fold_left_monoid (#a: Type) (opA: (a -> a -> Tot a)) (zeroA: a) (l: list a) : Lemma (requires (forall u v w . (u `opA` (v `opA` w)) == ((u `opA` v) `opA` w)) /\ (forall x . (x `opA` zeroA) == x) /\ (forall x . (zeroA `opA` x) == x)) (ensures forall x . (fold_left opA x l) == (x `opA` (fold_left opA zeroA l))) = match l with | [] -> () | x :: q -> fold_left_monoid opA zeroA q let fold_left_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w . f u (f v w) == f (f u v) w) /\ (forall x . f x z == x) /\ (forall x . f z x == x)) (ensures fold_left f z (l1 @ l2) == f (fold_left f z l1) (fold_left f z l2)) = fold_left_append f l1 l2; fold_left_monoid f z l2 (* Properties of [index] *) private let rec index_extensionality_aux (#a: Type) (l1 l2: list a) (l_len: (l_len: unit { length l1 == length l2 } )) (l_index: (i: (i: nat {i < length l1})) -> Tot (l_index: unit {index l1 i == index l2 i})) : Lemma (ensures (l1 == l2)) = match (l1, l2) with | (a1::q1, a2::q2) -> let a_eq : (a_eq : unit {a1 == a2}) = l_index 0 in let q_len : (q_len: unit {length q1 == length q2}) = () in let q_index (i: (i: nat {i < length q1})) : Tot (q_index: unit {index q1 i == index q2 i}) = l_index (i + 1) in let q_eq : (q_eq : unit {l1 == l2}) = index_extensionality_aux q1 q2 q_len q_index in () | _ -> () let index_extensionality (#a: Type) (l1 l2: list a) : Lemma (requires (length l1 == length l2 /\ (forall (i: nat) . i < length l1 ==> index l1 i == index l2 i))) (ensures (l1 == l2)) = index_extensionality_aux l1 l2 () (fun i -> ()) (** Properties of [strict_suffix_of] *) let rec strict_suffix_of_nil (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (strict_suffix_of [] (x::l))) (decreases l) = match l with | [] -> () | a' :: q -> strict_suffix_of_nil a' q let strict_suffix_of_or_eq_nil (#a: Type) (l: list a) : Lemma (ensures (strict_suffix_of [] l \/ l == [])) = match l with | [] -> () | a :: q -> strict_suffix_of_nil a q let strict_suffix_of_cons (#a: Type) (x: a) (l: list a) : Lemma (ensures (strict_suffix_of l (x::l))) = () let rec strict_suffix_of_trans (#a: Type) (l1 l2 l3: list a) : Lemma (requires True) (ensures ((strict_suffix_of l1 l2 /\ strict_suffix_of l2 l3) ==> strict_suffix_of l1 l3)) (decreases l3)
false
false
FStar.List.Tot.Properties.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_suffix_of_trans (#a: Type) (l1 l2 l3: list a) : Lemma (requires True) (ensures ((strict_suffix_of l1 l2 /\ strict_suffix_of l2 l3) ==> strict_suffix_of l1 l3)) (decreases l3) [SMTPat (strict_suffix_of l1 l2); SMTPat (strict_suffix_of l2 l3)]
[ "recursion" ]
FStar.List.Tot.Properties.strict_suffix_of_trans
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list a -> l2: Prims.list a -> l3: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.strict_suffix_of l1 l2 /\ FStar.List.Tot.Base.strict_suffix_of l2 l3 ==> FStar.List.Tot.Base.strict_suffix_of l1 l3) (decreases l3) [ SMTPat (FStar.List.Tot.Base.strict_suffix_of l1 l2); SMTPat (FStar.List.Tot.Base.strict_suffix_of l2 l3) ]
{ "end_col": 44, "end_line": 943, "start_col": 2, "start_line": 941 }
FStar.Pervasives.Lemma
val map_strict_suffix_of (#a #b: Type) (f: (a -> Tot b)) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> strict_suffix_of (map f l1) (map f l2))) (decreases l2)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_strict_suffix_of (#a #b: Type) (f: a -> Tot b) (l1: list a) (l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> strict_suffix_of (map f l1) (map f l2))) (decreases l2) = match l2 with | [] -> () | a::q -> map_strict_suffix_of f l1 q
val map_strict_suffix_of (#a #b: Type) (f: (a -> Tot b)) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> strict_suffix_of (map f l1) (map f l2))) (decreases l2) let rec map_strict_suffix_of (#a #b: Type) (f: (a -> Tot b)) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> strict_suffix_of (map f l1) (map f l2))) (decreases l2) =
false
null
true
match l2 with | [] -> () | a :: q -> map_strict_suffix_of f l1 q
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma", "" ]
[ "Prims.list", "FStar.List.Tot.Properties.map_strict_suffix_of", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "FStar.List.Tot.Base.strict_suffix_of", "FStar.List.Tot.Base.map", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2 let rec assoc_append_elim_l (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l1 == None)) (ensures (assoc x (l1 @ l2) == assoc x l2)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_append_elim_l x q l2 let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q let rec assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y . ~ (memP (x, y) l))) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_memP_none x q let assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y . assoc x l == Some y))) = match assoc x l with | None -> assoc_memP_none x l; mem_memP x (map fst l); memP_map_elim fst x l | Some y -> assoc_memP_some x y l; memP_map_intro fst (x, y) l; mem_memP x (map fst l) (** Properties of [fold_left] *) let rec fold_left_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b) . p x ==> memP y l ==> p (f x y) ) (ensures forall (x: a) . p x ==> p (fold_left f x l)) = match l with | [] -> () | y :: q -> fold_left_invar f q p let rec fold_left_map (#a #b #c: Type) (f_aba: a -> b -> Tot a) (f_bc: b -> Tot c) (f_aca: a -> c -> Tot a) (l: list b) : Lemma (requires forall (x: a) (y: b) . f_aba x y == f_aca x (f_bc y) ) (ensures forall (x : a) . fold_left f_aba x l == fold_left f_aca x (map f_bc l) ) = match l with | [] -> () | y :: q -> fold_left_map f_aba f_bc f_aca q let rec map_append (#a #b: Type) (f: a -> Tot b) (l1 l2: list a) : Lemma (ensures map f (l1 @ l2) == map f l1 @ map f l2) = match l1 with | [] -> () | x :: q -> map_append f q l2 let rec fold_left_append (#a #b: Type) (f: a -> b -> Tot a) (l1 l2: list b) : Lemma (ensures forall x . fold_left f x (l1 @ l2) == fold_left f (fold_left f x l1) l2) = match l1 with | [] -> () | x :: q -> fold_left_append f q l2 let rec fold_left_monoid (#a: Type) (opA: (a -> a -> Tot a)) (zeroA: a) (l: list a) : Lemma (requires (forall u v w . (u `opA` (v `opA` w)) == ((u `opA` v) `opA` w)) /\ (forall x . (x `opA` zeroA) == x) /\ (forall x . (zeroA `opA` x) == x)) (ensures forall x . (fold_left opA x l) == (x `opA` (fold_left opA zeroA l))) = match l with | [] -> () | x :: q -> fold_left_monoid opA zeroA q let fold_left_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w . f u (f v w) == f (f u v) w) /\ (forall x . f x z == x) /\ (forall x . f z x == x)) (ensures fold_left f z (l1 @ l2) == f (fold_left f z l1) (fold_left f z l2)) = fold_left_append f l1 l2; fold_left_monoid f z l2 (* Properties of [index] *) private let rec index_extensionality_aux (#a: Type) (l1 l2: list a) (l_len: (l_len: unit { length l1 == length l2 } )) (l_index: (i: (i: nat {i < length l1})) -> Tot (l_index: unit {index l1 i == index l2 i})) : Lemma (ensures (l1 == l2)) = match (l1, l2) with | (a1::q1, a2::q2) -> let a_eq : (a_eq : unit {a1 == a2}) = l_index 0 in let q_len : (q_len: unit {length q1 == length q2}) = () in let q_index (i: (i: nat {i < length q1})) : Tot (q_index: unit {index q1 i == index q2 i}) = l_index (i + 1) in let q_eq : (q_eq : unit {l1 == l2}) = index_extensionality_aux q1 q2 q_len q_index in () | _ -> () let index_extensionality (#a: Type) (l1 l2: list a) : Lemma (requires (length l1 == length l2 /\ (forall (i: nat) . i < length l1 ==> index l1 i == index l2 i))) (ensures (l1 == l2)) = index_extensionality_aux l1 l2 () (fun i -> ()) (** Properties of [strict_suffix_of] *) let rec strict_suffix_of_nil (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (strict_suffix_of [] (x::l))) (decreases l) = match l with | [] -> () | a' :: q -> strict_suffix_of_nil a' q let strict_suffix_of_or_eq_nil (#a: Type) (l: list a) : Lemma (ensures (strict_suffix_of [] l \/ l == [])) = match l with | [] -> () | a :: q -> strict_suffix_of_nil a q let strict_suffix_of_cons (#a: Type) (x: a) (l: list a) : Lemma (ensures (strict_suffix_of l (x::l))) = () let rec strict_suffix_of_trans (#a: Type) (l1 l2 l3: list a) : Lemma (requires True) (ensures ((strict_suffix_of l1 l2 /\ strict_suffix_of l2 l3) ==> strict_suffix_of l1 l3)) (decreases l3) [SMTPat (strict_suffix_of l1 l2); SMTPat (strict_suffix_of l2 l3)] = match l3 with | [] -> () | _ :: q -> strict_suffix_of_trans l1 l2 q let rec strict_suffix_of_correct (#a) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> l1 << l2)) (decreases l2) = match l2 with | [] -> () | _ :: q -> strict_suffix_of_correct l1 q let rec map_strict_suffix_of (#a #b: Type) (f: a -> Tot b) (l1: list a) (l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> strict_suffix_of (map f l1) (map f l2)))
false
false
FStar.List.Tot.Properties.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_strict_suffix_of (#a #b: Type) (f: (a -> Tot b)) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> strict_suffix_of (map f l1) (map f l2))) (decreases l2)
[ "recursion" ]
FStar.List.Tot.Properties.map_strict_suffix_of
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> b) -> l1: Prims.list a -> l2: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.strict_suffix_of l1 l2 ==> FStar.List.Tot.Base.strict_suffix_of (FStar.List.Tot.Base.map f l1) (FStar.List.Tot.Base.map f l2)) (decreases l2)
{ "end_col": 31, "end_line": 963, "start_col": 2, "start_line": 960 }
FStar.Pervasives.Lemma
val fold_left_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w. f u (f v w) == f (f u v) w) /\ (forall x. f x z == x) /\ (forall x. f z x == x)) (ensures fold_left f z (l1 @ l2) == f (fold_left f z l1) (fold_left f z l2))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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 fold_left_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w . f u (f v w) == f (f u v) w) /\ (forall x . f x z == x) /\ (forall x . f z x == x)) (ensures fold_left f z (l1 @ l2) == f (fold_left f z l1) (fold_left f z l2)) = fold_left_append f l1 l2; fold_left_monoid f z l2
val fold_left_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w. f u (f v w) == f (f u v) w) /\ (forall x. f x z == x) /\ (forall x. f z x == x)) (ensures fold_left f z (l1 @ l2) == f (fold_left f z l1) (fold_left f z l2)) let fold_left_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w. f u (f v w) == f (f u v) w) /\ (forall x. f x z == x) /\ (forall x. f z x == x)) (ensures fold_left f z (l1 @ l2) == f (fold_left f z l1) (fold_left f z l2)) =
false
null
true
fold_left_append f l1 l2; fold_left_monoid f z l2
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.fold_left_monoid", "Prims.unit", "FStar.List.Tot.Properties.fold_left_append", "Prims.l_and", "Prims.l_Forall", "Prims.eq2", "Prims.squash", "FStar.List.Tot.Base.fold_left", "FStar.List.Tot.Base.op_At", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2 let rec assoc_append_elim_l (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l1 == None)) (ensures (assoc x (l1 @ l2) == assoc x l2)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_append_elim_l x q l2 let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q let rec assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y . ~ (memP (x, y) l))) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_memP_none x q let assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y . assoc x l == Some y))) = match assoc x l with | None -> assoc_memP_none x l; mem_memP x (map fst l); memP_map_elim fst x l | Some y -> assoc_memP_some x y l; memP_map_intro fst (x, y) l; mem_memP x (map fst l) (** Properties of [fold_left] *) let rec fold_left_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b) . p x ==> memP y l ==> p (f x y) ) (ensures forall (x: a) . p x ==> p (fold_left f x l)) = match l with | [] -> () | y :: q -> fold_left_invar f q p let rec fold_left_map (#a #b #c: Type) (f_aba: a -> b -> Tot a) (f_bc: b -> Tot c) (f_aca: a -> c -> Tot a) (l: list b) : Lemma (requires forall (x: a) (y: b) . f_aba x y == f_aca x (f_bc y) ) (ensures forall (x : a) . fold_left f_aba x l == fold_left f_aca x (map f_bc l) ) = match l with | [] -> () | y :: q -> fold_left_map f_aba f_bc f_aca q let rec map_append (#a #b: Type) (f: a -> Tot b) (l1 l2: list a) : Lemma (ensures map f (l1 @ l2) == map f l1 @ map f l2) = match l1 with | [] -> () | x :: q -> map_append f q l2 let rec fold_left_append (#a #b: Type) (f: a -> b -> Tot a) (l1 l2: list b) : Lemma (ensures forall x . fold_left f x (l1 @ l2) == fold_left f (fold_left f x l1) l2) = match l1 with | [] -> () | x :: q -> fold_left_append f q l2 let rec fold_left_monoid (#a: Type) (opA: (a -> a -> Tot a)) (zeroA: a) (l: list a) : Lemma (requires (forall u v w . (u `opA` (v `opA` w)) == ((u `opA` v) `opA` w)) /\ (forall x . (x `opA` zeroA) == x) /\ (forall x . (zeroA `opA` x) == x)) (ensures forall x . (fold_left opA x l) == (x `opA` (fold_left opA zeroA l))) = match l with | [] -> () | x :: q -> fold_left_monoid opA zeroA q let fold_left_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w . f u (f v w) == f (f u v) w) /\ (forall x . f x z == x) /\ (forall x . f z x == x)) (ensures
false
false
FStar.List.Tot.Properties.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_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w. f u (f v w) == f (f u v) w) /\ (forall x. f x z == x) /\ (forall x. f z x == x)) (ensures fold_left f z (l1 @ l2) == f (fold_left f z l1) (fold_left f z l2))
[]
FStar.List.Tot.Properties.fold_left_append_monoid
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> _: a -> a) -> z: a -> l1: Prims.list a -> l2: Prims.list a -> FStar.Pervasives.Lemma (requires (forall (u302: a) (v: a) (w: a). f u302 (f v w) == f (f u302 v) w) /\ (forall (x: a). f x z == x) /\ (forall (x: a). f z x == x)) (ensures FStar.List.Tot.Base.fold_left f z (l1 @ l2) == f (FStar.List.Tot.Base.fold_left f z l1) (FStar.List.Tot.Base.fold_left f z l2))
{ "end_col": 25, "end_line": 881, "start_col": 2, "start_line": 880 }
FStar.Pervasives.Lemma
val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))]
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x)
val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx =
false
null
true
let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x)
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma", "" ]
[ "FStar.Pervasives.Native.tuple2", "Prims.list", "FStar.List.Tot.Properties.lemma_snoc_unsnoc", "FStar.Pervasives.Native.Mktuple2", "FStar.List.Tot.Base.tl", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx))))
false
false
FStar.List.Tot.Properties.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_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))]
[ "recursion" ]
FStar.List.Tot.Properties.lemma_snoc_unsnoc
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
lx: (Prims.list a * a) -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.unsnoc (FStar.List.Tot.Base.snoc lx) == lx) (decreases FStar.List.Tot.Base.length (FStar.Pervasives.Native.fst lx)) [SMTPat (FStar.List.Tot.Base.unsnoc (FStar.List.Tot.Base.snoc lx))]
{ "end_col": 36, "end_line": 418, "start_col": 33, "start_line": 414 }
FStar.Pervasives.Lemma
val append_init_last (#a: Type) (l: list a {Cons? l}) : Lemma (l == append (init l) [last l])
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_init_last (#a: Type) (l: list a { Cons? l }) : Lemma (l == append (init l) [last l]) = match l with | a :: q -> if Cons? q then append_init_last q else ()
val append_init_last (#a: Type) (l: list a {Cons? l}) : Lemma (l == append (init l) [last l]) let rec append_init_last (#a: Type) (l: list a {Cons? l}) : Lemma (l == append (init l) [last l]) =
false
null
true
match l with | a :: q -> if Cons? q then append_init_last q
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.b2t", "Prims.uu___is_Cons", "FStar.List.Tot.Properties.append_init_last", "Prims.bool", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.List.Tot.Base.append", "FStar.List.Tot.Base.init", "Prims.Cons", "FStar.List.Tot.Base.last", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2 let rec assoc_append_elim_l (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l1 == None)) (ensures (assoc x (l1 @ l2) == assoc x l2)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_append_elim_l x q l2 let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q let rec assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y . ~ (memP (x, y) l))) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_memP_none x q let assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y . assoc x l == Some y))) = match assoc x l with | None -> assoc_memP_none x l; mem_memP x (map fst l); memP_map_elim fst x l | Some y -> assoc_memP_some x y l; memP_map_intro fst (x, y) l; mem_memP x (map fst l) (** Properties of [fold_left] *) let rec fold_left_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b) . p x ==> memP y l ==> p (f x y) ) (ensures forall (x: a) . p x ==> p (fold_left f x l)) = match l with | [] -> () | y :: q -> fold_left_invar f q p let rec fold_left_map (#a #b #c: Type) (f_aba: a -> b -> Tot a) (f_bc: b -> Tot c) (f_aca: a -> c -> Tot a) (l: list b) : Lemma (requires forall (x: a) (y: b) . f_aba x y == f_aca x (f_bc y) ) (ensures forall (x : a) . fold_left f_aba x l == fold_left f_aca x (map f_bc l) ) = match l with | [] -> () | y :: q -> fold_left_map f_aba f_bc f_aca q let rec map_append (#a #b: Type) (f: a -> Tot b) (l1 l2: list a) : Lemma (ensures map f (l1 @ l2) == map f l1 @ map f l2) = match l1 with | [] -> () | x :: q -> map_append f q l2 let rec fold_left_append (#a #b: Type) (f: a -> b -> Tot a) (l1 l2: list b) : Lemma (ensures forall x . fold_left f x (l1 @ l2) == fold_left f (fold_left f x l1) l2) = match l1 with | [] -> () | x :: q -> fold_left_append f q l2 let rec fold_left_monoid (#a: Type) (opA: (a -> a -> Tot a)) (zeroA: a) (l: list a) : Lemma (requires (forall u v w . (u `opA` (v `opA` w)) == ((u `opA` v) `opA` w)) /\ (forall x . (x `opA` zeroA) == x) /\ (forall x . (zeroA `opA` x) == x)) (ensures forall x . (fold_left opA x l) == (x `opA` (fold_left opA zeroA l))) = match l with | [] -> () | x :: q -> fold_left_monoid opA zeroA q let fold_left_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w . f u (f v w) == f (f u v) w) /\ (forall x . f x z == x) /\ (forall x . f z x == x)) (ensures fold_left f z (l1 @ l2) == f (fold_left f z l1) (fold_left f z l2)) = fold_left_append f l1 l2; fold_left_monoid f z l2 (* Properties of [index] *) private let rec index_extensionality_aux (#a: Type) (l1 l2: list a) (l_len: (l_len: unit { length l1 == length l2 } )) (l_index: (i: (i: nat {i < length l1})) -> Tot (l_index: unit {index l1 i == index l2 i})) : Lemma (ensures (l1 == l2)) = match (l1, l2) with | (a1::q1, a2::q2) -> let a_eq : (a_eq : unit {a1 == a2}) = l_index 0 in let q_len : (q_len: unit {length q1 == length q2}) = () in let q_index (i: (i: nat {i < length q1})) : Tot (q_index: unit {index q1 i == index q2 i}) = l_index (i + 1) in let q_eq : (q_eq : unit {l1 == l2}) = index_extensionality_aux q1 q2 q_len q_index in () | _ -> () let index_extensionality (#a: Type) (l1 l2: list a) : Lemma (requires (length l1 == length l2 /\ (forall (i: nat) . i < length l1 ==> index l1 i == index l2 i))) (ensures (l1 == l2)) = index_extensionality_aux l1 l2 () (fun i -> ()) (** Properties of [strict_suffix_of] *) let rec strict_suffix_of_nil (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (strict_suffix_of [] (x::l))) (decreases l) = match l with | [] -> () | a' :: q -> strict_suffix_of_nil a' q let strict_suffix_of_or_eq_nil (#a: Type) (l: list a) : Lemma (ensures (strict_suffix_of [] l \/ l == [])) = match l with | [] -> () | a :: q -> strict_suffix_of_nil a q let strict_suffix_of_cons (#a: Type) (x: a) (l: list a) : Lemma (ensures (strict_suffix_of l (x::l))) = () let rec strict_suffix_of_trans (#a: Type) (l1 l2 l3: list a) : Lemma (requires True) (ensures ((strict_suffix_of l1 l2 /\ strict_suffix_of l2 l3) ==> strict_suffix_of l1 l3)) (decreases l3) [SMTPat (strict_suffix_of l1 l2); SMTPat (strict_suffix_of l2 l3)] = match l3 with | [] -> () | _ :: q -> strict_suffix_of_trans l1 l2 q let rec strict_suffix_of_correct (#a) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> l1 << l2)) (decreases l2) = match l2 with | [] -> () | _ :: q -> strict_suffix_of_correct l1 q let rec map_strict_suffix_of (#a #b: Type) (f: a -> Tot b) (l1: list a) (l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> strict_suffix_of (map f l1) (map f l2))) (decreases l2) = match l2 with | [] -> () | a::q -> map_strict_suffix_of f l1 q let rec mem_strict_suffix_of (#a: eqtype) (l1: list a) (m: a) (l2: list a) : Lemma (requires True) (ensures ((mem m l1 /\ strict_suffix_of l1 l2) ==> mem m l2)) = match l2 with | [] -> () | a :: q -> mem_strict_suffix_of l1 m q let rec strict_suffix_of_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures (strict_suffix_of l1 l2 ==> (exists l3 . l2 == append l3 l1))) = match l2 with | [] -> () | a :: q -> FStar.Classical.or_elim #(l1 == q) #(strict_suffix_of l1 q) #(fun _ -> exists l3 . l2 == append l3 l1) (fun _ -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) (a :: [])) (fun _ -> FStar.Classical.exists_elim (exists l3 . l2 == append l3 l1) #_ #(fun l3 -> q == append l3 l1) (strict_suffix_of_exists_append l1 q) (fun l3 -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) (a :: l3) )) let strict_suffix_of_or_eq_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures ((strict_suffix_of l1 l2 \/ l1 == l2) ==> (exists l3 . l2 == append l3 l1))) = FStar.Classical.or_elim #(strict_suffix_of l1 l2) #(l1 == l2) #(fun _ -> exists l3 . l2 == append l3 l1) (fun _ -> strict_suffix_of_exists_append l1 l2) (fun _ -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) [] ) (** Properties of << with lists *) let precedes_tl (#a: Type) (l: list a {Cons? l}) : Lemma (ensures (tl l << l)) = () let rec precedes_append_cons_r (#a: Type) (l1: list a) (x: a) (l2: list a) : Lemma (requires True) (ensures (x << append l1 (x :: l2))) [SMTPat (x << append l1 (x :: l2))] = match l1 with | [] -> () | _ :: q -> precedes_append_cons_r q x l2 let precedes_append_cons_prod_r (#a #b: Type) (l1: list (a * b)) (x: a) (y: b) (l2: list (a * b)) : Lemma (ensures x << (append l1 ((x, y) :: l2)) /\ y << (append l1 ((x, y) :: l2))) = precedes_append_cons_r l1 (x, y) l2 let rec memP_precedes (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> x << l)) (decreases l) = match l with | [] -> () | y :: q -> FStar.Classical.or_elim #(x == y) #(memP x q) #(fun _ -> x << l) (fun _ -> ()) (fun _ -> memP_precedes x q) let assoc_precedes (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) (y: b) : Lemma (requires (assoc x l == Some y)) (ensures (x << l /\ y << l)) = assoc_memP_some x y l; memP_precedes (x, y) l (** Properties about find *) let rec find_none (#a: Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma (requires (find f l == None /\ memP x l)) (ensures (f x == false)) = let (x' :: l') = l in Classical.or_elim #(x == x') #(~ (x == x')) #(fun _ -> f x == false) (fun h -> ()) (fun h -> find_none f l' x) (** Properties of init and last *) let rec append_init_last (#a: Type) (l: list a { Cons? l }) : Lemma
false
false
FStar.List.Tot.Properties.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_init_last (#a: Type) (l: list a {Cons? l}) : Lemma (l == append (init l) [last l])
[ "recursion" ]
FStar.List.Tot.Properties.append_init_last
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list a {Cons? l} -> FStar.Pervasives.Lemma (ensures l == FStar.List.Tot.Base.init l @ [FStar.List.Tot.Base.last l])
{ "end_col": 8, "end_line": 1105, "start_col": 2, "start_line": 1099 }
FStar.Pervasives.Lemma
val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)]
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_lemma f l = match l with | [] -> () | h::t -> map_lemma f t
val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l =
false
null
true
match l with | [] -> () | h :: t -> map_lemma f t
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.map_lemma", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)]
false
false
FStar.List.Tot.Properties.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_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)]
[ "recursion" ]
FStar.List.Tot.Properties.map_lemma
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: 'a -> 'b) -> l: Prims.list 'a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.length (FStar.List.Tot.Base.map f l) = FStar.List.Tot.Base.length l) [SMTPat (FStar.List.Tot.Base.map f l)]
{ "end_col": 27, "end_line": 388, "start_col": 4, "start_line": 386 }
FStar.Pervasives.Lemma
val mem_strict_suffix_of (#a: eqtype) (l1: list a) (m: a) (l2: list a) : Lemma (requires True) (ensures ((mem m l1 /\ strict_suffix_of l1 l2) ==> mem m l2))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_strict_suffix_of (#a: eqtype) (l1: list a) (m: a) (l2: list a) : Lemma (requires True) (ensures ((mem m l1 /\ strict_suffix_of l1 l2) ==> mem m l2)) = match l2 with | [] -> () | a :: q -> mem_strict_suffix_of l1 m q
val mem_strict_suffix_of (#a: eqtype) (l1: list a) (m: a) (l2: list a) : Lemma (requires True) (ensures ((mem m l1 /\ strict_suffix_of l1 l2) ==> mem m l2)) let rec mem_strict_suffix_of (#a: eqtype) (l1: list a) (m: a) (l2: list a) : Lemma (requires True) (ensures ((mem m l1 /\ strict_suffix_of l1 l2) ==> mem m l2)) =
false
null
true
match l2 with | [] -> () | a :: q -> mem_strict_suffix_of l1 m q
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.list", "FStar.List.Tot.Properties.mem_strict_suffix_of", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "Prims.l_and", "Prims.b2t", "FStar.List.Tot.Base.mem", "FStar.List.Tot.Base.strict_suffix_of", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2 let rec assoc_append_elim_l (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l1 == None)) (ensures (assoc x (l1 @ l2) == assoc x l2)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_append_elim_l x q l2 let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q let rec assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y . ~ (memP (x, y) l))) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_memP_none x q let assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y . assoc x l == Some y))) = match assoc x l with | None -> assoc_memP_none x l; mem_memP x (map fst l); memP_map_elim fst x l | Some y -> assoc_memP_some x y l; memP_map_intro fst (x, y) l; mem_memP x (map fst l) (** Properties of [fold_left] *) let rec fold_left_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b) . p x ==> memP y l ==> p (f x y) ) (ensures forall (x: a) . p x ==> p (fold_left f x l)) = match l with | [] -> () | y :: q -> fold_left_invar f q p let rec fold_left_map (#a #b #c: Type) (f_aba: a -> b -> Tot a) (f_bc: b -> Tot c) (f_aca: a -> c -> Tot a) (l: list b) : Lemma (requires forall (x: a) (y: b) . f_aba x y == f_aca x (f_bc y) ) (ensures forall (x : a) . fold_left f_aba x l == fold_left f_aca x (map f_bc l) ) = match l with | [] -> () | y :: q -> fold_left_map f_aba f_bc f_aca q let rec map_append (#a #b: Type) (f: a -> Tot b) (l1 l2: list a) : Lemma (ensures map f (l1 @ l2) == map f l1 @ map f l2) = match l1 with | [] -> () | x :: q -> map_append f q l2 let rec fold_left_append (#a #b: Type) (f: a -> b -> Tot a) (l1 l2: list b) : Lemma (ensures forall x . fold_left f x (l1 @ l2) == fold_left f (fold_left f x l1) l2) = match l1 with | [] -> () | x :: q -> fold_left_append f q l2 let rec fold_left_monoid (#a: Type) (opA: (a -> a -> Tot a)) (zeroA: a) (l: list a) : Lemma (requires (forall u v w . (u `opA` (v `opA` w)) == ((u `opA` v) `opA` w)) /\ (forall x . (x `opA` zeroA) == x) /\ (forall x . (zeroA `opA` x) == x)) (ensures forall x . (fold_left opA x l) == (x `opA` (fold_left opA zeroA l))) = match l with | [] -> () | x :: q -> fold_left_monoid opA zeroA q let fold_left_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w . f u (f v w) == f (f u v) w) /\ (forall x . f x z == x) /\ (forall x . f z x == x)) (ensures fold_left f z (l1 @ l2) == f (fold_left f z l1) (fold_left f z l2)) = fold_left_append f l1 l2; fold_left_monoid f z l2 (* Properties of [index] *) private let rec index_extensionality_aux (#a: Type) (l1 l2: list a) (l_len: (l_len: unit { length l1 == length l2 } )) (l_index: (i: (i: nat {i < length l1})) -> Tot (l_index: unit {index l1 i == index l2 i})) : Lemma (ensures (l1 == l2)) = match (l1, l2) with | (a1::q1, a2::q2) -> let a_eq : (a_eq : unit {a1 == a2}) = l_index 0 in let q_len : (q_len: unit {length q1 == length q2}) = () in let q_index (i: (i: nat {i < length q1})) : Tot (q_index: unit {index q1 i == index q2 i}) = l_index (i + 1) in let q_eq : (q_eq : unit {l1 == l2}) = index_extensionality_aux q1 q2 q_len q_index in () | _ -> () let index_extensionality (#a: Type) (l1 l2: list a) : Lemma (requires (length l1 == length l2 /\ (forall (i: nat) . i < length l1 ==> index l1 i == index l2 i))) (ensures (l1 == l2)) = index_extensionality_aux l1 l2 () (fun i -> ()) (** Properties of [strict_suffix_of] *) let rec strict_suffix_of_nil (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (strict_suffix_of [] (x::l))) (decreases l) = match l with | [] -> () | a' :: q -> strict_suffix_of_nil a' q let strict_suffix_of_or_eq_nil (#a: Type) (l: list a) : Lemma (ensures (strict_suffix_of [] l \/ l == [])) = match l with | [] -> () | a :: q -> strict_suffix_of_nil a q let strict_suffix_of_cons (#a: Type) (x: a) (l: list a) : Lemma (ensures (strict_suffix_of l (x::l))) = () let rec strict_suffix_of_trans (#a: Type) (l1 l2 l3: list a) : Lemma (requires True) (ensures ((strict_suffix_of l1 l2 /\ strict_suffix_of l2 l3) ==> strict_suffix_of l1 l3)) (decreases l3) [SMTPat (strict_suffix_of l1 l2); SMTPat (strict_suffix_of l2 l3)] = match l3 with | [] -> () | _ :: q -> strict_suffix_of_trans l1 l2 q let rec strict_suffix_of_correct (#a) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> l1 << l2)) (decreases l2) = match l2 with | [] -> () | _ :: q -> strict_suffix_of_correct l1 q let rec map_strict_suffix_of (#a #b: Type) (f: a -> Tot b) (l1: list a) (l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> strict_suffix_of (map f l1) (map f l2))) (decreases l2) = match l2 with | [] -> () | a::q -> map_strict_suffix_of f l1 q let rec mem_strict_suffix_of (#a: eqtype) (l1: list a) (m: a) (l2: list a) : Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_strict_suffix_of (#a: eqtype) (l1: list a) (m: a) (l2: list a) : Lemma (requires True) (ensures ((mem m l1 /\ strict_suffix_of l1 l2) ==> mem m l2))
[ "recursion" ]
FStar.List.Tot.Properties.mem_strict_suffix_of
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list a -> m: a -> l2: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.mem m l1 /\ FStar.List.Tot.Base.strict_suffix_of l1 l2 ==> FStar.List.Tot.Base.mem m l2)
{ "end_col": 31, "end_line": 972, "start_col": 2, "start_line": 969 }
FStar.Pervasives.Lemma
val assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~(assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2
val assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~(assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~(assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) =
false
null
true
match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma", "" ]
[ "Prims.eqtype", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.op_Equality", "Prims.bool", "FStar.List.Tot.Properties.assoc_append_elim_r", "Prims.unit", "Prims.l_or", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.List.Tot.Base.assoc", "FStar.Pervasives.Native.None", "Prims.l_not", "Prims.squash", "FStar.List.Tot.Base.op_At", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1))
false
false
FStar.List.Tot.Properties.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_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~(assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1)
[ "recursion" ]
FStar.List.Tot.Properties.assoc_append_elim_r
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> l1: Prims.list (a * b) -> l2: Prims.list (a * b) -> FStar.Pervasives.Lemma (requires FStar.List.Tot.Base.assoc x l2 == FStar.Pervasives.Native.None \/ ~(FStar.List.Tot.Base.assoc x l1 == FStar.Pervasives.Native.None)) (ensures FStar.List.Tot.Base.assoc x (l1 @ l2) == FStar.List.Tot.Base.assoc x l1) (decreases l1)
{ "end_col": 69, "end_line": 741, "start_col": 2, "start_line": 739 }
FStar.Pervasives.Lemma
val find_none (#a: Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma (requires (find f l == None /\ memP x l)) (ensures (f x == false))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_none (#a: Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma (requires (find f l == None /\ memP x l)) (ensures (f x == false)) = let (x' :: l') = l in Classical.or_elim #(x == x') #(~ (x == x')) #(fun _ -> f x == false) (fun h -> ()) (fun h -> find_none f l' x)
val find_none (#a: Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma (requires (find f l == None /\ memP x l)) (ensures (f x == false)) let rec find_none (#a: Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma (requires (find f l == None /\ memP x l)) (ensures (f x == false)) =
false
null
true
let x' :: l' = l in Classical.or_elim #(x == x') #(~(x == x')) #(fun _ -> f x == false) (fun h -> ()) (fun h -> find_none f l' x)
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.bool", "Prims.list", "FStar.Classical.or_elim", "Prims.eq2", "Prims.l_not", "Prims.squash", "Prims.l_or", "Prims.unit", "FStar.List.Tot.Properties.find_none", "Prims.l_and", "FStar.Pervasives.Native.option", "Prims.b2t", "FStar.List.Tot.Base.find", "FStar.Pervasives.Native.None", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi) (** [sorted f l] holds if, and only if, any two consecutive elements [x], [y] of [l] are such that [f x y] holds *) val sorted: ('a -> 'a -> Tot bool) -> list 'a -> Tot bool let rec sorted f = function | [] | [_] -> true | x::y::tl -> f x y && sorted f (y::tl) (** [f] is a total order if, and only if, it is reflexive, anti-symmetric, transitive and total. *) type total_order (#a:Type) (f: (a -> a -> Tot bool)) = (forall a. f a a) (* reflexivity *) /\ (forall a1 a2. f a1 a2 /\ f a2 a1 ==> a1 == a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) (** Correctness of the merging of two sorted lists around a pivot. *) val append_sorted: #a:eqtype -> f:(a -> a -> Tot bool) -> l1:list a{sorted f l1} -> l2:list a{sorted f l2} -> pivot:a -> Lemma (requires (total_order #a f /\ (forall y. mem y l1 ==> not(f pivot y)) /\ (forall y. mem y l2 ==> f pivot y))) (ensures (sorted f (l1@(pivot::l2)))) [SMTPat (sorted f (l1@(pivot::l2)))] let rec append_sorted #a f l1 l2 pivot = match l1 with | [] -> () | hd::tl -> append_sorted f tl l2 pivot (** Correctness of [sortWith], part 2/2: the elements of [sortWith f l] are sorted according to comparison function [f], and the elements of [sortWith f l] are the elements of [l]. *) val sortWith_sorted: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires (total_order #a (bool_of_compare f))) (ensures ((sorted (bool_of_compare f) (sortWith f l)) /\ (forall x. mem x l = mem x (sortWith f l)))) (decreases (length l)) let rec sortWith_sorted #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_mem_forall (bool_of_compare f pivot) tl; partition_mem_p_forall (bool_of_compare f pivot) tl; sortWith_sorted f lo; sortWith_sorted f hi; append_mem_forall (sortWith f lo) (pivot::sortWith f hi); append_sorted (bool_of_compare f) (sortWith f lo) (sortWith f hi) pivot (** Properties of [noRepeats] *) let noRepeats_nil (#a: eqtype) : Lemma (ensures (noRepeats #a [])) = () let noRepeats_cons (#a: eqtype) (h: a) (tl: list a) : Lemma (requires ((~ (mem h tl)) /\ noRepeats tl)) (ensures (noRepeats #a (h::tl))) = () let rec noRepeats_append_elim (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats (l1 @ l2))) (ensures (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_elim q1 l2 let rec noRepeats_append_intro (#a: eqtype) (l1 l2: list a) : Lemma (requires (noRepeats l1 /\ noRepeats l2 /\ (forall x . mem x l1 ==> ~ (mem x l2)))) (ensures (noRepeats (l1 @ l2))) (decreases l1) = match l1 with | [] -> () | x :: q1 -> append_mem q1 l2 x; noRepeats_append_intro q1 l2 (** Properties of [assoc] *) let assoc_nil (#a: eqtype) (#b: Type) (x: a) : Lemma (ensures (assoc #a #b x [] == None)) = () let assoc_cons_eq (#a: eqtype) (#b: Type) (x: a) (y: b) (q: list (a * b)) : Lemma (ensures (assoc x ((x, y) :: q) == Some y)) = () let assoc_cons_not_eq (#a: eqtype) (#b: Type) (x x': a) (y: b) (q: list (a * b)) : Lemma (requires (x <> x')) (ensures (assoc x' ((x, y) :: q) == assoc x' q)) = () let rec assoc_append_elim_r (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l2 == None \/ ~ (assoc x l1 == None))) (ensures (assoc x (l1 @ l2) == assoc x l1)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_append_elim_r x q l2 let rec assoc_append_elim_l (#a: eqtype) (#b: Type) (x: a) (l1 l2: list (a * b)) : Lemma (requires (assoc x l1 == None)) (ensures (assoc x (l1 @ l2) == assoc x l2)) (decreases l1) = match l1 with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_append_elim_l x q l2 let rec assoc_memP_some (#a: eqtype) (#b: Type) (x: a) (y: b) (l: list (a * b)) : Lemma (requires (assoc x l == Some y)) (ensures (memP (x, y) l)) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then () else assoc_memP_some x y q let rec assoc_memP_none (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (requires (assoc x l == None)) (ensures (forall y . ~ (memP (x, y) l))) (decreases l) = match l with | [] -> () | (x', _) :: q -> if x = x' then assert False else assoc_memP_none x q let assoc_mem (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) : Lemma (ensures (mem x (map fst l) <==> (exists y . assoc x l == Some y))) = match assoc x l with | None -> assoc_memP_none x l; mem_memP x (map fst l); memP_map_elim fst x l | Some y -> assoc_memP_some x y l; memP_map_intro fst (x, y) l; mem_memP x (map fst l) (** Properties of [fold_left] *) let rec fold_left_invar (#a #b: Type) (f: (a -> b -> Tot a)) (l: list b) (p: (a -> Tot Type0)) : Lemma (requires forall (x: a) (y: b) . p x ==> memP y l ==> p (f x y) ) (ensures forall (x: a) . p x ==> p (fold_left f x l)) = match l with | [] -> () | y :: q -> fold_left_invar f q p let rec fold_left_map (#a #b #c: Type) (f_aba: a -> b -> Tot a) (f_bc: b -> Tot c) (f_aca: a -> c -> Tot a) (l: list b) : Lemma (requires forall (x: a) (y: b) . f_aba x y == f_aca x (f_bc y) ) (ensures forall (x : a) . fold_left f_aba x l == fold_left f_aca x (map f_bc l) ) = match l with | [] -> () | y :: q -> fold_left_map f_aba f_bc f_aca q let rec map_append (#a #b: Type) (f: a -> Tot b) (l1 l2: list a) : Lemma (ensures map f (l1 @ l2) == map f l1 @ map f l2) = match l1 with | [] -> () | x :: q -> map_append f q l2 let rec fold_left_append (#a #b: Type) (f: a -> b -> Tot a) (l1 l2: list b) : Lemma (ensures forall x . fold_left f x (l1 @ l2) == fold_left f (fold_left f x l1) l2) = match l1 with | [] -> () | x :: q -> fold_left_append f q l2 let rec fold_left_monoid (#a: Type) (opA: (a -> a -> Tot a)) (zeroA: a) (l: list a) : Lemma (requires (forall u v w . (u `opA` (v `opA` w)) == ((u `opA` v) `opA` w)) /\ (forall x . (x `opA` zeroA) == x) /\ (forall x . (zeroA `opA` x) == x)) (ensures forall x . (fold_left opA x l) == (x `opA` (fold_left opA zeroA l))) = match l with | [] -> () | x :: q -> fold_left_monoid opA zeroA q let fold_left_append_monoid (#a: Type) (f: (a -> a -> Tot a)) (z: a) (l1 l2: list a) : Lemma (requires (forall u v w . f u (f v w) == f (f u v) w) /\ (forall x . f x z == x) /\ (forall x . f z x == x)) (ensures fold_left f z (l1 @ l2) == f (fold_left f z l1) (fold_left f z l2)) = fold_left_append f l1 l2; fold_left_monoid f z l2 (* Properties of [index] *) private let rec index_extensionality_aux (#a: Type) (l1 l2: list a) (l_len: (l_len: unit { length l1 == length l2 } )) (l_index: (i: (i: nat {i < length l1})) -> Tot (l_index: unit {index l1 i == index l2 i})) : Lemma (ensures (l1 == l2)) = match (l1, l2) with | (a1::q1, a2::q2) -> let a_eq : (a_eq : unit {a1 == a2}) = l_index 0 in let q_len : (q_len: unit {length q1 == length q2}) = () in let q_index (i: (i: nat {i < length q1})) : Tot (q_index: unit {index q1 i == index q2 i}) = l_index (i + 1) in let q_eq : (q_eq : unit {l1 == l2}) = index_extensionality_aux q1 q2 q_len q_index in () | _ -> () let index_extensionality (#a: Type) (l1 l2: list a) : Lemma (requires (length l1 == length l2 /\ (forall (i: nat) . i < length l1 ==> index l1 i == index l2 i))) (ensures (l1 == l2)) = index_extensionality_aux l1 l2 () (fun i -> ()) (** Properties of [strict_suffix_of] *) let rec strict_suffix_of_nil (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (strict_suffix_of [] (x::l))) (decreases l) = match l with | [] -> () | a' :: q -> strict_suffix_of_nil a' q let strict_suffix_of_or_eq_nil (#a: Type) (l: list a) : Lemma (ensures (strict_suffix_of [] l \/ l == [])) = match l with | [] -> () | a :: q -> strict_suffix_of_nil a q let strict_suffix_of_cons (#a: Type) (x: a) (l: list a) : Lemma (ensures (strict_suffix_of l (x::l))) = () let rec strict_suffix_of_trans (#a: Type) (l1 l2 l3: list a) : Lemma (requires True) (ensures ((strict_suffix_of l1 l2 /\ strict_suffix_of l2 l3) ==> strict_suffix_of l1 l3)) (decreases l3) [SMTPat (strict_suffix_of l1 l2); SMTPat (strict_suffix_of l2 l3)] = match l3 with | [] -> () | _ :: q -> strict_suffix_of_trans l1 l2 q let rec strict_suffix_of_correct (#a) (l1 l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> l1 << l2)) (decreases l2) = match l2 with | [] -> () | _ :: q -> strict_suffix_of_correct l1 q let rec map_strict_suffix_of (#a #b: Type) (f: a -> Tot b) (l1: list a) (l2: list a) : Lemma (requires True) (ensures (strict_suffix_of l1 l2 ==> strict_suffix_of (map f l1) (map f l2))) (decreases l2) = match l2 with | [] -> () | a::q -> map_strict_suffix_of f l1 q let rec mem_strict_suffix_of (#a: eqtype) (l1: list a) (m: a) (l2: list a) : Lemma (requires True) (ensures ((mem m l1 /\ strict_suffix_of l1 l2) ==> mem m l2)) = match l2 with | [] -> () | a :: q -> mem_strict_suffix_of l1 m q let rec strict_suffix_of_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures (strict_suffix_of l1 l2 ==> (exists l3 . l2 == append l3 l1))) = match l2 with | [] -> () | a :: q -> FStar.Classical.or_elim #(l1 == q) #(strict_suffix_of l1 q) #(fun _ -> exists l3 . l2 == append l3 l1) (fun _ -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) (a :: [])) (fun _ -> FStar.Classical.exists_elim (exists l3 . l2 == append l3 l1) #_ #(fun l3 -> q == append l3 l1) (strict_suffix_of_exists_append l1 q) (fun l3 -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) (a :: l3) )) let strict_suffix_of_or_eq_exists_append (#a: Type) (l1 l2: list a) : Lemma (ensures ((strict_suffix_of l1 l2 \/ l1 == l2) ==> (exists l3 . l2 == append l3 l1))) = FStar.Classical.or_elim #(strict_suffix_of l1 l2) #(l1 == l2) #(fun _ -> exists l3 . l2 == append l3 l1) (fun _ -> strict_suffix_of_exists_append l1 l2) (fun _ -> FStar.Classical.exists_intro (fun l3 -> l2 == append l3 l1) [] ) (** Properties of << with lists *) let precedes_tl (#a: Type) (l: list a {Cons? l}) : Lemma (ensures (tl l << l)) = () let rec precedes_append_cons_r (#a: Type) (l1: list a) (x: a) (l2: list a) : Lemma (requires True) (ensures (x << append l1 (x :: l2))) [SMTPat (x << append l1 (x :: l2))] = match l1 with | [] -> () | _ :: q -> precedes_append_cons_r q x l2 let precedes_append_cons_prod_r (#a #b: Type) (l1: list (a * b)) (x: a) (y: b) (l2: list (a * b)) : Lemma (ensures x << (append l1 ((x, y) :: l2)) /\ y << (append l1 ((x, y) :: l2))) = precedes_append_cons_r l1 (x, y) l2 let rec memP_precedes (#a: Type) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> x << l)) (decreases l) = match l with | [] -> () | y :: q -> FStar.Classical.or_elim #(x == y) #(memP x q) #(fun _ -> x << l) (fun _ -> ()) (fun _ -> memP_precedes x q) let assoc_precedes (#a: eqtype) (#b: Type) (x: a) (l: list (a * b)) (y: b) : Lemma (requires (assoc x l == Some y)) (ensures (x << l /\ y << l)) = assoc_memP_some x y l; memP_precedes (x, y) l (** Properties about find *) let rec find_none (#a: Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma (requires (find f l == None /\ memP x l))
false
false
FStar.List.Tot.Properties.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_none (#a: Type) (f: (a -> Tot bool)) (l: list a) (x: a) : Lemma (requires (find f l == None /\ memP x l)) (ensures (f x == false))
[ "recursion" ]
FStar.List.Tot.Properties.find_none
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> Prims.bool) -> l: Prims.list a -> x: a -> FStar.Pervasives.Lemma (requires FStar.List.Tot.Base.find f l == FStar.Pervasives.Native.None /\ FStar.List.Tot.Base.memP x l ) (ensures f x == false)
{ "end_col": 31, "end_line": 1093, "start_col": 1, "start_line": 1087 }
FStar.Pervasives.Lemma
val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))]
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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 lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l
val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l =
false
null
true
let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; let rec aux (l: list a {length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.b2t", "Prims.op_GreaterThan", "FStar.List.Tot.Base.length", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.List.Tot.Base.append", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.splitAt", "Prims.op_Subtraction", "Prims.Nil", "FStar.Pervasives.pattern", "Prims.op_Equality", "Prims.int", "Prims.bool", "FStar.List.Tot.Base.tl", "FStar.List.Tot.Base.lemma_splitAt_snd_length", "FStar.Pervasives.Native.Mktuple2", "Prims.Cons", "FStar.List.Tot.Base.unsnoc" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l))
false
false
FStar.List.Tot.Properties.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_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))]
[]
FStar.List.Tot.Properties.lemma_unsnoc_snoc
{ "file_name": "ulib/FStar.List.Tot.Properties.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} -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.snoc (FStar.List.Tot.Base.unsnoc l) == l) [SMTPat (FStar.List.Tot.Base.snoc (FStar.List.Tot.Base.unsnoc l))]
{ "end_col": 7, "end_line": 406, "start_col": 28, "start_line": 397 }
FStar.Pervasives.Lemma
val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_permutation #a f l = match l with | [] -> () | pivot::tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot::sortWith f hi)
val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l)) let rec sortWith_permutation #a f l =
false
null
true
match l with | [] -> () | pivot :: tl -> let hi, lo = partition (bool_of_compare f pivot) tl in partition_length (bool_of_compare f pivot) tl; partition_count_forall (bool_of_compare f pivot) tl; sortWith_permutation f lo; sortWith_permutation f hi; append_count_forall (sortWith f lo) (pivot :: sortWith f hi)
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma", "" ]
[ "Prims.eqtype", "Prims.int", "Prims.list", "FStar.List.Tot.Properties.append_count_forall", "FStar.List.Tot.Base.sortWith", "Prims.Cons", "Prims.unit", "FStar.List.Tot.Properties.sortWith_permutation", "FStar.List.Tot.Properties.partition_count_forall", "FStar.List.Tot.Base.bool_of_compare", "FStar.List.Tot.Base.partition_length", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l (** Correctness of quicksort **) (** Correctness of [sortWith], part 1/2: the number of occurrences of any [x] in [sortWith f l] is the same as the number of occurrences in [l]. *) val sortWith_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l)))
false
false
FStar.List.Tot.Properties.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_permutation: #a:eqtype -> f:(a -> a -> Tot int) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = count x (sortWith f l))) (decreases (length l))
[ "recursion" ]
FStar.List.Tot.Properties.sortWith_permutation
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> _: a -> Prims.int) -> l: Prims.list a -> FStar.Pervasives.Lemma (ensures forall (x: a). FStar.List.Tot.Base.count x l = FStar.List.Tot.Base.count x (FStar.List.Tot.Base.sortWith f l)) (decreases FStar.List.Tot.Base.length l)
{ "end_col": 65, "end_line": 604, "start_col": 38, "start_line": 596 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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'T = rev'
let rev'T =
false
null
false
rev'
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "total" ]
[ "FStar.List.Tot.Properties.rev'", "Prims.list" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> []
false
false
FStar.List.Tot.Properties.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'T : _: Prims.list _ -> Prims.list _
[]
FStar.List.Tot.Properties.rev'T
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.list _ -> Prims.list _
{ "end_col": 16, "end_line": 319, "start_col": 12, "start_line": 319 }
FStar.Pervasives.Lemma
val lemma_unsnoc_index (#t: Type) (l: list t) (i: nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures (i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1)
val lemma_unsnoc_index (#t: Type) (l: list t) (i: nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures (i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) let rec lemma_unsnoc_index (#t: Type) (l: list t) (i: nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures (i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) =
false
null
true
match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1)
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.nat", "Prims.int", "FStar.List.Tot.Properties.lemma_unsnoc_index", "FStar.List.Tot.Base.tl", "Prims.op_Subtraction", "Prims.unit", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "FStar.List.Tot.Base.length", "Prims.op_LessThan", "Prims.squash", "FStar.Pervasives.Native.fst", "FStar.List.Tot.Base.unsnoc", "Prims.eq2", "FStar.List.Tot.Base.index", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\
false
false
FStar.List.Tot.Properties.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_unsnoc_index (#t: Type) (l: list t) (i: nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures (i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i))
[ "recursion" ]
FStar.List.Tot.Properties.lemma_unsnoc_index
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list t -> i: Prims.nat -> FStar.Pervasives.Lemma (requires FStar.List.Tot.Base.length l > 0 /\ i < FStar.List.Tot.Base.length l - 1) (ensures i < FStar.List.Tot.Base.length (FStar.Pervasives.Native.fst (FStar.List.Tot.Base.unsnoc l)) /\ FStar.List.Tot.Base.index (FStar.Pervasives.Native.fst (FStar.List.Tot.Base.unsnoc l)) i == FStar.List.Tot.Base.index l i)
{ "end_col": 42, "end_line": 458, "start_col": 2, "start_line": 456 }
FStar.Pervasives.Lemma
val subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)]
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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 subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] = mem_subset l l
val subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] let subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)] =
false
null
true
mem_subset l l
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.list", "FStar.List.Tot.Properties.mem_subset", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.b2t", "FStar.List.Tot.Base.subset", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.bool", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' ) let rec lemma_split_using (#t:Type) (l:list t) (x:t{x `memP` l}) : Lemma (ensures ( let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l)) = match l with | [_] -> () | a :: rest -> let goal = let l1, l2 = split_using l x in length l2 > 0 /\ ~(x `memP` l1) /\ hd l2 == x /\ append l1 l2 == l in FStar.Classical.or_elim #_ #_ #(fun () -> goal) (fun (_:squash (a == x)) -> ()) (fun (_:squash (x `memP` rest)) -> lemma_split_using rest x) (** Definition of [index_of] *) (** [index_of l x] gives the index of the leftmost [x] in [l]. NOTE: Uses [strong_excluded_middle] axiom. *) let rec index_of (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (i:nat{i < length l /\ index l i == x}) = match l with | [_] -> 0 | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( 0 ) else ( 1 + index_of rest x ) (** Properties about partition **) (** If [partition f l = (l1, l2)], then for any [x], [x] is in [l] if and only if [x] is in either one of [l1] or [l2] *) val partition_mem: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in mem x l = (mem x l1 || mem x l2))) let rec partition_mem #a f l x = match l with | [] -> () | hd::tl -> partition_mem f tl x (** Same as [partition_mem], but using [forall] *) val partition_mem_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition f l in (forall x. mem x l = (mem x l1 || mem x l2)))) let rec partition_mem_forall #a f l = match l with | [] -> () | hd::tl -> partition_mem_forall f tl (** If [partition f l = (l1, l2)], then for any [x], if [x] is in [l1] (resp. [l2]), then [f x] holds (resp. does not hold) *) val partition_mem_p_forall: #a:eqtype -> p:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (let l1, l2 = partition p l in (forall x. mem x l1 ==> p x) /\ (forall x. mem x l2 ==> not (p x)))) let rec partition_mem_p_forall #a p l = match l with | [] -> () | hd::tl -> partition_mem_p_forall p tl (** If [partition f l = (l1, l2)], then the number of occurrences of any [x] in [l] is the same as the sum of the number of occurrences in [l1] and [l2]. *) val partition_count: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> x:a -> Lemma (requires True) (ensures (count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) let rec partition_count #a f l x = match l with | [] -> () | hd::tl -> partition_count f tl x (** Same as [partition_count], but using [forall] *) val partition_count_forall: #a:eqtype -> f:(a -> Tot bool) -> l:list a -> Lemma (requires True) (ensures (forall x. count x l = (count x (fst (partition f l)) + count x (snd (partition f l))))) (* [SMTPat (partitionT f l)] *) let rec partition_count_forall #a f l= match l with | [] -> () | hd::tl -> partition_count_forall f tl (** Properties about subset **) let rec mem_subset (#a: eqtype) (la lb: list a) : Lemma (requires (forall x. mem x la ==> mem x lb)) (ensures (subset la lb)) = match la with | [] -> () | hd :: tl -> mem_subset tl lb
false
false
FStar.List.Tot.Properties.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 subset_reflexive (#a: eqtype) (l: list a) : Lemma (subset l l) [SMTPat (subset l l)]
[]
FStar.List.Tot.Properties.subset_reflexive
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.subset l l) [SMTPat (FStar.List.Tot.Base.subset l l)]
{ "end_col": 63, "end_line": 585, "start_col": 49, "start_line": 585 }
FStar.Pervasives.Lemma
val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x
val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x =
false
null
true
match l with | [] -> () | hd :: tl -> rev_acc_memP tl (hd :: acc) x
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.rev_acc_memP", "Prims.Cons", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc)))
[ "recursion" ]
FStar.List.Tot.Properties.rev_acc_memP
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list a -> acc: Prims.list a -> x: a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.memP x (FStar.List.Tot.Base.rev_acc l acc) <==> FStar.List.Tot.Base.memP x l \/ FStar.List.Tot.Base.memP x acc)
{ "end_col": 43, "end_line": 138, "start_col": 34, "start_line": 136 }
FStar.Pervasives.Lemma
val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl'
val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l =
false
null
true
match l with | [] -> () | hd' :: tl' -> append_l_cons hd tl tl'
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.append_l_cons", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl)))
[ "recursion" ]
FStar.List.Tot.Properties.append_l_cons
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
hd: 'a -> tl: Prims.list 'a -> l: Prims.list 'a -> FStar.Pervasives.Lemma (ensures l @ hd :: tl == (l @ [hd]) @ tl)
{ "end_col": 41, "end_line": 175, "start_col": 32, "start_line": 173 }
FStar.Pervasives.Lemma
val memP_map_intro (#a #b: Type) (f: (a -> Tot b)) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q
val memP_map_intro (#a #b: Type) (f: (a -> Tot b)) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) let rec memP_map_intro (#a #b: Type) (f: (a -> Tot b)) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) =
false
null
true
match l with | [] -> () | _ :: q -> memP_map_intro f x q
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma", "" ]
[ "Prims.list", "FStar.List.Tot.Properties.memP_map_intro", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "FStar.List.Tot.Base.memP", "FStar.List.Tot.Base.map", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l)))
false
false
FStar.List.Tot.Properties.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_map_intro (#a #b: Type) (f: (a -> Tot b)) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l)
[ "recursion" ]
FStar.List.Tot.Properties.memP_map_intro
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> b) -> x: a -> l: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.memP x l ==> FStar.List.Tot.Base.memP (f x) (FStar.List.Tot.Base.map f l)) (decreases l)
{ "end_col": 34, "end_line": 79, "start_col": 2, "start_line": 77 }
FStar.Pervasives.Lemma
val mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x
val mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) =
false
null
true
match l with | [] -> () | x' :: l' -> mem_count l' x
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.list", "FStar.List.Tot.Properties.mem_count", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_iff", "Prims.b2t", "FStar.List.Tot.Base.mem", "Prims.op_GreaterThan", "FStar.List.Tot.Base.count", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma
false
false
FStar.List.Tot.Properties.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_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0)
[ "recursion" ]
FStar.List.Tot.Properties.mem_count
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list a -> x: a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.mem x l <==> FStar.List.Tot.Base.count x l > 0)
{ "end_col": 30, "end_line": 117, "start_col": 2, "start_line": 115 }
FStar.Pervasives.Lemma
val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl
val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive =
false
null
true
function | [] -> () | hd :: tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.rev'_involutive", "Prims.unit", "FStar.List.Tot.Properties.rev'_append", "FStar.List.Tot.Properties.rev'", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l))
[ "recursion" ]
FStar.List.Tot.Properties.rev'_involutive
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list 'a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Properties.rev' (FStar.List.Tot.Properties.rev' l) == l)
{ "end_col": 60, "end_line": 350, "start_col": 26, "start_line": 348 }
FStar.Pervasives.Lemma
val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2
val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 =
false
null
true
match l1 with | [] -> () | hd :: tl -> append_mem_forall tl l2
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.list", "FStar.List.Tot.Properties.append_mem_forall", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2)))
[ "recursion" ]
FStar.List.Tot.Properties.append_mem_forall
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list a -> l2: Prims.list a -> FStar.Pervasives.Lemma (ensures forall (a: a). FStar.List.Tot.Base.mem a (l1 @ l2) = (FStar.List.Tot.Base.mem a l1 || FStar.List.Tot.Base.mem a l2))
{ "end_col": 37, "end_line": 207, "start_col": 37, "start_line": 205 }
FStar.Pervasives.Lemma
val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl)
val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc =
false
null
true
match l with | [] -> () | hd :: tl -> rev_acc_rev' tl (hd :: acc); append_l_cons hd acc (rev' tl)
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.append_l_cons", "FStar.List.Tot.Properties.rev'", "Prims.unit", "FStar.List.Tot.Properties.rev_acc_rev'", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True))
false
false
FStar.List.Tot.Properties.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_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc)))
[ "recursion" ]
FStar.List.Tot.Properties.rev_acc_rev'
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list 'a -> acc: Prims.list 'a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.rev_acc l acc == FStar.List.Tot.Properties.rev' l @ acc)
{ "end_col": 73, "end_line": 326, "start_col": 29, "start_line": 324 }
FStar.Pervasives.Lemma
val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_rev' l = rev_acc_rev' l []; append_l_nil (rev' l)
val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l =
false
null
true
rev_acc_rev' l []; append_l_nil (rev' l)
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.append_l_nil", "FStar.List.Tot.Properties.rev'", "Prims.unit", "FStar.List.Tot.Properties.rev_acc_rev'", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l)))
[]
FStar.List.Tot.Properties.rev_rev'
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list 'a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.rev l == FStar.List.Tot.Properties.rev' l)
{ "end_col": 57, "end_line": 331, "start_col": 17, "start_line": 331 }
Prims.GTot
val split_using (#t: Type) (l: list t) (x: t{x `memP` l}) : GTot (list t * list t)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_using (#t:Type) (l:list t) (x:t{x `memP` l}) : GTot (list t * list t) = match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ( [], l ) else ( let l1', l2' = split_using rest x in a :: l1', l2' )
val split_using (#t: Type) (l: list t) (x: t{x `memP` l}) : GTot (list t * list t) let rec split_using (#t: Type) (l: list t) (x: t{x `memP` l}) : GTot (list t * list t) =
false
null
false
match l with | [_] -> [], l | a :: rest -> if FStar.StrongExcludedMiddle.strong_excluded_middle (a == x) then ([], l) else (let l1', l2' = split_using rest x in a :: l1', l2')
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "sometrivial" ]
[ "Prims.list", "FStar.List.Tot.Base.memP", "FStar.Pervasives.Native.Mktuple2", "Prims.Nil", "FStar.StrongExcludedMiddle.strong_excluded_middle", "Prims.eq2", "Prims.bool", "Prims.Cons", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Properties.split_using" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l) (** [unsnoc] followed by [append] can be connected to the same vice-versa. *) let rec lemma_unsnoc_append (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) // the [length l2 = 0] is trivial (ensures ( let al, a = unsnoc (l1 @ l2) in let bl, b = unsnoc l2 in al == l1 @ bl /\ a == b)) = match l1 with | [] -> () | _ :: l1' -> lemma_unsnoc_append l1' l2 (** [unsnoc] gives you [last] element, which is [index]ed at [length l - 1] *) let rec lemma_unsnoc_is_last (#t:Type) (l:list t) : Lemma (requires (length l > 0)) (ensures (snd (unsnoc l) == last l /\ snd (unsnoc l) == index l (length l - 1))) = match l with | [_] -> () | _ -> lemma_unsnoc_is_last (tl l) (** [index]ing on the left part of an [unsnoc]d list is the same as indexing the original list. *) let rec lemma_unsnoc_index (#t:Type) (l:list t) (i:nat) : Lemma (requires (length l > 0 /\ i < length l - 1)) (ensures ( i < length (fst (unsnoc l)) /\ index (fst (unsnoc l)) i == index l i)) = match i with | 0 -> () | _ -> lemma_unsnoc_index (tl l) (i - 1) (** Definition and properties about [split_using] *) (** [split_using] splits a list at the first instance of finding an element in it. NOTE: Uses [strong_excluded_middle] axiom. *) let rec split_using (#t:Type) (l:list t) (x:t{x `memP` l}) :
false
false
FStar.List.Tot.Properties.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_using (#t: Type) (l: list t) (x: t{x `memP` l}) : GTot (list t * list t)
[ "recursion" ]
FStar.List.Tot.Properties.split_using
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list t -> x: t{FStar.List.Tot.Base.memP x l} -> Prims.GTot (Prims.list t * Prims.list t)
{ "end_col": 5, "end_line": 476, "start_col": 2, "start_line": 468 }
FStar.Pervasives.Lemma
val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2
val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) let rec append_count_forall #a l1 l2 =
false
null
true
match l1 with | [] -> () | hd :: tl -> append_count_forall tl l2
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.list", "FStar.List.Tot.Properties.append_count_forall", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2)))
false
false
FStar.List.Tot.Properties.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_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2)))
[ "recursion" ]
FStar.List.Tot.Properties.append_count_forall
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list a -> l2: Prims.list a -> FStar.Pervasives.Lemma (ensures forall (a: a). FStar.List.Tot.Base.count a (l1 @ l2) = FStar.List.Tot.Base.count a l1 + FStar.List.Tot.Base.count a l2)
{ "end_col": 39, "end_line": 225, "start_col": 39, "start_line": 223 }
FStar.Pervasives.Lemma
val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])]
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_l_nil = function | [] -> () | hd::tl -> append_l_nil tl
val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil =
false
null
true
function | [] -> () | hd :: tl -> append_l_nil tl
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.append_l_nil", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])]
[ "recursion" ]
FStar.List.Tot.Properties.append_l_nil
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list 'a -> FStar.Pervasives.Lemma (ensures l @ [] == l) [SMTPat (l @ [])]
{ "end_col": 29, "end_line": 163, "start_col": 23, "start_line": 161 }
Prims.Tot
val rev': list 'a -> Tot (list 'a)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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' = function | [] -> [] | hd::tl -> (rev' tl)@[hd]
val rev': list 'a -> Tot (list 'a) let rec rev' =
false
null
false
function | [] -> [] | hd :: tl -> (rev' tl) @ [hd]
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "total" ]
[ "Prims.list", "Prims.Nil", "FStar.List.Tot.Base.op_At", "FStar.List.Tot.Properties.rev'", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **)
false
false
FStar.List.Tot.Properties.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)
[ "recursion" ]
FStar.List.Tot.Properties.rev'
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.list 'a -> Prims.list 'a
{ "end_col": 28, "end_line": 318, "start_col": 15, "start_line": 316 }
FStar.Pervasives.Lemma
val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) )
val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 =
false
null
true
match l1, l2 with | [], [] -> () | hd1 :: tl1, hd2 :: tl2 -> append_inv_tail l tl1 tl2 | [], hd2 :: tl2 -> (match l with | [] -> () | hd :: tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2 @ [hd])) | hd1 :: tl1, [] -> (match l with | [] -> () | hd :: tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1 @ [hd]) [])
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.Pervasives.Native.Mktuple2", "FStar.List.Tot.Properties.append_inv_tail", "Prims.Nil", "FStar.List.Tot.Base.op_At", "Prims.Cons", "Prims.unit", "FStar.List.Tot.Properties.append_l_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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l)))
false
false
FStar.List.Tot.Properties.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_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2))
[ "recursion" ]
FStar.List.Tot.Properties.append_inv_tail
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list 'a -> l1: Prims.list 'a -> l2: Prims.list 'a -> FStar.Pervasives.Lemma (requires l1 @ l == l2 @ l) (ensures l1 == l2)
{ "end_col": 8, "end_line": 261, "start_col": 34, "start_line": 247 }
FStar.Pervasives.Lemma
val append_injective (#a: _) (l0 l0' l1 l1': list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1')
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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 append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1'
val append_injective (#a: _) (l0 l0' l1 l1': list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') let append_injective #a (l0: list a) (l0': list a) (l1: list a) (l1': list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') =
false
null
true
introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> ( l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _ . append_length_inv_head l0 l1 l0' l1' and _ . append_length_inv_tail l0 l1 l0' l1'
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.Classical.Sugar.implies_intro", "Prims.l_and", "Prims.l_or", "Prims.eq2", "Prims.nat", "FStar.List.Tot.Base.length", "FStar.List.Tot.Base.append", "Prims.squash", "FStar.Classical.Sugar.or_elim", "Prims.l_not", "FStar.List.Tot.Properties.append_length_inv_head", "FStar.List.Tot.Properties.append_length_inv_tail", "Prims.unit", "Prims.l_True", "Prims.l_imp", "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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==>
false
false
FStar.List.Tot.Properties.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_injective (#a: _) (l0 l0' l1 l1': list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1')
[]
FStar.List.Tot.Properties.append_injective
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l0: Prims.list a -> l0': Prims.list a -> l1: Prims.list a -> l1': Prims.list a -> FStar.Pervasives.Lemma (ensures (FStar.List.Tot.Base.length l0 == FStar.List.Tot.Base.length l0' \/ FStar.List.Tot.Base.length l1 == FStar.List.Tot.Base.length l1') /\ l0 @ l1 == l0' @ l1' ==> l0 == l0' /\ l1 == l1')
{ "end_col": 49, "end_line": 301, "start_col": 5, "start_line": 292 }
FStar.Pervasives.Lemma
val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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 lemma_unsnoc_length #a l = lemma_snoc_length (unsnoc l)
val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1)) let lemma_unsnoc_length #a l =
false
null
true
lemma_snoc_length (unsnoc l)
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.b2t", "Prims.op_GreaterThan", "FStar.List.Tot.Base.length", "FStar.List.Tot.Properties.lemma_snoc_length", "FStar.List.Tot.Base.unsnoc", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl val rev_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p hd ==> p (hd@[tl])))) (ensures (p l)) let rev_ind p l = rev'_involutive l; rev'_list_ind p (rev' l) (** Properties about iterators **) val map_lemma: f:('a -> Tot 'b) -> l:(list 'a) -> Lemma (requires True) (ensures (length (map f l)) = length l) [SMTPat (map f l)] let rec map_lemma f l = match l with | [] -> () | h::t -> map_lemma f t (** Properties about unsnoc *) (** [unsnoc] is the inverse of [snoc] *) val lemma_unsnoc_snoc: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (snoc (unsnoc l) == l)) [SMTPat (snoc (unsnoc l))] let lemma_unsnoc_snoc #a l = let l', x = unsnoc l in let l1, l2 = l', [x] in lemma_splitAt_snd_length (length l - 1) l; // assert ((l1, l2) == splitAt (length l - 1) l); let rec aux (l:list a{length l > 0}) : Lemma (let l1, l2 = splitAt (length l - 1) l in append l1 l2 == l) = if length l = 1 then () else aux (tl l) in aux l (** [snoc] is the inverse of [unsnoc] *) val lemma_snoc_unsnoc: #a:Type -> lx:(list a * a) -> Lemma (requires True) (ensures (unsnoc (snoc lx) == lx)) (decreases (length (fst (lx)))) [SMTPat (unsnoc (snoc lx))] let rec lemma_snoc_unsnoc #a lx = let l, x = lx in match l with | [] -> () | _ -> lemma_snoc_unsnoc (tl l, x) (** Doing an [unsnoc] gives us a list that is shorter in length by 1 *) val lemma_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1))
false
false
FStar.List.Tot.Properties.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_unsnoc_length: #a:Type -> l:list a{length l > 0} -> Lemma (requires True) (ensures (length (fst (unsnoc l)) == length l - 1))
[]
FStar.List.Tot.Properties.lemma_unsnoc_length
{ "file_name": "ulib/FStar.List.Tot.Properties.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} -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.length (FStar.Pervasives.Native.fst (FStar.List.Tot.Base.unsnoc l)) == FStar.List.Tot.Base.length l - 1)
{ "end_col": 30, "end_line": 425, "start_col": 2, "start_line": 425 }
FStar.Pervasives.Lemma
val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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'_list_ind p = function | [] -> () | hd::tl -> rev'_list_ind p tl
val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l))) let rec rev'_list_ind p =
false
null
true
function | [] -> () | hd :: tl -> rev'_list_ind p tl
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.bool", "FStar.List.Tot.Properties.rev'_list_ind", "Prims.unit" ]
[]
(* 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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd] val rev_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev (l1@l2)) == ((rev l2)@(rev l1)))) let rev_append l1 l2 = rev_rev' l1; rev_rev' l2; rev_rev' (l1@l2); rev'_append l1 l2 val rev'_involutive : l:list 'a -> Lemma (requires True) (ensures (rev' (rev' l) == l)) let rec rev'_involutive = function | [] -> () | hd::tl -> rev'_append (rev' tl) [hd]; rev'_involutive tl val rev_involutive : l:list 'a -> Lemma (requires True) (ensures (rev (rev l) == l)) let rev_involutive l = rev_rev' l; rev_rev' (rev' l); rev'_involutive l (** Properties about snoc *) val lemma_snoc_length : (lx:(list 'a * 'a)) -> Lemma (requires True) (ensures (length (snoc lx) = length (fst lx) + 1)) let lemma_snoc_length (l, x) = append_length l [x] (** Reverse induction principle **) val rev'_list_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl)))))
false
false
FStar.List.Tot.Properties.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_ind: p:(list 'a -> Tot bool) -> l:list 'a -> Lemma (requires ((p []) /\ (forall hd tl. p (rev' tl) ==> p (rev' (hd::tl))))) (ensures (p (rev' l)))
[ "recursion" ]
FStar.List.Tot.Properties.rev'_list_ind
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
p: (_: Prims.list 'a -> Prims.bool) -> l: Prims.list 'a -> FStar.Pervasives.Lemma (requires p [] /\ (forall (hd: 'a) (tl: Prims.list 'a). p (FStar.List.Tot.Properties.rev' tl) ==> p (FStar.List.Tot.Properties.rev' (hd :: tl))) ) (ensures p (FStar.List.Tot.Properties.rev' l))
{ "end_col": 32, "end_line": 371, "start_col": 26, "start_line": 369 }
FStar.Pervasives.Lemma
val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1))))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "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'_append l1 l2 = match l1 with | [] -> append_l_nil (rev' l2) | hd::tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd]
val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1)))) let rec rev'_append l1 l2 =
false
null
true
match l1 with | [] -> append_l_nil (rev' l2) | hd :: tl -> rev'_append tl l2; append_assoc (rev' l2) (rev' tl) [hd]
{ "checked_file": "FStar.List.Tot.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.List.Tot.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Tot.Properties.append_l_nil", "FStar.List.Tot.Properties.rev'", "FStar.List.Tot.Properties.append_assoc", "Prims.Cons", "Prims.Nil", "Prims.unit", "FStar.List.Tot.Properties.rev'_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 states and proves some properties about pure and total operations on lists. @summary Properties of pure total operations on lists *) module FStar.List.Tot.Properties open FStar.List.Tot.Base (** A list indexed by its length **) let llist a (n:nat) = l:list a {length l = n} (** Properties about mem **) (** Correctness of [mem] for types with decidable equality. TODO: replace [mem] with [memP] in relevant lemmas and define the right SMTPat to automatically recover lemmas about [mem] for types with decidable equality *) let rec mem_memP (#a: eqtype) (x: a) (l: list a) : Lemma (ensures (mem x l <==> memP x l)) [SMTPat (mem x l); SMTPat (memP x l)] = match l with | [] -> () | a :: q -> mem_memP x q (** If an element can be [index]ed, then it is a [memP] of the list. *) let rec lemma_index_memP (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (index l i `memP` l)) [SMTPat (index l i `memP` l)] = match i with | 0 -> () | _ -> lemma_index_memP (tl l) (i - 1) (** The empty list has no elements. *) val memP_empty : #a: Type -> x:a -> Lemma (requires (memP x [])) (ensures False) let memP_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val memP_existsb: #a: Type -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ memP x xs)))) let rec memP_existsb #a f xs = match xs with | [] -> () | hd::tl -> memP_existsb f tl let rec memP_map_intro (#a #b: Type) (f: a -> Tot b) (x: a) (l: list a) : Lemma (requires True) (ensures (memP x l ==> memP (f x) (map f l))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_intro f x q (* NOTE: would fail if [requires memP x l] instead of [ ==> ] *) let rec memP_map_elim (#a #b: Type) (f: a -> Tot b) (y: b) (l: list a) : Lemma (requires True) (ensures (memP y (map f l) ==> (exists (x : a) . memP x l /\ f x == y))) (decreases l) = match l with | [] -> () | _ :: q -> memP_map_elim f y q (** The empty list has no elements *) val mem_empty : #a:eqtype -> x:a -> Lemma (requires (mem x [])) (ensures False) let mem_empty #a x = () (** Full specification for [existsb]: [existsb f xs] holds if, and only if, there exists an element [x] of [xs] such that [f x] holds. *) val mem_existsb: #a:eqtype -> f:(a -> Tot bool) -> xs:list a -> Lemma(ensures (existsb f xs <==> (exists (x:a). (f x = true /\ mem x xs)))) let rec mem_existsb #a f xs = match xs with | [] -> () | hd::tl -> mem_existsb f tl let rec mem_count (#a: eqtype) (l: list a) (x: a) : Lemma (mem x l <==> count x l > 0) = match l with | [] -> () | x' :: l' -> mem_count l' x (** Properties about rev **) val rev_acc_length : l:list 'a -> acc:list 'a -> Lemma (requires True) (ensures (length (rev_acc l acc) = length l + length acc)) let rec rev_acc_length l acc = match l with | [] -> () | hd::tl -> rev_acc_length tl (hd::acc) val rev_length : l:list 'a -> Lemma (requires True) (ensures (length (rev l) = length l)) let rev_length l = rev_acc_length l [] val rev_acc_memP : #a:Type -> l:list a -> acc:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev_acc l acc) <==> (memP x l \/ memP x acc))) let rec rev_acc_memP #a l acc x = match l with | [] -> () | hd::tl -> rev_acc_memP tl (hd::acc) x (** A list and its reversed have the same elements *) val rev_memP : #a:Type -> l:list a -> x:a -> Lemma (requires True) (ensures (memP x (rev l) <==> memP x l)) let rev_memP #a l x = rev_acc_memP l [] x val rev_mem : #a:eqtype -> l:list a -> x:a -> Lemma (requires True) (ensures (mem x (rev l) <==> mem x l)) let rev_mem l x = rev_memP l x (** Properties about append **) val append_nil_l: l:list 'a -> Lemma (requires True) (ensures ([]@l == l)) let append_nil_l l = () val append_l_nil: l:list 'a -> Lemma (requires True) (ensures (l@[] == l)) [SMTPat (l@[])] let rec append_l_nil = function | [] -> () | hd::tl -> append_l_nil tl val append_cons_l: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures (((hd::tl)@l) == (hd::(tl@l)))) let append_cons_l hd tl l = () val append_l_cons: hd:'a -> tl:list 'a -> l:list 'a -> Lemma (requires True) (ensures ((l@(hd::tl)) == ((l@[hd])@tl))) let rec append_l_cons hd tl l = match l with | [] -> () | hd'::tl' -> append_l_cons hd tl tl' val append_assoc: l1:list 'a -> l2:list 'a -> l3:list 'a -> Lemma (requires True) (ensures ((l1@(l2@l3)) == ((l1@l2)@l3))) let rec append_assoc l1 l2 l3 = match l1 with | [] -> () | hd::tl -> append_assoc tl l2 l3 val append_length: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures (length (l1@l2) = length l1 + length l2)) [SMTPat (length (l1 @ l2))] let rec append_length l1 l2 = match l1 with | [] -> () | hd::tl -> append_length tl l2 val append_mem: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (mem a (l1@l2) = (mem a l1 || mem a l2))) (* [SMTPat (mem a (l1@l2))] *) let rec append_mem #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_mem tl l2 a val append_mem_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. mem a (l1@l2) = (mem a l1 || mem a l2))) let rec append_mem_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_mem_forall tl l2 val append_count: #t:eqtype -> l1:list t -> l2:list t -> a:t -> Lemma (requires True) (ensures (count a (l1@l2) = (count a l1 + count a l2))) let rec append_count #t l1 l2 a = match l1 with | [] -> () | hd::tl -> append_count tl l2 a val append_count_forall: #a:eqtype -> l1:list a -> l2:list a -> Lemma (requires True) (ensures (forall a. count a (l1@l2) = (count a l1 + count a l2))) (* [SMTPat (l1@l2)] *) let rec append_count_forall #a l1 l2 = match l1 with | [] -> () | hd::tl -> append_count_forall tl l2 val append_eq_nil: l1:list 'a -> l2:list 'a -> Lemma (requires (l1@l2 == [])) (ensures (l1 == [] /\ l2 == [])) let append_eq_nil l1 l2 = () val append_eq_singl: l1:list 'a -> l2:list 'a -> x:'a -> Lemma (requires (l1@l2 == [x])) (ensures ((l1 == [x] /\ l2 == []) \/ (l1 == [] /\ l2 == [x]))) let append_eq_singl l1 l2 x = () val append_inv_head: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l@l1) == (l@l2))) (ensures (l1 == l2)) let rec append_inv_head l l1 l2 = match l with | [] -> () | hd::tl -> append_inv_head tl l1 l2 val append_inv_tail: l:list 'a -> l1:list 'a -> l2:list 'a -> Lemma (requires ((l1@l) == (l2@l))) (ensures (l1 == l2)) let rec append_inv_tail l l1 l2 = match l1, l2 with | [], [] -> () | hd1::tl1, hd2::tl2 -> append_inv_tail l tl1 tl2 | [], hd2::tl2 -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl2; append_inv_tail tl [] (tl2@[hd]) (* We can here apply the induction hypothesis thanks to termination on a lexicographical ordering of the arguments! *) ) | hd1::tl1, [] -> (match l with | [] -> () | hd::tl -> append_l_cons hd tl tl1; append_inv_tail tl (tl1@[hd]) [] (* Idem *) ) let rec append_length_inv_head (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length left1 == length left2)) (ensures (left1 == left2 /\ right1 == right2)) (decreases left1) = match left1 with | [] -> () | _ :: left1' -> append_length_inv_head left1' right1 (tl left2) right2 let append_length_inv_tail (#a: Type) (left1 right1 left2 right2: list a) : Lemma (requires (append left1 right1 == append left2 right2 /\ length right1 == length right2)) (ensures (left1 == left2 /\ right1 == right2)) = append_length left1 right1; append_length left2 right2; append_length_inv_head left1 right1 left2 right2 let append_injective #a (l0 l0':list a) (l1 l1':list a) : Lemma (ensures (length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1' ==> l0 == l0' /\ l1 == l1') = introduce ((length l0 == length l0' \/ length l1 == length l1') /\ append l0 l1 == append l0' l1') ==> (l0 == l0' /\ l1 == l1') with _. eliminate (length l0 == length l0') \/ (length l1 == length l1') returns _ with _. append_length_inv_head l0 l1 l0' l1' and _. append_length_inv_tail l0 l1 l0' l1' (** The [last] element of a list remains the same, even after that list is [append]ed to another list. *) let rec lemma_append_last (#a:Type) (l1 l2:list a) : Lemma (requires (length l2 > 0)) (ensures (last (l1 @ l2) == last l2)) = match l1 with | [] -> () | _ :: l1' -> lemma_append_last l1' l2 (** Properties mixing rev and append **) val rev': list 'a -> Tot (list 'a) let rec rev' = function | [] -> [] | hd::tl -> (rev' tl)@[hd] let rev'T = rev' val rev_acc_rev': l:list 'a -> acc:list 'a -> Lemma (requires (True)) (ensures ((rev_acc l acc) == ((rev' l)@acc))) let rec rev_acc_rev' l acc = match l with | [] -> () | hd::tl -> rev_acc_rev' tl (hd::acc); append_l_cons hd acc (rev' tl) val rev_rev': l:list 'a -> Lemma (requires True) (ensures ((rev l) == (rev' l))) let rev_rev' l = rev_acc_rev' l []; append_l_nil (rev' l) val rev'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True)
false
false
FStar.List.Tot.Properties.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'_append: l1:list 'a -> l2:list 'a -> Lemma (requires True) (ensures ((rev' (l1@l2)) == ((rev' l2)@(rev' l1))))
[ "recursion" ]
FStar.List.Tot.Properties.rev'_append
{ "file_name": "ulib/FStar.List.Tot.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list 'a -> l2: Prims.list 'a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Properties.rev' (l1 @ l2) == FStar.List.Tot.Properties.rev' l2 @ FStar.List.Tot.Properties.rev' l1)
{ "end_col": 72, "end_line": 338, "start_col": 28, "start_line": 336 }